Changeset 2278 for code/branches/buildsystem/src/core/Script.cc
- Timestamp:
- Nov 26, 2008, 5:35:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem/src/core/Script.cc
r2239 r2278 134 134 } 135 135 136 unsigned int Script::getNextQuote(const std::string& text, unsigned int start)137 {138 unsigned int quote = start - 1;139 140 while ((quote = text.find('\"', quote + 1)) != std::string::npos)141 {142 unsigned int backslash = quote;143 unsigned int numbackslashes = 0;144 for (; backslash > 0; backslash--, numbackslashes++)145 if (text[backslash - 1] != '\\')146 break;147 148 if (numbackslashes % 2 == 0)149 break;150 }151 152 return quote;153 }154 155 136 std::string Script::replaceLuaTags(const std::string& text) 156 137 { 157 138 // chreate map with all Lua tags 158 std::map< unsigned int, bool> luaTags;159 { 160 unsigned int pos = 0;139 std::map<size_t, bool> luaTags; 140 { 141 size_t pos = 0; 161 142 while ((pos = text.find("<?lua", pos)) != std::string::npos) 162 143 luaTags[pos++] = true; 163 144 } 164 145 { 165 unsigned int pos = 0;146 size_t pos = 0; 166 147 while ((pos = text.find("?>", pos)) != std::string::npos) 167 148 luaTags[pos++] = false; … … 170 151 // erase all tags from the map that are between two quotes 171 152 { 172 std::map< unsigned int, bool>::iterator it = luaTags.begin();173 std::map< unsigned int, bool>::iterator it2 = it;153 std::map<size_t, bool>::iterator it = luaTags.begin(); 154 std::map<size_t, bool>::iterator it2 = it; 174 155 bool bBetweenQuotes = false; 175 unsigned int pos = 0;156 size_t pos = 0; 176 157 while ((pos = getNextQuote(text, pos)) != std::string::npos) 177 158 { … … 196 177 { 197 178 bool expectedValue = true; 198 for (std::map< unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)179 for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it) 199 180 { 200 181 if (it->second == expectedValue) … … 215 196 std::string output; 216 197 { 217 std::map< unsigned int, bool>::iterator it = luaTags.begin();198 std::map<size_t, bool>::iterator it = luaTags.begin(); 218 199 bool bInPrintFunction = true; 219 unsigned int start = 0;220 unsigned int end = 0;200 size_t start = 0; 201 size_t end = 0; 221 202 222 203 do … … 234 215 std::string temp = text.substr(start, end - start); 235 216 { 236 unsigned int pos = 0;217 size_t pos = 0; 237 218 while ((pos = temp.find('[', pos)) != std::string::npos) 238 219 { 239 220 unsigned int tempCounter = 1; 240 unsigned int tempPos = pos++;221 size_t tempPos = pos++; 241 222 while(temp[++tempPos] == '=') { 242 223 tempCounter++; … … 253 234 } 254 235 { 255 unsigned int pos = 0;236 size_t pos = 0; 256 237 while ((pos = temp.find(']', pos)) != std::string::npos) 257 238 { 258 239 unsigned int tempCounter = 1; 259 unsigned int tempPos = pos++;240 size_t tempPos = pos++; 260 241 while(temp[++tempPos] == '=') { 261 242 tempCounter++;
Note: See TracChangeset
for help on using the changeset viewer.