X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fhashcomp.h;h=87b2636fca0f1d96a07aa27ba95c3b7cac302106;hb=20e2743926aafeae8104a0706806d36149574e8a;hp=c99b5d64613b3364ab754e1689bbe6e1cd1fd451;hpb=6fe1f4e1136f2ab95a88e68af1894bf6002d03f4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/hashcomp.h b/include/hashcomp.h index c99b5d646..87b2636fc 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -72,25 +72,25 @@ CoreExport extern unsigned const char rfc_case_sensitive_map[256]; template const T& SearchAndReplace(T& text, const T& pattern, const T& replace) { - T replacement; - if ((!pattern.empty()) && (!text.empty())) - { - for (std::string::size_type n = 0; n != text.length(); ++n) - { - if (text.length() >= pattern.length() && text.substr(n, pattern.length()) == pattern) - { - /* Found the pattern in the text, replace it, and advance */ - replacement.append(replace); - n = n + pattern.length() - 1; - } - else - { - replacement += text[n]; - } - } - } - text = replacement; - return text; + T replacement; + if ((!pattern.empty()) && (!text.empty())) + { + for (std::string::size_type n = 0; n != text.length(); ++n) + { + if (text.length() >= pattern.length() && text.substr(n, pattern.length()) == pattern) + { + // Found the pattern in the text, replace it, and advance + replacement.append(replace); + n = n + pattern.length() - 1; + } + else + { + replacement += text[n]; + } + } + } + text = replacement; + return text; } /** The irc namespace contains a number of helper classes.