From eb8afa5d35a6646150ab091f5cc8d22cb217a26d Mon Sep 17 00:00:00 2001 From: Miroslav Puda Date: Sat, 18 May 2013 21:38:09 +0200 Subject: [PATCH 1/4] Ignoring Eclipse project files. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 27d3a13de..b757c53f1 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ CMakeLists.txt.user *.swp *.swo *.kate-swp +.cproject +.project +.settings/ From d5689730eb2f4aee600367947246a4d245d664f0 Mon Sep 17 00:00:00 2001 From: Miroslav Puda Date: Sat, 18 May 2013 22:57:27 +0200 Subject: [PATCH 2/4] Removal of unnecessary variable. empty variable duplicates empty() method of std::string. Check for empty value should be replaced by assert since it does not makes much sense to call scanInt with null character. --- components/compiler/scanner.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index 38e0c353d..d5095a50a 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -164,9 +164,7 @@ namespace Compiler bool Scanner::scanInt (char c, Parser& parser, bool& cont) { std::string value; - value += c; - bool empty = false; bool error = false; @@ -175,7 +173,6 @@ namespace Compiler if (std::isdigit (c)) { value += c; - empty = false; } else if (std::isalpha (c) || c=='_') error = true; @@ -190,7 +187,11 @@ namespace Compiler } } - if (empty || error) + /* + * value could be empty only if scanInt is called with c == '\0'. + * That is unlikely so it should be replaced by assertion. + */ + if (value.empty() || error) return false; TokenLoc loc (mLoc); From 3cebb41459f84bb0f7f221909dd95191f969eb31 Mon Sep 17 00:00:00 2001 From: Miroslav Puda Date: Tue, 21 May 2013 21:04:15 +0200 Subject: [PATCH 3/4] missing break --- apps/openmw/mwscript/scriptmanagerimp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index b3e5f8ff6..14fe5b7fd 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -209,6 +209,7 @@ namespace MWScript offset = script->mData.mNumShorts+script->mData.mNumLongs; size = script->mData.mNumFloats; + break; default: From 7149439ace598415039f11e57f97b18e51178758 Mon Sep 17 00:00:00 2001 From: Miroslav Puda Date: Wed, 22 May 2013 13:23:49 +0200 Subject: [PATCH 4/4] Replacement of empty() method by assertion. --- components/compiler/scanner.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index d5095a50a..b45015d1e 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -1,6 +1,7 @@ #include "scanner.hpp" +#include #include #include #include @@ -163,6 +164,7 @@ namespace Compiler bool Scanner::scanInt (char c, Parser& parser, bool& cont) { + assert(c != '\0'); std::string value; value += c; @@ -187,11 +189,7 @@ namespace Compiler } } - /* - * value could be empty only if scanInt is called with c == '\0'. - * That is unlikely so it should be replaced by assertion. - */ - if (value.empty() || error) + if (error) return false; TokenLoc loc (mLoc);