157693Sbostic /*- 257693Sbostic * Copyright (c) 1992 The Regents of the University of California. 357693Sbostic * All rights reserved. 457693Sbostic * 557693Sbostic * This code is derived from software contributed to Berkeley by 657693Sbostic * Rodney Ruddock of the University of Guelph. 757693Sbostic * 857693Sbostic * %sccs.include.redist.c% 957693Sbostic */ 1057693Sbostic 1157693Sbostic #ifndef lint 12*57710Sbostic static char sccsid[] = "@(#)line_number.c 5.2 (Berkeley) 01/23/93"; 1357693Sbostic #endif /* not lint */ 1457693Sbostic 15*57710Sbostic #include <sys/types.h> 16*57710Sbostic 17*57710Sbostic #include <db.h> 18*57710Sbostic #include <regex.h> 19*57710Sbostic #include <setjmp.h> 20*57710Sbostic #include <stdio.h> 21*57710Sbostic 2257693Sbostic #include "ed.h" 23*57710Sbostic #include "extern.h" 2457693Sbostic 2557693Sbostic /* 2657693Sbostic * Converts a LINE to a line number (int) that can be printed to 2757693Sbostic * the device the user is at. Used by n. 2857693Sbostic */ 2957693Sbostic int 3057693Sbostic line_number(line_addr) 31*57710Sbostic LINE *line_addr; 3257693Sbostic { 33*57710Sbostic LINE *l_temp1; 34*57710Sbostic int l_cnt = 1; /* yes! =1 */ 3557693Sbostic 36*57710Sbostic l_temp1 = top; 37*57710Sbostic if ((line_addr == NULL) && (top == NULL)) 38*57710Sbostic return (0); 3957693Sbostic 40*57710Sbostic for (;;) { 41*57710Sbostic if (sigint_flag) 42*57710Sbostic SIGINT_ACTION; 43*57710Sbostic if (line_addr == l_temp1) 44*57710Sbostic break; 45*57710Sbostic l_temp1 = l_temp1->below; 46*57710Sbostic l_cnt++; 47*57710Sbostic } 48*57710Sbostic return (l_cnt); 49*57710Sbostic } 50