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

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
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,
Mark Mentovai 2011/11/09 20:31:32 This is really easy to write a test for, but you h
Alexei Svitkine (slow) 2011/11/09 21:03:58 Done.
+ 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>

Powered by Google App Engine
This is Rietveld 408576698