1 /* $NetBSD: ex_equal.c,v 1.2 2013/11/22 15:52:05 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.
14 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 ";
17 #include <sys/types.h>
18 #include <sys/queue.h>
20 #include <bitstring.h>
24 #include "../common/common.h"
27 * ex_equal -- :address =
29 * PUBLIC: int ex_equal __P((SCR *, EXCMD *));
32 ex_equal(SCR
*sp
, EXCMD
*cmdp
)
39 * Print out the line number matching the specified address,
40 * or the number of the last line in the file if no address
44 * Historically, ":0=" displayed 0, and ":=" or ":1=" in an
45 * empty file displayed 1. Until somebody complains loudly,
46 * we're going to do it right. The tables in excmd.c permit
47 * lno to get away with any address from 0 to the end of the
48 * file, which, in an empty file, is 0.
50 if (F_ISSET(cmdp
, E_ADDR_DEF
)) {
51 if (db_last(sp
, &lno
))
54 lno
= cmdp
->addr1
.lno
;
56 (void)ex_printf(sp
, "%ld\n", (unsigned long)lno
);