GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/vi/build/../ex/ex_equal.c Lines: 0 8 0.0 %
Date: 2017-11-07 Branches: 0 6 0.0 %

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