Handle the case where a negative offset in a regular expression match
is larger than the number of lines in the overflow file.
This commit is contained in:
parent
9b51759707
commit
248602a1b2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96710
@ -325,6 +325,8 @@ toomuch(FILE *ofp, long n)
|
|||||||
for (i = 1; i <= nread; i++)
|
for (i = 1; i <= nread; i++)
|
||||||
if (buf[nread - i] == '\n' && n-- == 0)
|
if (buf[nread - i] == '\n' && n-- == 0)
|
||||||
break;
|
break;
|
||||||
|
if (ftello(ofp) == 0)
|
||||||
|
break;
|
||||||
} while (n > 0);
|
} while (n > 0);
|
||||||
if (fseek(ofp, nread - i + 1, SEEK_CUR) != 0)
|
if (fseek(ofp, nread - i + 1, SEEK_CUR) != 0)
|
||||||
err(1, "%s", currfile);
|
err(1, "%s", currfile);
|
||||||
|
Loading…
Reference in New Issue
Block a user