1 /* $NetBSD: ex_equal.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
13 #include <sys/cdefs.h>
16 static const char sccsid
[] = "Id: ex_equal.c,v 10.12 2001/06/25 15:19:15 skimo Exp (Berkeley) Date: 2001/06/25 15:19:15 ";
19 __RCSID("$NetBSD: ex_equal.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
25 #include <bitstring.h>
29 #include "../common/common.h"
32 * ex_equal -- :address =
34 * PUBLIC: int ex_equal __P((SCR *, EXCMD *));
37 ex_equal(SCR
*sp
, EXCMD
*cmdp
)
44 * Print out the line number matching the specified address,
45 * or the number of the last line in the file if no address
49 * Historically, ":0=" displayed 0, and ":=" or ":1=" in an
50 * empty file displayed 1. Until somebody complains loudly,
51 * we're going to do it right. The tables in excmd.c permit
52 * lno to get away with any address from 0 to the end of the
53 * file, which, in an empty file, is 0.
55 if (F_ISSET(cmdp
, E_ADDR_DEF
)) {
56 if (db_last(sp
, &lno
))
59 lno
= cmdp
->addr1
.lno
;
61 (void)ex_printf(sp
, "%ld\n", (unsigned long)lno
);