Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1791)

Unified Diff: base/string_util.cc

Issue 8502027: Fix AutocompleteMatch DCHECK() triggered by |RenderViewContextMenu::AppendSearchProvider()|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/string_util.h ('k') | base/string_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util.cc
===================================================================
--- base/string_util.cc (revision 108864)
+++ base/string_util.cc (working copy)
@@ -165,34 +165,49 @@
const char kUtf8ByteOrderMark[] = "\xEF\xBB\xBF";
template<typename STR>
-bool RemoveCharsT(const STR& input,
- const typename STR::value_type remove_chars[],
- STR* output) {
+bool ReplaceCharsT(const STR& input,
+ const typename STR::value_type replace_chars[],
+ const STR& replace_with,
+ STR* output) {
bool removed = false;
size_t found;
*output = input;
- found = output->find_first_of(remove_chars);
+ found = output->find_first_of(replace_chars);
while (found != STR::npos) {
removed = true;
- output->replace(found, 1, STR());
- found = output->find_first_of(remove_chars, found);
+ output->replace(found, 1, replace_with);
+ found = output->find_first_of(replace_chars, found);
}
return removed;
}
+bool ReplaceChars(const string16& input,
+ const char16 replace_chars[],
+ const string16& replace_with,
+ string16* output) {
+ return ReplaceCharsT(input, replace_chars, replace_with, output);
+}
+
+bool ReplaceChars(const std::string& input,
+ const char replace_chars[],
+ const std::string& replace_with,
+ std::string* output) {
+ return ReplaceCharsT(input, replace_chars, replace_with, output);
+}
+
bool RemoveChars(const string16& input,
const char16 remove_chars[],
string16* output) {
- return RemoveCharsT(input, remove_chars, output);
+ return ReplaceChars(input, remove_chars, string16(), output);
}
bool RemoveChars(const std::string& input,
const char remove_chars[],
std::string* output) {
- return RemoveCharsT(input, remove_chars, output);
+ return ReplaceChars(input, remove_chars, std::string(), output);
}
template<typename STR>
« no previous file with comments | « base/string_util.h ('k') | base/string_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698