fixed bug that global tokens were not parsed correctly

This commit is contained in:
louis 2015-01-27 17:36:29 +01:00
parent 15ad84bccf
commit 17497de3c3
2 changed files with 23 additions and 16 deletions

View File

@ -190,3 +190,4 @@ Version 0.2.0
Version 0.2.1 Version 0.2.1
- fixed bug that global tokens were not parsed correctly

View File

@ -73,12 +73,15 @@ void cGlobals::ReplaceIntVars(string &value) {
stringstream sToken; stringstream sToken;
sToken << "{" << it->first << "}"; sToken << "{" << it->first << "}";
string token = sToken.str(); string token = sToken.str();
size_t foundToken = value.find(token); size_t foundToken = string::npos;
do {
foundToken = value.find(token);
if (foundToken != string::npos) { if (foundToken != string::npos) {
stringstream st; stringstream st;
st << it->second; st << it->second;
value = value.replace(foundToken, token.size(), st.str()); value = value.replace(foundToken, token.size(), st.str());
} }
} while (foundToken != string::npos);
} }
} }
@ -107,7 +110,9 @@ void cGlobals::ReplaceDoubleVars(string &value) {
stringstream sToken; stringstream sToken;
sToken << "{" << it->first << "}"; sToken << "{" << it->first << "}";
string token = sToken.str(); string token = sToken.str();
size_t foundToken = value.find(token); size_t foundToken = string::npos;
do {
foundToken = value.find(token);
if (foundToken != string::npos) { if (foundToken != string::npos) {
stringstream st; stringstream st;
st << it->second; st << it->second;
@ -119,6 +124,7 @@ void cGlobals::ReplaceDoubleVars(string &value) {
} }
value = value.replace(foundToken, token.size(), doubleVal); value = value.replace(foundToken, token.size(), doubleVal);
} }
} while (foundToken != string::npos);
} }
} }