xref: /csrg-svn/contrib/ed/line_number.c (revision 57710)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rodney Ruddock of the University of Guelph.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)line_number.c	5.2 (Berkeley) 01/23/93";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 
17 #include <db.h>
18 #include <regex.h>
19 #include <setjmp.h>
20 #include <stdio.h>
21 
22 #include "ed.h"
23 #include "extern.h"
24 
25 /*
26  * Converts a LINE to a line number (int) that can be printed to
27  * the device the user is at. Used by n.
28  */
29 int
30 line_number(line_addr)
31 	LINE *line_addr;
32 {
33 	LINE *l_temp1;
34 	int l_cnt = 1;		/* yes! =1 */
35 
36 	l_temp1 = top;
37 	if ((line_addr == NULL) && (top == NULL))
38 		return (0);
39 
40 	for (;;) {
41 		if (sigint_flag)
42 			SIGINT_ACTION;
43 		if (line_addr == l_temp1)
44 			break;
45 		l_temp1 = l_temp1->below;
46 		l_cnt++;
47 	}
48 	return (l_cnt);
49 }
50