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