aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-28 22:10:47 +0100
committerMax Kellermann <max@duempel.org>2014-10-28 22:10:47 +0100
commit217d88f21f11236478dd41c37b67bef5b0a06497 (patch)
tree84cb55217dea328cbc4e3e9ae3157182509825a7
parent394e3be482ed492e5d90222dab828c2448fbccce (diff)
downloadmpd-217d88f21f11236478dd41c37b67bef5b0a06497.tar.gz
mpd-217d88f21f11236478dd41c37b67bef5b0a06497.tar.xz
mpd-217d88f21f11236478dd41c37b67bef5b0a06497.zip
TextInputStream: don't ignore unterminated last line
-rw-r--r--NEWS1
-rw-r--r--src/input/TextInputStream.cxx20
2 files changed, 17 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 6b2282a20..5541db7f2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
ver 0.19.2 (not yet released)
* playlist
+ - m3u: don't ignore unterminated last line
- m3u: recognize the file suffix ".m3u8"
* decoder
- faad: remove workaround for ancient libfaad2 ABI bug
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;
+ }
}
}