aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/TextInputStream.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/input/TextInputStream.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/input/TextInputStream.cxx b/src/input/TextInputStream.cxx
index b79f64bdc..5a8dcc065 100644
--- a/src/input/TextInputStream.cxx
+++ b/src/input/TextInputStream.cxx
@@ -38,8 +38,8 @@ TextInputStream::ReadLine()
while (true) {
auto dest = buffer.Write();
if (dest.size < 2) {
- /* end of file (or line too long): terminate
- the current line */
+ /* line too long: terminate the current
+ line */
assert(!dest.IsEmpty());
dest[0] = 0;
@@ -66,7 +66,19 @@ TextInputStream::ReadLine()
if (line != nullptr)
return line;
- if (nbytes == 0)
- return nullptr;
+ if (nbytes == 0) {
+ /* end of file: see if there's an unterminated
+ line */
+
+ dest = buffer.Write();
+ assert(!dest.IsEmpty());
+ dest[0] = 0;
+
+ auto r = buffer.Read();
+ buffer.Clear();
+ return r.IsEmpty()
+ ? nullptr
+ : r.data;
+ }
}
}