mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
sort: fix bug with EOF at buffer refill
* src/sort.c (fillbuf): Don't append eol unless the line is nonempty.
This fixes a bug that was partly but not completely fixed by
the aadc67dfdb commit (dated July 15).
* tests/misc/sort (realloc-buf-2): New test, which catches this
bug on 64-bit hosts.
This commit is contained in:
1 parent
247e239698
commit
c8d3838681
2 files changed
+2
-1
No files matched your search
+1
-1
@@ -1727,7 +1727,7 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
|
||||
buf->eof = true;
|
||||
if (buf->buf == ptrlim)
|
||||
return false;
|
||||
if (ptrlim[-1] != eol)
|
||||
if (line_start != ptrlim && ptrlim[-1] != eol)
|
||||
*ptrlim++ = eol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +367,7 @@ my @Tests =
|
||||
# Exercise the code that enlarges the line buffer. See the thread here:
|
||||
# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11006
|
||||
['realloc-buf', '-S1', {IN=>'a'x4000 ."\n"}, {OUT=>'a'x4000 ."\n"}],
|
||||
['realloc-buf-2', '-S1', {IN=>'a'x5 ."\n"}, {OUT=>'a'x5 ."\n"}],
|
||||
|
||||
["sort-numeric", '--sort=numeric', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}],
|
||||
["sort-gennum", '--sort=general-numeric',
|
||||
|
||||
Reference in new issue
Block a user