text input: fix problem with autoindenting and ^^D
[nvi.git] / ex / ex_equal.c
bloba06e92daac38b7440769ac6010cfcce662cb7dd6
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 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 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
20 #include <limits.h>
21 #include <stdio.h>
23 #include "../common/common.h"
26 * ex_equal -- :address =
28 * PUBLIC: int ex_equal __P((SCR *, EXCMD *));
30 int
31 ex_equal(SCR *sp, EXCMD *cmdp)
33 db_recno_t lno;
35 NEEDFILE(sp, cmdp);
38 * Print out the line number matching the specified address,
39 * or the number of the last line in the file if no address
40 * specified.
42 * !!!
43 * Historically, ":0=" displayed 0, and ":=" or ":1=" in an
44 * empty file displayed 1. Until somebody complains loudly,
45 * we're going to do it right. The tables in excmd.c permit
46 * lno to get away with any address from 0 to the end of the
47 * file, which, in an empty file, is 0.
49 if (F_ISSET(cmdp, E_ADDR_DEF)) {
50 if (db_last(sp, &lno))
51 return (1);
52 } else
53 lno = cmdp->addr1.lno;
55 (void)ex_printf(sp, "%ld\n", lno);
56 return (0);