From 428438cf898fba2100f6859ca791c108f4b8d72a Mon Sep 17 00:00:00 2001 From: Antidote Date: Fri, 10 Jan 2014 13:13:06 -0800 Subject: [PATCH] * Changed zelda::utility::countChar to use a pointer to lastOccur rather than a reference --- include/utility.hpp | 2 +- src/utility.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/utility.hpp b/include/utility.hpp index 1e38cba..5d29d5e 100644 --- a/include/utility.hpp +++ b/include/utility.hpp @@ -47,7 +47,7 @@ void toupper(std::string& str); std::string sprintf(const char* fmt, ...); bool parseBool(const std::string& boolean, bool &valid); -int countChar(const std::string& str, const char chr, int& lastOccur); +int countChar(const std::string& str, const char chr, int* lastOccur = NULL); } // utility } // zelda diff --git a/src/utility.cpp b/src/utility.cpp index d0d3362..58135b7 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -171,11 +171,11 @@ bool parseBool(const std::string& boolean, bool &valid) std::transform(val.begin(), val.end(), val.begin(), ::tolower); // Check for true first - if (!val.compare("true") || !val.compare("1") || !val.compare("yes")) + if (!val.compare("true") || !val.compare("1") || !val.compare("yes") || !val.compare("on")) return (valid = true); // Now false - if (!val.compare("false") || !val.compare("0") || !val.compare("no")) + if (!val.compare("false") || !val.compare("0") || !val.compare("no") || !val.compare("off")) { valid = true; return false; @@ -186,7 +186,7 @@ bool parseBool(const std::string& boolean, bool &valid) return (valid = false); } -int countChar(const std::string &str, const char chr, int &lastOccur) +int countChar(const std::string& str, const char chr, int* lastOccur) { int ret = 0; @@ -195,7 +195,9 @@ int countChar(const std::string &str, const char chr, int &lastOccur) { if (c == chr) { - lastOccur = index; + if (lastOccur != NULL) + *lastOccur = index; + ret++; } index++;