diff options
-rw-r--r-- | engines/parallaction/parser.cpp | 23 | ||||
-rw-r--r-- | engines/parallaction/parser.h | 5 |
2 files changed, 18 insertions, 10 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index a475f5701a..c15d1111d3 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -42,23 +42,28 @@ Script::~Script() { char *Script::readLine(char *buf, size_t bufSize) { - uint16 _si; - char v2 = 0; - for ( _si = 0; _si<bufSize; _si++) { + uint16 i; + for (i = 0; i < bufSize; i++) { - v2 = _input->readSByte(); + char c = _input->readSByte(); - if (v2 == 0xA || v2 == 0xD || _input->eos()) break; - if (!_input->eos() && _si < bufSize) buf[_si] = v2; + if (_input->eos()) + break; + + if (c == 0xA || c == 0xD) + break; + + if (i < bufSize) + buf[i] = c; } _line++; - if (_si == 0 && _input->eos()) + if (i == 0 && _input->eos()) return 0; - buf[_si] = 0xA; - buf[_si+1] = '\0'; + buf[i] = 0xA; + buf[i+1] = '\0'; return buf; diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index f0cc448518..f184dcbc58 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -433,6 +433,7 @@ class ReadStringStream : public Common::ReadStream { char *_text; uint32 _pos; uint32 _size; + bool _eos; public: ReadStringStream(const Common::String &text) { @@ -440,6 +441,7 @@ public: strcpy(_text, text.c_str()); _size = text.size(); _pos = 0; + _eos = false; } ~ReadStringStream() { @@ -449,6 +451,7 @@ public: uint32 read(void *buffer, uint32 size) { if (_pos + size > _size) { size = _size - _pos; + _eos = true; } memcpy(buffer, _text + _pos, size); _pos += size; @@ -456,7 +459,7 @@ public: } bool eos() const { - return _pos == _size; // FIXME (eos definition change) + return _eos; } }; |