diff options
author | Karl Berry <karl@freefriends.org> | 2013-08-06 23:52:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-08-06 23:52:15 +0000 |
commit | 6f855519650fde622bd6326b68315d8cf2650380 (patch) | |
tree | ef13638aa742c62c26c2964c2b3ff8b166b188a9 /Build/source/texk/kpathsea/line.c | |
parent | a2703f81b605770555f3b6ff889723fb17d15c25 (diff) |
do not ignore text on a non-terminated final line, plus new test; move all kpse tests to subdir
git-svn-id: svn://tug.org/texlive/trunk@31370 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/line.c')
-rw-r--r-- | Build/source/texk/kpathsea/line.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Build/source/texk/kpathsea/line.c b/Build/source/texk/kpathsea/line.c index 9d8e4e9eb13..c26303a3012 100644 --- a/Build/source/texk/kpathsea/line.c +++ b/Build/source/texk/kpathsea/line.c @@ -43,11 +43,15 @@ read_line (FILE *f) } } - /* If we read anything, return it. This can't represent a last - ``line'' which doesn't end in a newline, but so what. */ - if (c != EOF) { + /* If we read anything, return it, even a partial last-line-if-file + which is not properly terminated. */ + if (loc == 0 && c == EOF) { + /* At end of file. */ + free (line); + line = NULL; + } else { /* Terminate the string. We can't represent nulls in the file, - either. Again, it doesn't matter. */ + but this doesn't matter. */ line[loc] = 0; /* Absorb LF of a CRLF pair. */ if (c == '\r') { @@ -56,9 +60,6 @@ read_line (FILE *f) ungetc (c, f); } } - } else { /* At end of file. */ - free (line); - line = NULL; } return line; |