diff options
Diffstat (limited to 'common/xmlparser.cpp')
-rw-r--r-- | common/xmlparser.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index 67a3d36cec..4470180710 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -97,35 +97,37 @@ bool XMLParser::parserError(const String &errStr) { assert(_stream->pos() == startPosition); currentPosition = startPosition; - int keyOpening = 0; - int keyClosing = 0; + Common::String errorMessage = Common::String::format("\n File <%s>, line %d:\n", _fileName.c_str(), lineCount); - while (currentPosition-- && keyOpening == 0) { - _stream->seek(-2, SEEK_CUR); - c = _stream->readByte(); + if (startPosition > 1) { + int keyOpening = 0; + int keyClosing = 0; - if (c == '<') - keyOpening = currentPosition - 1; - else if (c == '>') - keyClosing = currentPosition; - } + while (currentPosition-- && keyOpening == 0) { + _stream->seek(-2, SEEK_CUR); + c = _stream->readByte(); - _stream->seek(startPosition, SEEK_SET); - currentPosition = startPosition; - while (keyClosing == 0 && c && currentPosition++) { - c = _stream->readByte(); + if (c == '<') + keyOpening = currentPosition - 1; + else if (c == '>') + keyClosing = currentPosition; + } - if (c == '>') - keyClosing = currentPosition; - } + _stream->seek(startPosition, SEEK_SET); + currentPosition = startPosition; + while (keyClosing == 0 && c && currentPosition++) { + c = _stream->readByte(); - Common::String errorMessage = Common::String::format("\n File <%s>, line %d:\n", _fileName.c_str(), lineCount); + if (c == '>') + keyClosing = currentPosition; + } - currentPosition = (keyClosing - keyOpening); - _stream->seek(keyOpening, SEEK_SET); + currentPosition = (keyClosing - keyOpening); + _stream->seek(keyOpening, SEEK_SET); - while (currentPosition--) - errorMessage += (char)_stream->readByte(); + while (currentPosition--) + errorMessage += (char)_stream->readByte(); + } errorMessage += "\n\nParser error: "; errorMessage += errStr; |