Comment PFIL_HOOKS since it should not be needed in GENERIC.
[dragonfly.git] / contrib / nvi / ex / ex_equal.c
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.
6  *
7  * See the LICENSE file for redistribution information.
8  */
9
10 #include "config.h"
11
12 #ifndef lint
13 static const char sccsid[] = "@(#)ex_equal.c    10.10 (Berkeley) 3/6/96";
14 #endif /* not lint */
15
16 #include <sys/types.h>
17 #include <sys/queue.h>
18
19 #include <bitstring.h>
20 #include <limits.h>
21 #include <stdio.h>
22
23 #include "../common/common.h"
24
25 /*
26  * ex_equal -- :address =
27  *
28  * PUBLIC: int ex_equal __P((SCR *, EXCMD *));
29  */
30 int
31 ex_equal(sp, cmdp)
32         SCR *sp;
33         EXCMD *cmdp;
34 {
35         recno_t lno;
36
37         NEEDFILE(sp, cmdp);
38
39         /*
40          * Print out the line number matching the specified address,
41          * or the number of the last line in the file if no address
42          * specified.
43          *
44          * !!!
45          * Historically, ":0=" displayed 0, and ":=" or ":1=" in an
46          * empty file displayed 1.  Until somebody complains loudly,
47          * we're going to do it right.  The tables in excmd.c permit
48          * lno to get away with any address from 0 to the end of the
49          * file, which, in an empty file, is 0.
50          */
51         if (F_ISSET(cmdp, E_ADDR_DEF)) {
52                 if (db_last(sp, &lno))
53                         return (1);
54         } else
55                 lno = cmdp->addr1.lno;
56
57         (void)ex_printf(sp, "%ld\n", lno);
58         return (0);
59 }