COMMON: readLine_NEW fails to read last line in file
|Reported by:||salty-horse||Owned by:||wjp|
Using latest svn r34343.
If the last "line" in a file doesn't end with a newline, readLine_NEW will return 0 instead of the real data.
In my case, I am opening a file with Common::File::open() and calling readLine_NEW on it.
Suppose the last characters of the file are 'a', 'b' followed by EOF.
readLine_NEW will execute "c = readByte();" in common/stream.cpp:166 twice.
After the third time, c will be '\0'.
It then gets to the check:
if (ioFailed() || (len == 0 && eos()))
ioFailed() returns True and then 0 is returned, even if len > 0.
Maybe the real problem is ioFailed returning 'true' when nothing is actually failing.
It's set when readByte() calls File::read(&b, 1).
AFAIK, this doesn't actually cause any errors in existing engines. I've encountered it in my KoM engine.
Ticket imported from: #2095303. Ticket imported from: bugs/3944.