From 4b1df64fba0ec3a79c2773b231f014035f2f3c82 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 22 Sep 2014 16:28:17 +0200 Subject: [PATCH] Book parser: Fix comparison between signed and unsigned integer expressions --- apps/openmw/mwgui/formatting.cpp | 18 +++++++----------- apps/openmw/mwgui/formatting.hpp | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index c8b6f39833..f7188c8b60 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -21,7 +21,7 @@ namespace MWGui { /* BookTextParser */ BookTextParser::BookTextParser(const std::string & text) - : mIndex(-1), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) + : mIndex(0), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) { MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor mText = Interpreter::fixDefinesBook(mText, interpreterContext); @@ -47,16 +47,8 @@ namespace MWGui BookTextParser::Events BookTextParser::next() { - while (1) + while (mIndex < mText.size()) { - ++mIndex; - - if (mIndex >= mText.size()) - { - flushBuffer(); - return Event_EOF; - } - char ch = mText[mIndex]; if (ch == '<') { @@ -93,6 +85,7 @@ namespace MWGui mIgnoreNewlineTags = false; } + ++mIndex; return type; } } @@ -106,8 +99,11 @@ namespace MWGui } } - + ++mIndex; } + + flushBuffer(); + return Event_EOF; } void BookTextParser::flushBuffer() diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 71e398f7f4..f119422c9c 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -49,7 +49,7 @@ namespace MWGui void parseTag(std::string tag); private: - int mIndex; + size_t mIndex; std::string mText; std::string mReadyText;