diff options
author | elektrahesse | 2010-09-09 19:33:36 +0200 |
---|---|---|
committer | elektrahesse | 2010-09-09 19:33:36 +0200 |
commit | 6c56f4fcb206c1494e4f7cbd6d42fcac3cd8394e (patch) | |
tree | 05b68e8865c1d495bfd83d6af60552401ca5742e | |
parent | Fixed chat colors and added group im colors (diff) | |
download | meta-impy-6c56f4fcb206c1494e4f7cbd6d42fcac3cd8394e.zip meta-impy-6c56f4fcb206c1494e4f7cbd6d42fcac3cd8394e.tar.gz meta-impy-6c56f4fcb206c1494e4f7cbd6d42fcac3cd8394e.tar.bz2 meta-impy-6c56f4fcb206c1494e4f7cbd6d42fcac3cd8394e.tar.xz |
Switched to boost::regex and wrote a regex supporting punctuation for name matching in both chat and group ims
-rw-r--r-- | linden/indra/newview/llfloaterchat.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index d7465fa..4be20b5 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp | |||
@@ -78,7 +78,7 @@ | |||
78 | #include "llstylemap.h" | 78 | #include "llstylemap.h" |
79 | #include "llviewermenu.h" | 79 | #include "llviewermenu.h" |
80 | 80 | ||
81 | #include "regex.h" | 81 | #include "boost/regex.hpp" |
82 | 82 | ||
83 | // Used for LCD display | 83 | // Used for LCD display |
84 | extern void AddNewIMToLCD(const std::string &newLine); | 84 | extern void AddNewIMToLCD(const std::string &newLine); |
@@ -456,7 +456,12 @@ void LLFloaterChat::updateSettings() | |||
456 | BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) | 456 | BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) |
457 | { | 457 | { |
458 | std::string my_name = gSavedSettings.getString("FirstName"); | 458 | std::string my_name = gSavedSettings.getString("FirstName"); |
459 | std::string pattern_s = "(^|.*[\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([,\\.\\?!:;\\*\\)\\s]+.*|$)"; | ||
460 | boost::smatch what; | ||
461 | boost::regex e1(pattern_s, boost::regex::icase); | ||
462 | return boost::regex_search(text_line, what, e1); | ||
459 | 463 | ||
464 | /* | ||
460 | std::transform(my_name.begin(), my_name.end(), my_name.begin(), tolower); | 465 | std::transform(my_name.begin(), my_name.end(), my_name.begin(), tolower); |
461 | 466 | ||
462 | std::string lower_chat = std::string(text_line); | 467 | std::string lower_chat = std::string(text_line); |
@@ -473,6 +478,9 @@ BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) | |||
473 | return TRUE; | 478 | return TRUE; |
474 | } | 479 | } |
475 | 480 | ||
481 | return FALSE; | ||
482 | */ | ||
483 | |||
476 | /* | 484 | /* |
477 | regex_t compiled; | 485 | regex_t compiled; |
478 | // ^.*([\.\?!:;\*\(\s]+)(elektra)([,\.\?!:;\*\)\s$]+).* <--- this works :) | 486 | // ^.*([\.\?!:;\*\(\s]+)(elektra)([,\.\?!:;\*\)\s$]+).* <--- this works :) |
@@ -483,8 +491,9 @@ BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) | |||
483 | 491 | ||
484 | if (regexec(&compiled, text_line.c_str(), 0, NULL, 0) == 0) | 492 | if (regexec(&compiled, text_line.c_str(), 0, NULL, 0) == 0) |
485 | return TRUE; | 493 | return TRUE; |
486 | */ | 494 | |
487 | return FALSE; | 495 | return FALSE; |
496 | */ | ||
488 | } | 497 | } |
489 | 498 | ||
490 | LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor) | 499 | LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor) |