diff options
| author | Xin LI <delphij@FreeBSD.org> | 2021-07-18 05:00:54 +0000 |
|---|---|---|
| committer | Xin LI <delphij@FreeBSD.org> | 2021-07-18 05:00:54 +0000 |
| commit | 1f8b3bb911e37330e00dab1b1e6cba65c573e63c (patch) | |
| tree | 76bc208c60410d67a73ad419308e89b2f17e33df /linenum.c | |
| parent | bb457ab744207cc137364e84eb5e56632cdcdc98 (diff) | |
Diffstat (limited to 'linenum.c')
| -rw-r--r-- | linenum.c | 23 |
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; + } +} |
