From ba07d1dd0a2babc27e50ff9b8ea3b77943bd9f09 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 4 Sep 2008 21:40:32 +0000 Subject: Use readLine() instead of readLine_OLD(). svn-id: r34336 --- engines/sword2/startup.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/engines/sword2/startup.cpp b/engines/sword2/startup.cpp index 2d19ed6bf9..09bf65bf75 100644 --- a/engines/sword2/startup.cpp +++ b/engines/sword2/startup.cpp @@ -64,19 +64,23 @@ bool Sword2Engine::initStartMenu() { // extract the filenames int start_ids[MAX_starts]; - char buf[10]; - int lineno = 0; - while (fp.readLine_OLD(buf, sizeof(buf))) { + while (!fp.eos() && !fp.ioFailed()) { + Common::String line = fp.readLine(); + + // Skip empty lines or, more likely, the end of the stream. + if (line.size() == 0) + continue; + char *errptr; int id; lineno++; - id = strtol(buf, &errptr, 10); + id = strtol(line.c_str(), &errptr, 10); if (*errptr) { - warning("startup.inf:%d: Invalid string '%s'", lineno, buf); + warning("startup.inf:%d: Invalid string '%s'", lineno, line.c_str()); continue; } @@ -98,6 +102,10 @@ bool Sword2Engine::initStartMenu() { } } + // An I/O error before EOS? That's bad, but this is not a vital file. + if (fp.ioFailed() && !fp.eos()) + warning("I/O error while reading startup.inf"); + fp.close(); // Using this method the Gode generated resource.inf must have #0d0a -- cgit v1.2.3