1b8ba871bSPeter Wemm /*- 2b8ba871bSPeter Wemm * Copyright (c) 1992, 1993, 1994 3b8ba871bSPeter Wemm * The Regents of the University of California. All rights reserved. 4b8ba871bSPeter Wemm * Copyright (c) 1992, 1993, 1994, 1995, 1996 5b8ba871bSPeter Wemm * Keith Bostic. All rights reserved. 6b8ba871bSPeter Wemm * 7b8ba871bSPeter Wemm * See the LICENSE file for redistribution information. 8b8ba871bSPeter Wemm */ 9b8ba871bSPeter Wemm 10b8ba871bSPeter Wemm #include "config.h" 11b8ba871bSPeter Wemm 12b8ba871bSPeter Wemm #ifndef lint 13*f0957ccaSPeter Wemm static const char sccsid[] = "$Id: ex_equal.c,v 10.12 2001/06/25 15:19:15 skimo Exp $"; 14b8ba871bSPeter Wemm #endif /* not lint */ 15b8ba871bSPeter Wemm 16b8ba871bSPeter Wemm #include <sys/types.h> 17b8ba871bSPeter Wemm #include <sys/queue.h> 18*f0957ccaSPeter Wemm #include <sys/time.h> 19b8ba871bSPeter Wemm 20b8ba871bSPeter Wemm #include <bitstring.h> 21b8ba871bSPeter Wemm #include <limits.h> 22b8ba871bSPeter Wemm #include <stdio.h> 23b8ba871bSPeter Wemm 24b8ba871bSPeter Wemm #include "../common/common.h" 25b8ba871bSPeter Wemm 26b8ba871bSPeter Wemm /* 27b8ba871bSPeter Wemm * ex_equal -- :address = 28b8ba871bSPeter Wemm * 29b8ba871bSPeter Wemm * PUBLIC: int ex_equal __P((SCR *, EXCMD *)); 30b8ba871bSPeter Wemm */ 31b8ba871bSPeter Wemm int 32*f0957ccaSPeter Wemm ex_equal(SCR *sp, EXCMD *cmdp) 33b8ba871bSPeter Wemm { 34b8ba871bSPeter Wemm recno_t lno; 35b8ba871bSPeter Wemm 36b8ba871bSPeter Wemm NEEDFILE(sp, cmdp); 37b8ba871bSPeter Wemm 38b8ba871bSPeter Wemm /* 39b8ba871bSPeter Wemm * Print out the line number matching the specified address, 40b8ba871bSPeter Wemm * or the number of the last line in the file if no address 41b8ba871bSPeter Wemm * specified. 42b8ba871bSPeter Wemm * 43b8ba871bSPeter Wemm * !!! 44b8ba871bSPeter Wemm * Historically, ":0=" displayed 0, and ":=" or ":1=" in an 45b8ba871bSPeter Wemm * empty file displayed 1. Until somebody complains loudly, 46b8ba871bSPeter Wemm * we're going to do it right. The tables in excmd.c permit 47b8ba871bSPeter Wemm * lno to get away with any address from 0 to the end of the 48b8ba871bSPeter Wemm * file, which, in an empty file, is 0. 49b8ba871bSPeter Wemm */ 50b8ba871bSPeter Wemm if (F_ISSET(cmdp, E_ADDR_DEF)) { 51b8ba871bSPeter Wemm if (db_last(sp, &lno)) 52b8ba871bSPeter Wemm return (1); 53b8ba871bSPeter Wemm } else 54b8ba871bSPeter Wemm lno = cmdp->addr1.lno; 55b8ba871bSPeter Wemm 56b8ba871bSPeter Wemm (void)ex_printf(sp, "%ld\n", lno); 57b8ba871bSPeter Wemm return (0); 58b8ba871bSPeter Wemm } 59