Changeset 1889 for code/trunk/src/core/Script.cc
- Timestamp:
- Oct 6, 2008, 1:05:07 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/Script.cc
r1810 r1889 33 33 34 34 #include "CoreIncludes.h" 35 36 #include "util/String.h" 35 37 36 38 #include "lua/lua.hpp" … … 131 133 } 132 134 133 unsigned int Script::getNextQuote(const std::string& text, unsigned int start)134 {135 unsigned int quote = start - 1;136 137 while ((quote = text.find('\"', quote + 1)) != std::string::npos)138 {139 unsigned int backslash = quote;140 unsigned int numbackslashes = 0;141 for (; backslash > 0; backslash--, numbackslashes++)142 if (text[backslash - 1] != '\\')143 break;144 145 if (numbackslashes % 2 == 0)146 break;147 }148 149 return quote;150 }151 152 135 std::string Script::replaceLuaTags(const std::string& text) 153 136 { 154 137 // chreate map with all Lua tags 155 std::map< unsigned int, bool> luaTags;156 { 157 unsigned int pos = 0;138 std::map<size_t, bool> luaTags; 139 { 140 size_t pos = 0; 158 141 while ((pos = text.find("<?lua", pos)) != std::string::npos) 159 142 luaTags[pos++] = true; 160 143 } 161 144 { 162 unsigned int pos = 0;145 size_t pos = 0; 163 146 while ((pos = text.find("?>", pos)) != std::string::npos) 164 147 luaTags[pos++] = false; … … 167 150 // erase all tags from the map that are between two quotes 168 151 { 169 std::map< unsigned int, bool>::iterator it = luaTags.begin();170 std::map< unsigned int, bool>::iterator it2 = it;152 std::map<size_t, bool>::iterator it = luaTags.begin(); 153 std::map<size_t, bool>::iterator it2 = it; 171 154 bool bBetweenQuotes = false; 172 unsigned int pos = 0;155 size_t pos = 0; 173 156 while ((pos = getNextQuote(text, pos)) != std::string::npos) 174 157 { … … 193 176 { 194 177 bool expectedValue = true; 195 for (std::map< unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)178 for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it) 196 179 { 197 180 if (it->second == expectedValue) … … 212 195 std::string output; 213 196 { 214 std::map< unsigned int, bool>::iterator it = luaTags.begin();197 std::map<size_t, bool>::iterator it = luaTags.begin(); 215 198 bool bInPrintFunction = true; 216 unsigned int start = 0;217 unsigned int end = 0;199 size_t start = 0; 200 size_t end = 0; 218 201 219 202 do … … 231 214 std::string temp = text.substr(start, end - start); 232 215 { 233 unsigned int pos = 0;216 size_t pos = 0; 234 217 while ((pos = temp.find('[', pos)) != std::string::npos) 235 218 { 236 219 unsigned int tempCounter = 1; 237 unsigned int tempPos = pos++;220 size_t tempPos = pos++; 238 221 while(temp[++tempPos] == '=') { 239 222 tempCounter++; … … 250 233 } 251 234 { 252 unsigned int pos = 0;235 size_t pos = 0; 253 236 while ((pos = temp.find(']', pos)) != std::string::npos) 254 237 { 255 238 unsigned int tempCounter = 1; 256 unsigned int tempPos = pos++;239 size_t tempPos = pos++; 257 240 while(temp[++tempPos] == '=') { 258 241 tempCounter++;
Note: See TracChangeset
for help on using the changeset viewer.