1/* $NetBSD: ex_equal.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ 2/*- 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. 7 * 8 * See the LICENSE file for redistribution information. 9 */ 10 11#include "config.h" 12 13#include <sys/cdefs.h> 14#if 0 15#ifndef lint 16static 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#endif /* not lint */ 18#else 19__RCSID("$NetBSD: ex_equal.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); 20#endif 21 22#include <sys/types.h> 23#include <sys/queue.h> 24 25#include <bitstring.h> 26#include <limits.h> 27#include <stdio.h> 28 29#include "../common/common.h" 30 31/* 32 * ex_equal -- :address = 33 * 34 * PUBLIC: int ex_equal __P((SCR *, EXCMD *)); 35 */ 36int 37ex_equal(SCR *sp, EXCMD *cmdp) 38{ 39 db_recno_t lno; 40 41 NEEDFILE(sp, cmdp); 42 43 /* 44 * Print out the line number matching the specified address, 45 * or the number of the last line in the file if no address 46 * specified. 47 * 48 * !!! 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. 54 */ 55 if (F_ISSET(cmdp, E_ADDR_DEF)) { 56 if (db_last(sp, &lno)) 57 return (1); 58 } else 59 lno = cmdp->addr1.lno; 60 61 (void)ex_printf(sp, "%ld\n", (unsigned long)lno); 62 return (0); 63} 64