summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstring.h
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-08-29 06:23:41 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-08-29 06:23:41 +0000
commita1ed9ccf7330354d5df5083b44643f2a7e56b748 (patch)
tree75caa29925495a74548111da1800d67126343d13 /indra/llcommon/llstring.h
parentc4384d64a11fe96764f240a9e220989ad5546f16 (diff)
Partial merge of: viewer-2.0.0-3@131138 texture-pipeline-3@131862 -> viewer-2.0.0-3
Includes: * DEV-31909 VWR-13251: Revise lscript_library.cpp to allow localization of LSL editor hovertips * DEV-21938 llSHA1String does not appear where expected in the dropdown "Insert" menu in the LSL editor * Some cleanup to llerror so that it doesn't depend on llfixedbuffer * A few misc. server specific changes not related to the texture-pipeline changes (llapp, lloptioninterface)
Diffstat (limited to 'indra/llcommon/llstring.h')
-rw-r--r--indra/llcommon/llstring.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index a15d6a9a14..c6dcdd6d12 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -281,7 +281,8 @@ public:
static void replaceTabsWithSpaces( std::basic_string<T>& string, size_type spaces_per_tab );
static void replaceNonstandardASCII( std::basic_string<T>& string, T replacement );
static void replaceChar( std::basic_string<T>& string, T target, T replacement );
-
+ static void replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement );
+
static BOOL containsNonprintable(const std::basic_string<T>& string);
static void stripNonprintable(std::basic_string<T>& string);
@@ -1189,11 +1190,22 @@ template<class T>
void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement )
{
size_type found_pos = 0;
- for (found_pos = string.find(target, found_pos);
- found_pos != std::basic_string<T>::npos;
- found_pos = string.find(target, found_pos))
+ while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos )
{
string[found_pos] = replacement;
+ found_pos++; // avoid infinite defeat if target == replacement
+ }
+}
+
+//static
+template<class T>
+void LLStringUtilBase<T>::replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement )
+{
+ size_type found_pos = 0;
+ while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos )
+ {
+ string.replace( found_pos, target.length(), replacement );
+ found_pos += replacement.length(); // avoid infinite defeat if replacement contains target
}
}