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