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.4 (Berkeley) 04/30/93"; 13 #endif /* not lint */ 14 15 #include <sys/types.h> 16 17 #include <regex.h> 18 #include <setjmp.h> 19 #include <stdio.h> 20 21 #ifdef DBI 22 #include <db.h> 23 #endif 24 25 #include "ed.h" 26 #include "extern.h" 27 28 /* 29 * Converts a LINE to a line number (int) that can be printed to 30 * the device the user is at. Used by n and =. 31 */ 32 int 33 line_number(line_addr) 34 LINE *line_addr; 35 { 36 LINE *l_temp1; 37 int l_cnt = 1; /* yes! =1 */ 38 39 l_temp1 = top; 40 if ((line_addr == NULL) && (top == NULL)) 41 return (0); 42 43 for (;;) { 44 if (line_addr == l_temp1) 45 break; 46 l_temp1 = l_temp1->below; 47 l_cnt++; 48 } 49 return (l_cnt); 50 } 51