TextInputStream: don't ignore unterminated last line
This commit is contained in:
parent
394e3be482
commit
217d88f21f
1
NEWS
1
NEWS
|
@ -1,5 +1,6 @@
|
||||||
ver 0.19.2 (not yet released)
|
ver 0.19.2 (not yet released)
|
||||||
* playlist
|
* playlist
|
||||||
|
- m3u: don't ignore unterminated last line
|
||||||
- m3u: recognize the file suffix ".m3u8"
|
- m3u: recognize the file suffix ".m3u8"
|
||||||
* decoder
|
* decoder
|
||||||
- faad: remove workaround for ancient libfaad2 ABI bug
|
- faad: remove workaround for ancient libfaad2 ABI bug
|
||||||
|
|
|
@ -38,8 +38,8 @@ TextInputStream::ReadLine()
|
||||||
while (true) {
|
while (true) {
|
||||||
auto dest = buffer.Write();
|
auto dest = buffer.Write();
|
||||||
if (dest.size < 2) {
|
if (dest.size < 2) {
|
||||||
/* end of file (or line too long): terminate
|
/* line too long: terminate the current
|
||||||
the current line */
|
line */
|
||||||
|
|
||||||
assert(!dest.IsEmpty());
|
assert(!dest.IsEmpty());
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
|
@ -66,7 +66,19 @@ TextInputStream::ReadLine()
|
||||||
if (line != nullptr)
|
if (line != nullptr)
|
||||||
return line;
|
return line;
|
||||||
|
|
||||||
if (nbytes == 0)
|
if (nbytes == 0) {
|
||||||
return nullptr;
|
/* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue