summaryrefslogtreecommitdiff
path: root/linenum.c
diff options
context:
space:
mode:
Diffstat (limited to 'linenum.c')
-rw-r--r--linenum.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/linenum.c b/linenum.c
index 00cac60d14d3..a3e1b2fcb52d 100644
--- a/linenum.c
+++ b/linenum.c
@@ -469,3 +469,26 @@ currline(where)
linenum--;
return (linenum);
}
+
+/*
+ * Scan entire file, counting line numbers.
+ */
+ public void
+scan_eof(VOID_PARAM)
+{
+ POSITION pos = 0;
+ LINENUM linenum = 0;
+
+ if (ch_seek(0))
+ return;
+ ierror("Determining length of file", NULL_PARG);
+ while (pos != NULL_POSITION)
+ {
+ /* For efficiency, only add one every 256 line numbers. */
+ if ((linenum++ % 256) == 0)
+ add_lnum(linenum, pos);
+ pos = forw_raw_line(pos, (char **)NULL, (int *)NULL);
+ if (ABORT_SIGS())
+ break;
+ }
+}