diff options
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index e56002f..90199f1 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -4260,35 +4260,55 @@ S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse) | |||
4260 | std::string openers=" \t\n('\"[{<>"; | 4260 | std::string openers=" \t\n('\"[{<>"; |
4261 | std::string closers=" \t\n)'\"]}><;"; | 4261 | std::string closers=" \t\n)'\"]}><;"; |
4262 | 4262 | ||
4263 | S32 m2 = 0; | 4263 | S32 index = 0; |
4264 | S32 retval = 0; | ||
4265 | 4264 | ||
4266 | if (reverse) | 4265 | if (reverse) |
4267 | { | 4266 | { |
4268 | 4267 | for (index=pos; index >= 0; index--) | |
4269 | for (retval=pos; retval >= 0; retval--) | ||
4270 | { | 4268 | { |
4271 | m2 = openers.find(line.substr(retval,1)); | 4269 | char c = line[index]; |
4270 | S32 m2 = openers.find(c); | ||
4272 | if (m2 >= 0) | 4271 | if (m2 >= 0) |
4273 | { | 4272 | { |
4274 | break; | 4273 | return index+1; |
4275 | } | 4274 | } |
4276 | } | 4275 | } |
4277 | return retval+1; | ||
4278 | } | 4276 | } |
4279 | else | 4277 | else |
4280 | { | 4278 | { |
4281 | 4279 | // adjust the search slightly, to allow matching parenthesis inside the URL | |
4282 | for (retval=pos; retval<(S32)line.length(); retval++) | 4280 | S32 paren_count = 0; |
4281 | for (index=pos; index<(S32)line.length(); index++) | ||
4283 | { | 4282 | { |
4284 | m2 = closers.find(line.substr(retval,1)); | 4283 | char c = line[index]; |
4285 | if (m2 >= 0) | 4284 | |
4285 | if (c == '(') | ||
4286 | { | 4286 | { |
4287 | break; | 4287 | paren_count++; |
4288 | } | ||
4289 | else if (c == ')') | ||
4290 | { | ||
4291 | if (paren_count <= 0) | ||
4292 | { | ||
4293 | return index; | ||
4294 | } | ||
4295 | else | ||
4296 | { | ||
4297 | paren_count--; | ||
4298 | } | ||
4299 | } | ||
4300 | else | ||
4301 | { | ||
4302 | S32 m2 = closers.find(c); | ||
4303 | if (m2 >= 0) | ||
4304 | { | ||
4305 | return index; | ||
4306 | } | ||
4288 | } | 4307 | } |
4289 | } | 4308 | } |
4290 | return retval; | 4309 | } |
4291 | } | 4310 | |
4311 | return index; | ||
4292 | } | 4312 | } |
4293 | 4313 | ||
4294 | BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const | 4314 | BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const |