162321Salfred/*- 262321Salfred * Copyright (c) 1992, 1993, 1994 362321Salfred * The Regents of the University of California. All rights reserved. 462321Salfred * Copyright (c) 1992, 1993, 1994, 1995, 1996 562321Salfred * Keith Bostic. All rights reserved. 662321Salfred * 762321Salfred * See the LICENSE file for redistribution information. 862321Salfred */ 962321Salfred 1062321Salfred#include "config.h" 1162321Salfred 1262321Salfred#ifndef lint 1362321Salfredstatic const char sccsid[] = "$Id: ex_equal.c,v 10.12 2001/06/25 15:19:15 skimo Exp $"; 1462321Salfred#endif /* not lint */ 1592986Sobrien 1662321Salfred#include <sys/types.h> 1762321Salfred#include <sys/queue.h> 1862321Salfred#include <sys/time.h> 1992986Sobrien 2092986Sobrien#include <bitstring.h> 2162321Salfred#include <limits.h> 2262321Salfred#include <stdio.h> 2362321Salfred 2462321Salfred#include "../common/common.h" 2562321Salfred 2692941Sobrien/* 2792941Sobrien * ex_equal -- :address = 2862321Salfred * 2962321Salfred * PUBLIC: int ex_equal(SCR *, EXCMD *); 3062321Salfred */ 3162321Salfredint 3262321Salfredex_equal(SCR *sp, EXCMD *cmdp) 3392905Sobrien{ 3462321Salfred recno_t lno; 3562321Salfred 3662321Salfred NEEDFILE(sp, cmdp); 3762321Salfred 3862321Salfred /* 3962321Salfred * Print out the line number matching the specified address, 4062321Salfred * or the number of the last line in the file if no address 4162321Salfred * specified. 4262321Salfred * 4362321Salfred * !!! 4462321Salfred * Historically, ":0=" displayed 0, and ":=" or ":1=" in an 4562321Salfred * empty file displayed 1. Until somebody complains loudly, 4662321Salfred * we're going to do it right. The tables in excmd.c permit 4762321Salfred * lno to get away with any address from 0 to the end of the 4862321Salfred * file, which, in an empty file, is 0. 4962321Salfred */ 5062321Salfred if (F_ISSET(cmdp, E_ADDR_DEF)) { 5162321Salfred if (db_last(sp, &lno)) 5262321Salfred return (1); 5362321Salfred } else 5492905Sobrien lno = cmdp->addr1.lno; 5562321Salfred 5662321Salfred (void)ex_printf(sp, "%ld\n", lno); 5762321Salfred return (0); 5862321Salfred} 59