diff options
author | brettw <brettw@chromium.org> | 2015-06-23 17:39:02 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-24 00:39:38 +0000 |
commit | b3413064f36bf166d7dffb463bc442059dab1dd7 (patch) | |
tree | 391826aaaccf59398a8d59437482ce9dd62da48f | |
parent | 737f36b52ce9137b242b8259b8f440c61e6b60ba (diff) | |
download | chromium_src-b3413064f36bf166d7dffb463bc442059dab1dd7.zip chromium_src-b3413064f36bf166d7dffb463bc442059dab1dd7.tar.gz chromium_src-b3413064f36bf166d7dffb463bc442059dab1dd7.tar.bz2 |
Move more string_util functions to base namespace.
Rename IsWhitespace to IsUnicodeWhitespace (to contrast it to the already-existing IsAsciiWhitespace).
De-inline HexDigitToInt. This is only used in a few places and I don't think it's necessary to inline.
Remove some redundant base:: qualifications in base.
TBR=sky
Review URL: https://codereview.chromium.org/1200053004
Cr-Commit-Position: refs/heads/master@{#335827}
75 files changed, 171 insertions, 156 deletions
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc index 4d79be3..60569fd 100644 --- a/base/json/json_parser.cc +++ b/base/json/json_parser.cc @@ -31,7 +31,7 @@ const int32 kExtendedASCIIStart = 0x80; // optimization avoids about 2/3rds of string memory copies. The constructor // takes ownership of the input string. The real root value is Swap()ed into // the new instance. -class DictionaryHiddenRootValue : public base::DictionaryValue { +class DictionaryHiddenRootValue : public DictionaryValue { public: DictionaryHiddenRootValue(std::string* json, Value* root) : json_(json) { DCHECK(root->IsType(Value::TYPE_DICTIONARY)); @@ -43,7 +43,7 @@ class DictionaryHiddenRootValue : public base::DictionaryValue { // First deep copy to convert JSONStringValue to std::string and swap that // copy with |other|, which contains the new contents of |this|. - scoped_ptr<base::DictionaryValue> copy(DeepCopy()); + scoped_ptr<DictionaryValue> copy(DeepCopy()); copy->Swap(other); // Then erase the contents of the current dictionary and swap in the @@ -81,7 +81,7 @@ class DictionaryHiddenRootValue : public base::DictionaryValue { DISALLOW_COPY_AND_ASSIGN(DictionaryHiddenRootValue); }; -class ListHiddenRootValue : public base::ListValue { +class ListHiddenRootValue : public ListValue { public: ListHiddenRootValue(std::string* json, Value* root) : json_(json) { DCHECK(root->IsType(Value::TYPE_LIST)); @@ -93,7 +93,7 @@ class ListHiddenRootValue : public base::ListValue { // First deep copy to convert JSONStringValue to std::string and swap that // copy with |other|, which contains the new contents of |this|. - scoped_ptr<base::ListValue> copy(DeepCopy()); + scoped_ptr<ListValue> copy(DeepCopy()); copy->Swap(other); // Then erase the contents of the current list and swap in the new contents, @@ -130,14 +130,14 @@ class ListHiddenRootValue : public base::ListValue { // A variant on StringValue that uses StringPiece instead of copying the string // into the Value. This can only be stored in a child of hidden root (above), // otherwise the referenced string will not be guaranteed to outlive it. -class JSONStringValue : public base::Value { +class JSONStringValue : public Value { public: - explicit JSONStringValue(const base::StringPiece& piece) + explicit JSONStringValue(const StringPiece& piece) : Value(TYPE_STRING), string_piece_(piece) { } - // Overridden from base::Value: + // Overridden from Value: bool GetAsString(std::string* out_value) const override { string_piece_.CopyToString(out_value); return true; @@ -157,7 +157,7 @@ class JSONStringValue : public base::Value { private: // The location in the original input stream. - base::StringPiece string_piece_; + StringPiece string_piece_; DISALLOW_COPY_AND_ASSIGN(JSONStringValue); }; @@ -872,7 +872,7 @@ Value* JSONParser::ConsumeNumber() { return new FundamentalValue(num_int); double num_double; - if (base::StringToDouble(num_string.as_string(), &num_double) && + if (StringToDouble(num_string.as_string(), &num_double) && std::isfinite(num_double)) { return new FundamentalValue(num_double); } diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc index d2e9ec5..4f3fcac 100644 --- a/base/process/internal_linux.cc +++ b/base/process/internal_linux.cc @@ -25,8 +25,8 @@ const char kProcDir[] = "/proc"; const char kStatFile[] = "stat"; -base::FilePath GetProcPidDir(pid_t pid) { - return base::FilePath(kProcDir).Append(IntToString(pid)); +FilePath GetProcPidDir(pid_t pid) { + return FilePath(kProcDir).Append(IntToString(pid)); } pid_t ProcDirSlotToPid(const char* d_name) { @@ -106,7 +106,7 @@ bool ParseProcStats(const std::string& stats_data, typedef std::map<std::string, std::string> ProcStatMap; void ParseProcStat(const std::string& contents, ProcStatMap* output) { - base::StringPairs key_value_pairs; + StringPairs key_value_pairs; SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); for (size_t i = 0; i < key_value_pairs.size(); ++i) { output->insert(key_value_pairs[i]); diff --git a/base/strings/string_number_conversions.cc b/base/strings/string_number_conversions.cc index 642d24e9..b1b25d2 100644 --- a/base/strings/string_number_conversions.cc +++ b/base/strings/string_number_conversions.cc @@ -131,10 +131,10 @@ template<int BASE, typename CHAR> bool CharToDigit(CHAR c, uint8* digit) { return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit); } -// There is an IsWhitespace for wchars defined in string_util.h, but it is -// locale independent, whereas the functions we are replacing were -// locale-dependent. TBD what is desired, but for the moment let's not introduce -// a change in behaviour. +// There is an IsUnicodeWhitespace for wchars defined in string_util.h, but it +// is locale independent, whereas the functions we are replacing were +// locale-dependent. TBD what is desired, but for the moment let's not +// introduce a change in behaviour. template<typename CHAR> class WhitespaceHelper { }; diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc index 9bbe1cb..5839cf2 100644 --- a/base/strings/string_util.cc +++ b/base/strings/string_util.cc @@ -334,7 +334,7 @@ STR CollapseWhitespaceT(const STR& text, int chars_written = 0; for (typename STR::const_iterator i(text.begin()); i != text.end(); ++i) { - if (IsWhitespace(*i)) { + if (IsUnicodeWhitespace(*i)) { if (!in_whitespace) { // Reduce all whitespace sequences to a single space. in_whitespace = true; @@ -617,7 +617,16 @@ bool EndsWith(const string16& str, CompareCase::SENSITIVE); } -} // namespace base +char HexDigitToInt(wchar_t c) { + DCHECK(IsHexDigit(c)); + if (c >= '0' && c <= '9') + return static_cast<char>(c - '0'); + if (c >= 'A' && c <= 'F') + return static_cast<char>(c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return static_cast<char>(c - 'a' + 10); + return 0; +} static const char* const kByteStringsUnlocalized[] = { " B", @@ -647,9 +656,11 @@ string16 FormatBytesUnlocalized(int64 bytes) { kByteStringsUnlocalized[dimension]); } - return base::ASCIIToUTF16(buf); + return ASCIIToUTF16(buf); } +} // namespace base + // Runs in O(n) time in the length of |str|. template<class StringType> void DoReplaceSubstringsAfterOffset(StringType* str, diff --git a/base/strings/string_util.h b/base/strings/string_util.h index 6f3b766..f372d45 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -377,16 +377,6 @@ BASE_EXPORT bool EndsWith(const string16& str, const string16& search, bool case_sensitive); -} // namespace base - -#if defined(OS_WIN) -#include "base/strings/string_util_win.h" -#elif defined(OS_POSIX) -#include "base/strings/string_util_posix.h" -#else -#error Define string operations appropriately for your platform -#endif - // Determines the type of ASCII character, independent of locale (the C // library versions will change based on locale). template <typename Char> @@ -409,20 +399,15 @@ inline bool IsHexDigit(Char c) { (c >= 'a' && c <= 'f'); } -template <typename Char> -inline char HexDigitToInt(Char c) { - DCHECK(IsHexDigit(c)); - if (c >= '0' && c <= '9') - return static_cast<char>(c - '0'); - if (c >= 'A' && c <= 'F') - return static_cast<char>(c - 'A' + 10); - if (c >= 'a' && c <= 'f') - return static_cast<char>(c - 'a' + 10); - return 0; -} +// Returns the integer corresponding to the given hex character. For example: +// '4' -> 4 +// 'a' -> 10 +// 'B' -> 11 +// Assumes the input is a valid hex character. DCHECKs in debug builds if not. +BASE_EXPORT char HexDigitToInt(wchar_t c); -// Returns true if it's a whitespace character. -inline bool IsWhitespace(wchar_t c) { +// Returns true if it's a Unicode whitespace character. +inline bool IsUnicodeWhitespace(wchar_t c) { return wcschr(base::kWhitespaceWide, c) != NULL; } @@ -430,7 +415,17 @@ inline bool IsWhitespace(wchar_t c) { // appropriate for use in any UI; use of FormatBytes and friends in ui/base is // highly recommended instead. TODO(avi): Figure out how to get callers to use // FormatBytes instead; remove this. -BASE_EXPORT base::string16 FormatBytesUnlocalized(int64 bytes); +BASE_EXPORT string16 FormatBytesUnlocalized(int64 bytes); + +} // namespace base + +#if defined(OS_WIN) +#include "base/strings/string_util_win.h" +#elif defined(OS_POSIX) +#include "base/strings/string_util_posix.h" +#else +#error Define string operations appropriately for your platform +#endif // Starting at |start_offset| (usually 0), replace the first instance of // |find_this| with |replace_with|. diff --git a/base/test/expectations/parser.cc b/base/test/expectations/parser.cc index c7132e5..83c64c6 100644 --- a/base/test/expectations/parser.cc +++ b/base/test/expectations/parser.cc @@ -39,7 +39,7 @@ inline bool Parser::HasNext() { Parser::StateFunc Parser::Start() { // If at the start of a line is whitespace, skip it and arrange to come back // here. - if (IsAsciiWhitespace(*pos_)) + if (base::IsAsciiWhitespace(*pos_)) return SkipWhitespaceAndNewLines(&Parser::Start); // Handle comments at the start of lines. @@ -161,7 +161,7 @@ Parser::StateFunc Parser::End() { Parser::StateFunc Parser::ExtractString(StateFunc success) { const char* start = pos_; - while (!IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) { + while (!base::IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) { ++pos_; if (*pos_ == '#') { return SyntaxError("Unexpected start of comment"); @@ -179,7 +179,7 @@ Parser::StateFunc Parser::SkipWhitespace(Parser::StateFunc next) { } Parser::StateFunc Parser::SkipWhitespaceAndNewLines(Parser::StateFunc next) { - while (IsAsciiWhitespace(*pos_) && HasNext()) { + while (base::IsAsciiWhitespace(*pos_) && HasNext()) { if (*pos_ == '\n') { ++line_number_; } diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index d339124..e64dafdb 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -248,8 +248,8 @@ std::string UnescapeCacheFileName(const std::string& filename) { for (size_t i = 0; i < filename.size(); ++i) { char c = filename[i]; if (c == '%' && i + 2 < filename.length()) { - c = (HexDigitToInt(filename[i + 1]) << 4) + - HexDigitToInt(filename[i + 2]); + c = (base::HexDigitToInt(filename[i + 1]) << 4) + + base::HexDigitToInt(filename[i + 2]); i += 2; } unescaped.push_back(c); diff --git a/chrome/browser/extensions/install_signer.cc b/chrome/browser/extensions/install_signer.cc index 7214343..8ec39e5 100644 --- a/chrome/browser/extensions/install_signer.cc +++ b/chrome/browser/extensions/install_signer.cc @@ -108,7 +108,7 @@ bool ValidateExpireDateFormat(const std::string& input) { if (i == 4 || i == 7) { if (input[i] != '-') return false; - } else if (!IsAsciiDigit(input[i])) { + } else if (!base::IsAsciiDigit(input[i])) { return false; } } diff --git a/chrome/browser/install_verification/win/module_ids.cc b/chrome/browser/install_verification/win/module_ids.cc index e499fdc..109c3c3 100644 --- a/chrome/browser/install_verification/win/module_ids.cc +++ b/chrome/browser/install_verification/win/module_ids.cc @@ -54,7 +54,7 @@ void ParseAdditionalModuleID( for (base::StringPiece::const_iterator it = digest_piece.begin(); it != digest_piece.end(); ++it) { - if (!IsHexDigit(*it)) + if (!base::IsHexDigit(*it)) return; // Second token has invalid characters. } diff --git a/chrome/browser/internal_auth.cc b/chrome/browser/internal_auth.cc index 4286011..c3f44c7 100644 --- a/chrome/browser/internal_auth.cc +++ b/chrome/browser/internal_auth.cc @@ -112,7 +112,7 @@ bool IsVarSane(const std::string& var) { var.size() <= kStringLengthLimit && base::IsStringASCII(var) && var.find_first_not_of(kAllowedChars) == std::string::npos && - !IsAsciiDigit(var[0]); + !base::IsAsciiDigit(var[0]); } bool IsValueSane(const std::string& value) { @@ -448,7 +448,7 @@ bool InternalAuthVerification::VerifyPassport( void InternalAuthVerification::ChangeKey(const std::string& key) { base::AutoLock alk(g_verification_service_lock.Get()); g_verification_service.Get().ChangeKey(key); -}; +} // static int InternalAuthVerification::get_verification_window_ticks() { diff --git a/chrome/browser/profile_resetter/jtl_foundation.cc b/chrome/browser/profile_resetter/jtl_foundation.cc index 0739040..a2a2007 100644 --- a/chrome/browser/profile_resetter/jtl_foundation.cc +++ b/chrome/browser/profile_resetter/jtl_foundation.cc @@ -39,7 +39,7 @@ bool Hasher::IsHash(const std::string& maybe_hash) { return false; for (std::string::const_iterator it = maybe_hash.begin(); it != maybe_hash.end(); ++it) { - if (!IsHexDigit(*it)) + if (!base::IsHexDigit(*it)) return false; } return true; diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 1ab07a6..4e0af29 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -73,8 +73,8 @@ base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) { // Generate profile_id from sanitized basenames. for (size_t i = 0; i < basenames.length(); ++i) { - if (IsAsciiAlpha(basenames[i]) || - IsAsciiDigit(basenames[i]) || + if (base::IsAsciiAlpha(basenames[i]) || + base::IsAsciiDigit(basenames[i]) || basenames[i] == L'.') profile_id += basenames[i]; } diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 5f6160f..207be6a 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -1466,7 +1466,7 @@ bool OmniboxEditModel::CreatedKeywordSearchByInsertingSpaceInMiddle( return false; size_t space_position = caret_position - 1; if (!IsSpaceCharForAcceptingKeyword(new_text[space_position]) || - IsWhitespace(new_text[space_position - 1]) || + base::IsUnicodeWhitespace(new_text[space_position - 1]) || new_text.compare(0, space_position, old_text, 0, space_position) || !new_text.compare(space_position, new_text.length() - space_position, old_text, space_position, diff --git a/chrome/browser/ui/omnibox/omnibox_view.cc b/chrome/browser/ui/omnibox/omnibox_view.cc index 177bb7e..02e3302 100644 --- a/chrome/browser/ui/omnibox/omnibox_view.cc +++ b/chrome/browser/ui/omnibox/omnibox_view.cc @@ -42,7 +42,8 @@ base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) { // TODO(shess): It may also make sense to ignore leading or // trailing whitespace when making this determination. for (size_t i = 0; i < text.size(); ++i) { - if (IsWhitespace(text[i]) && text[i] != '\n' && text[i] != '\r') { + if (base::IsUnicodeWhitespace(text[i]) && + text[i] != '\n' && text[i] != '\r') { const base::string16 collapsed = base::CollapseWhitespace(text, false); // If the user is pasting all-whitespace, paste a single space // rather than nothing, since pasting nothing feels broken. diff --git a/chrome/browser/ui/search/search_ipc_router.cc b/chrome/browser/ui/search/search_ipc_router.cc index 1c06b1c..a1b85543 100644 --- a/chrome/browser/ui/search/search_ipc_router.cc +++ b/chrome/browser/ui/search/search_ipc_router.cc @@ -20,7 +20,7 @@ bool IsProviderValid(const base::string16& provider) { return false; for (base::string16::const_iterator it = provider.begin(); it != provider.end(); ++it) { - if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it)) + if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it)) return false; } return true; diff --git a/chrome/common/favicon/fallback_icon_url_parser.cc b/chrome/common/favicon/fallback_icon_url_parser.cc index f91e39f..2f9467b 100644 --- a/chrome/common/favicon/fallback_icon_url_parser.cc +++ b/chrome/common/favicon/fallback_icon_url_parser.cc @@ -26,9 +26,10 @@ bool IsHexColorString(const std::string& color_str) { const size_t* end = kValidHexColorSizes + arraysize(kValidHexColorSizes); if (std::find(kValidHexColorSizes, end, len) == end) return false; - for (auto ch : color_str) - if (!IsHexDigit(ch)) + for (auto ch : color_str) { + if (!base::IsHexDigit(ch)) return false; + } return true; } diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index ee32b19..79542aff 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc @@ -496,7 +496,7 @@ void AutofillAgent::AcceptDataListSuggestion( base::string16 last_part = parts.back(); // We want to keep just the leading whitespace. for (size_t i = 0; i < last_part.size(); ++i) { - if (!IsWhitespace(last_part[i])) { + if (!base::IsUnicodeWhitespace(last_part[i])) { last_part = last_part.substr(0, i); break; } diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc index ef7c330..d1fc175 100644 --- a/components/autofill/core/browser/validation.cc +++ b/components/autofill/core/browser/validation.cc @@ -88,7 +88,7 @@ bool IsValidCreditCardNumber(const base::string16& text) { for (base::string16::reverse_iterator iter = number.rbegin(); iter != number.rend(); ++iter) { - if (!IsAsciiDigit(*iter)) + if (!base::IsAsciiDigit(*iter)) return false; int digit = *iter - '0'; @@ -111,7 +111,7 @@ bool IsValidCreditCardSecurityCode(const base::string16& text) { for (base::string16::const_iterator iter = text.begin(); iter != text.end(); ++iter) { - if (!IsAsciiDigit(*iter)) + if (!base::IsAsciiDigit(*iter)) return false; } return true; diff --git a/components/autofill/core/common/save_password_progress_logger.cc b/components/autofill/core/common/save_password_progress_logger.cc index 6eb2563..cfa3a58 100644 --- a/components/autofill/core/common/save_password_progress_logger.cc +++ b/components/autofill/core/common/save_password_progress_logger.cc @@ -35,7 +35,8 @@ std::string ScrubURL(const GURL& url) { // Returns true for all characters which we don't want to see in the logged IDs // or names of HTML elements. bool IsUnwantedInElementID(char c) { - return !(c == '_' || c == '-' || IsAsciiAlpha(c) || IsAsciiDigit(c)); + return !(c == '_' || c == '-' || + base::IsAsciiAlpha(c) || base::IsAsciiDigit(c)); } // The UTF-8 version of SavePasswordProgressLogger::ScrubElementID. diff --git a/components/content_settings/core/common/content_settings_pattern_parser.cc b/components/content_settings/core/common/content_settings_pattern_parser.cc index ae7dcc3..cbdd260 100644 --- a/components/content_settings/core/common/content_settings_pattern_parser.cc +++ b/components/content_settings/core/common/content_settings_pattern_parser.cc @@ -152,7 +152,7 @@ void PatternParser::Parse(const std::string& pattern_spec, } else { // Check if the port string represents a valid port. for (size_t i = 0; i < port.size(); ++i) { - if (!IsAsciiDigit(port[i])) { + if (!base::IsAsciiDigit(port[i])) { builder->Invalid(); return; } diff --git a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc index af63866..9474d24 100644 --- a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc +++ b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc @@ -32,7 +32,8 @@ bool VerifyInstanceID(const std::string& str) { // Checks if it is URL-safe base64 encoded. for (auto ch : str) { - if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_' && ch != '-') + if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) && + ch != '_' && ch != '-') return false; } return true; diff --git a/components/omnibox/history_provider.cc b/components/omnibox/history_provider.cc index 0772b1ee..f78ccb3 100644 --- a/components/omnibox/history_provider.cc +++ b/components/omnibox/history_provider.cc @@ -39,7 +39,7 @@ bool HistoryProvider::PreventInlineAutocomplete( const AutocompleteInput& input) { return input.prevent_inline_autocomplete() || (!input.text().empty() && - IsWhitespace(input.text()[input.text().length() - 1])); + base::IsUnicodeWhitespace(input.text()[input.text().length() - 1])); } HistoryProvider::HistoryProvider(AutocompleteProvider::Type type, diff --git a/components/omnibox/scored_history_match.cc b/components/omnibox/scored_history_match.cc index 2914f7d..5f05d34 100644 --- a/components/omnibox/scored_history_match.cc +++ b/components/omnibox/scored_history_match.cc @@ -194,7 +194,7 @@ ScoredHistoryMatch::ScoredHistoryMatch( // For a URL like "http://www.washingtonmutual.com", this means // typing "w" will inline "ashington..." instead of "ww.washington...". if (!url_matches.empty() && (terms_vector.size() == 1) && - !IsWhitespace(*lower_string.rbegin())) { + !base::IsUnicodeWhitespace(*lower_string.rbegin())) { const base::string16 gurl_spec = base::UTF8ToUTF16(gurl.spec()); const URLPrefix* best_inlineable_prefix = URLPrefix::BestURLPrefix(gurl_spec, terms_vector[0]); diff --git a/components/password_manager/core/browser/affiliation_utils.cc b/components/password_manager/core/browser/affiliation_utils.cc index 98c9099..bd4bc5b 100644 --- a/components/password_manager/core/browser/affiliation_utils.cc +++ b/components/password_manager/core/browser/affiliation_utils.cc @@ -43,7 +43,7 @@ base::StringPiece ComponentString(const std::string& uri, bool ContainsOnlyAlphanumericAnd(const base::StringPiece& input, const base::StringPiece& other_characters) { for (char c : input) { - if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) && + if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && other_characters.find(c) == base::StringPiece::npos) return false; } diff --git a/components/password_manager/core/browser/browser_save_password_progress_logger.cc b/components/password_manager/core/browser/browser_save_password_progress_logger.cc index 6e47724..f93ff50 100644 --- a/components/password_manager/core/browser/browser_save_password_progress_logger.cc +++ b/components/password_manager/core/browser/browser_save_password_progress_logger.cc @@ -17,7 +17,7 @@ namespace { // Replaces all non-digits in |str| by spaces. std::string ScrubNonDigit(std::string str) { std::replace_if(str.begin(), str.end(), - [](char c) { return !IsAsciiDigit(c); }, ' '); + [](char c) { return !base::IsAsciiDigit(c); }, ' '); return str; } diff --git a/components/resource_provider/file_utils.cc b/components/resource_provider/file_utils.cc index 3cd3a0a..2e8d97a 100644 --- a/components/resource_provider/file_utils.cc +++ b/components/resource_provider/file_utils.cc @@ -17,7 +17,8 @@ bool IsPathNameValid(const std::string& name) { return false; for (auto c : name) { - if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) && c != '_' && c != '.') + if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && + c != '_' && c != '.') return false; } return true; diff --git a/components/search_engines/template_url_parser.cc b/components/search_engines/template_url_parser.cc index 394512c..51644b1 100644 --- a/components/search_engines/template_url_parser.cc +++ b/components/search_engines/template_url_parser.cc @@ -63,13 +63,13 @@ bool IsValidEncodingString(const std::string& input_encoding) { if (input_encoding.empty()) return false; - if (!IsAsciiAlpha(input_encoding[0])) + if (!base::IsAsciiAlpha(input_encoding[0])) return false; for (size_t i = 1, max = input_encoding.size(); i < max; ++i) { char c = input_encoding[i]; - if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) && c != '.' && c != '_' && - c != '-') { + if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && + c != '.' && c != '_' && c != '-') { return false; } } diff --git a/components/translate/core/language_detection/language_detection_util.cc b/components/translate/core/language_detection/language_detection_util.cc index 9556bb9..1440714 100644 --- a/components/translate/core/language_detection/language_detection_util.cc +++ b/components/translate/core/language_detection/language_detection_util.cc @@ -324,7 +324,7 @@ bool IsValidLanguageCode(const std::string& code) { for (std::string::const_iterator it = main_code.begin(); it != main_code.end(); ++it) { - if (!IsAsciiAlpha(*it)) + if (!base::IsAsciiAlpha(*it)) return false; } @@ -338,7 +338,7 @@ bool IsValidLanguageCode(const std::string& code) { for (std::string::const_iterator it = sub_code.begin(); it != sub_code.end(); ++it) { - if (!IsAsciiAlpha(*it)) + if (!base::IsAsciiAlpha(*it)) return false; } diff --git a/components/url_fixer/url_fixer.cc b/components/url_fixer/url_fixer.cc index f20159d..7c04272 100644 --- a/components/url_fixer/url_fixer.cc +++ b/components/url_fixer/url_fixer.cc @@ -343,7 +343,7 @@ bool HasPort(const std::string& original_text, // Scan the range to see if it is entirely digits. for (size_t i = port_start; i < port_end; ++i) { - if (!IsAsciiDigit(original_text[i])) + if (!base::IsAsciiDigit(original_text[i])) return false; } @@ -467,7 +467,8 @@ std::string SegmentURLInternal(std::string* text, url::Parsed* parts) { // We need to add a scheme in order for ParseStandardURL to be happy. // Find the first non-whitespace character. std::string::iterator first_nonwhite = text->begin(); - while ((first_nonwhite != text->end()) && IsWhitespace(*first_nonwhite)) + while ((first_nonwhite != text->end()) && + base::IsUnicodeWhitespace(*first_nonwhite)) ++first_nonwhite; // Construct the text to parse by inserting the scheme. diff --git a/content/browser/appcache/view_appcache_internals_job.cc b/content/browser/appcache/view_appcache_internals_job.cc index 57848da..3ef6f81 100644 --- a/content/browser/appcache/view_appcache_internals_job.cc +++ b/content/browser/appcache/view_appcache_internals_job.cc @@ -129,7 +129,7 @@ void EmitAppCacheInfo(const GURL& base_url, out->append("<ul>"); EmitListItem( kSize, - base::UTF16ToUTF8(FormatBytesUnlocalized(info->size)), + base::UTF16ToUTF8(base::FormatBytesUnlocalized(info->size)), out); EmitListItem( kCreationTime, @@ -242,7 +242,7 @@ void EmitAppCacheResourceInfoVector( iter->url, iter->response_id, group_id), false, false, out); - EmitTableData(base::UTF16ToUTF8(FormatBytesUnlocalized(iter->size)), + EmitTableData(base::UTF16ToUTF8(base::FormatBytesUnlocalized(iter->size)), true, false, out); out->append("</tr>\n"); } diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index b879939..f05c253 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -90,7 +90,7 @@ base::FilePath::StringType StripOrdinalNumber( for (base::FilePath::StringType::size_type i = l_paren_index + 1; i != r_paren_index; ++i) { - if (!IsAsciiDigit(pure_file_name[i])) + if (!base::IsAsciiDigit(pure_file_name[i])) return pure_file_name; } diff --git a/content/browser/download/save_package_unittest.cc b/content/browser/download/save_package_unittest.cc index c6c862c4..2665d2b 100644 --- a/content/browser/download/save_package_unittest.cc +++ b/content/browser/download/save_package_unittest.cc @@ -54,7 +54,7 @@ bool HasOrdinalNumber(const base::FilePath::StringType& filename) { for (base::FilePath::StringType::size_type i = l_paren_index + 1; i != r_paren_index; ++i) { - if (!IsAsciiDigit(filename[i])) + if (!base::IsAsciiDigit(filename[i])) return false; } diff --git a/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc b/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc index 43dd8129..e02027b 100644 --- a/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc @@ -265,7 +265,8 @@ class FileSystemDirURLRequestJobTest : public testing::Test { EXPECT_EQ(icu::UnicodeString(is_directory ? "1" : "0"), match.group(3, status)); if (size >= 0) { - icu::UnicodeString size_string(FormatBytesUnlocalized(size).c_str()); + icu::UnicodeString size_string( + base::FormatBytesUnlocalized(size).c_str()); EXPECT_EQ(size_string, match.group(4, status)); } diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc index d5f1da50..bdb2514 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc @@ -498,8 +498,8 @@ std::string PepperFileSystemBrowserHost::GeneratePluginId( // Verify |output| contains only alphabets, digits, or "._-". for (std::string::const_iterator it = output.begin(); it != output.end(); ++it) { - if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '.' && *it != '_' && - *it != '-') { + if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it) && + *it != '.' && *it != '_' && *it != '-') { LOG(WARNING) << "Failed to generate a plugin id."; return std::string(); } diff --git a/content/common/android/address_parser_internal.cc b/content/common/android/address_parser_internal.cc index fce5358..79e1d31 100644 --- a/content/common/android/address_parser_internal.cc +++ b/content/common/android/address_parser_internal.cc @@ -84,7 +84,7 @@ bool HouseNumberParser::IsPreDelimiter(base::char16 character) { } bool HouseNumberParser::IsPostDelimiter(base::char16 character) { - return IsWhitespace(character) || strchr(",\"'", character); + return base::IsUnicodeWhitespace(character) || strchr(",\"'", character); } void HouseNumberParser::RestartOnNextDelimiter() { @@ -144,7 +144,7 @@ bool HouseNumberParser::Parse( } // More digits. There should be no more after a letter was found. - if (IsAsciiDigit(*it_)) { + if (base::IsAsciiDigit(*it_)) { if (num_digits_ >= kMaxHouseDigits) { RestartOnNextDelimiter(); } else { @@ -154,7 +154,7 @@ bool HouseNumberParser::Parse( continue; } - if (IsAsciiAlpha(*it_)) { + if (base::IsAsciiAlpha(*it_)) { // Handle special case 'one'. if (result_chars_ == 0) { if (it_ + 3 <= end_ && base::LowerCaseEqualsASCII(it_, it_ + 3, "one")) @@ -168,7 +168,7 @@ bool HouseNumberParser::Parse( DCHECK_GT(result_chars_, 0U); DCHECK(it_ != begin_); base::char16 previous = SafePreviousChar(it_, begin_); - if (IsAsciiDigit(previous)) { + if (base::IsAsciiDigit(previous)) { // Check cases like '12A'. base::char16 next = SafeNextChar(it_, end_); if (IsPostDelimiter(next)) { @@ -177,7 +177,7 @@ bool HouseNumberParser::Parse( } // Handle cases like 12a, 1st, 2nd, 3rd, 7th. - if (IsAsciiAlpha(next)) { + if (base::IsAsciiAlpha(next)) { base::char16 last_digit = previous; base::char16 first_letter = base::ToLowerASCII(*it_); base::char16 second_letter = base::ToLowerASCII(next); @@ -350,7 +350,7 @@ bool FindStateStartingInWord(WordList* words, const Word& first_word = words->at(state_first_word); int length = first_word.end - first_word.begin; - if (length < 2 || !IsAsciiAlpha(*first_word.begin)) + if (length < 2 || !base::IsAsciiAlpha(*first_word.begin)) return false; // No state names start with x, y, z. @@ -362,7 +362,7 @@ bool FindStateStartingInWord(WordList* words, int first_index = first_letter - 'a'; // Look for two-letter state names. - if (length == 2 && IsAsciiAlpha(*(first_word.begin + 1))) { + if (length == 2 && base::IsAsciiAlpha(*(first_word.begin + 1))) { base::char16 second_letter = base::ToLowerASCII(*(first_word.begin + 1)); DCHECK(second_letter >= 'a'); @@ -425,7 +425,7 @@ bool IsZipValid(const Word& word, size_t state_index) { for (base::string16::const_iterator it = word.begin; it != word.end; ++it) { size_t pos = it - word.begin; - if (IsAsciiDigit(*it) || (*it == '-' && pos == kZipDigits)) + if (base::IsAsciiDigit(*it) || (*it == '-' && pos == kZipDigits)) continue; return false; } @@ -503,8 +503,8 @@ bool IsZipValidForState(const Word& word, size_t state_index) { // Zip numeric value for the first two characters. DCHECK(word.begin != word.end); - DCHECK(IsAsciiDigit(*word.begin)); - DCHECK(IsAsciiDigit(*(word.begin + 1))); + DCHECK(base::IsAsciiDigit(*word.begin)); + DCHECK(base::IsAsciiDigit(*(word.begin + 1))); int zip_prefix = (*word.begin - '0') * 10 + (*(word.begin + 1) - '0'); if ((zip_prefix >= zip_range[state_index].low && @@ -599,7 +599,7 @@ bool IsValidLocationName(const Word& word) { location_names_accumulative[arraysize(location_names_accumulative) - 1], static_cast<int>(arraysize(location_names))); - if (!IsAsciiAlpha(*word.begin)) + if (!base::IsAsciiAlpha(*word.begin)) return false; // No location names start with y, z. diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc index 7e2fc77..44ac56f 100644 --- a/content/renderer/manifest/manifest_parser.cc +++ b/content/renderer/manifest/manifest_parser.cc @@ -26,7 +26,7 @@ bool IsValidIconWidthOrHeight(const std::string& str) { if (str.empty() || str[0] == '0') return false; for (size_t i = 0; i < str.size(); ++i) - if (!IsAsciiDigit(str[i])) + if (!base::IsAsciiDigit(str[i])) return false; return true; } diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc index 6c72bcc..fe21162 100644 --- a/device/bluetooth/bluetooth_device.cc +++ b/device/bluetooth/bluetooth_device.cc @@ -241,7 +241,7 @@ std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) { canonicalized[i] = ':'; } else { - if (!IsHexDigit(canonicalized[i])) + if (!base::IsHexDigit(canonicalized[i])) return std::string(); canonicalized[i] = base::ToUpperASCII(canonicalized[i]); diff --git a/device/bluetooth/bluetooth_uuid.cc b/device/bluetooth/bluetooth_uuid.cc index 714d1c5..d5933cc 100644 --- a/device/bluetooth/bluetooth_uuid.cc +++ b/device/bluetooth/bluetooth_uuid.cc @@ -40,7 +40,7 @@ void GetCanonicalUuid(std::string uuid, if (uuid[i] != '-') return; } else { - if (!IsHexDigit(uuid[i])) + if (!base::IsHexDigit(uuid[i])) return; uuid[i] = base::ToLowerASCII(uuid[i]); } diff --git a/device/udev_linux/udev.cc b/device/udev_linux/udev.cc index e2b93d2..6055fb9 100644 --- a/device/udev_linux/udev.cc +++ b/device/udev_linux/udev.cc @@ -171,8 +171,8 @@ std::string UdevDecodeString(const std::string& encoded) { for (size_t i = 0; i < size; ++i) { char c = encoded[i]; if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') { - c = (HexDigitToInt(encoded[i + 2]) << 4) + - HexDigitToInt(encoded[i + 3]); + c = (base::HexDigitToInt(encoded[i + 2]) << 4) + + base::HexDigitToInt(encoded[i + 3]); i += 3; } decoded.push_back(c); diff --git a/extensions/browser/api/networking_config/networking_config_service.cc b/extensions/browser/api/networking_config/networking_config_service.cc index b10813d..2f27f8c 100644 --- a/extensions/browser/api/networking_config/networking_config_service.cc +++ b/extensions/browser/api/networking_config/networking_config_service.cc @@ -25,7 +25,7 @@ bool IsValidNonEmptyHexString(const std::string& input) { if (count == 0 || (count % 2) != 0) return false; for (const char& c : input) - if (!IsHexDigit<char>(c)) + if (!base::IsHexDigit<char>(c)) return false; return true; } diff --git a/extensions/browser/api/vpn_provider/vpn_provider_api.cc b/extensions/browser/api/vpn_provider/vpn_provider_api.cc index f38a1e2..fb82aab 100644 --- a/extensions/browser/api/vpn_provider/vpn_provider_api.cc +++ b/extensions/browser/api/vpn_provider/vpn_provider_api.cc @@ -32,7 +32,7 @@ bool CheckIPCIDRSanity(const std::string& value, bool cidr, bool ipv6) { int counter = 0; for (const auto& elem : value) { - if (IsAsciiDigit(elem)) { + if (base::IsAsciiDigit(elem)) { counter++; continue; } @@ -53,7 +53,7 @@ bool CheckIPCIDRSanity(const std::string& value, bool cidr, bool ipv6) { if (!colon) return false; colon--; - } else if (!hex_allowed || !IsHexDigit(elem)) { + } else if (!hex_allowed || !base::IsHexDigit(elem)) { return false; } else { counter++; diff --git a/extensions/browser/user_script_loader.cc b/extensions/browser/user_script_loader.cc index 39e1ee8..69ef590 100644 --- a/extensions/browser/user_script_loader.cc +++ b/extensions/browser/user_script_loader.cc @@ -35,7 +35,7 @@ bool GetDeclarationValue(const base::StringPiece& line, std::string temp(line.data() + index + prefix.length(), line.length() - index - prefix.length()); - if (temp.empty() || !IsWhitespace(temp[0])) + if (temp.empty() || !base::IsUnicodeWhitespace(temp[0])) return false; base::TrimWhitespaceASCII(temp, base::TRIM_ALL, value); diff --git a/extensions/common/csp_validator.cc b/extensions/common/csp_validator.cc index ced436e..06ea4ef 100644 --- a/extensions/common/csp_validator.cc +++ b/extensions/common/csp_validator.cc @@ -83,7 +83,7 @@ bool isNonWildcardTLD(const std::string& url, // ":123456" or ":****" as valid, but that does not matter because the // relaxing CSP directive will just be ignored by Blink. for (size_t i = start_of_port + 1; i < end_of_host; ++i) { - is_valid_port = IsAsciiDigit(url[i]) || url[i] == '*'; + is_valid_port = base::IsAsciiDigit(url[i]) || url[i] == '*'; if (!is_valid_port) break; } diff --git a/extensions/common/message_bundle.cc b/extensions/common/message_bundle.cc index 1340e54..d71513f 100644 --- a/extensions/common/message_bundle.cc +++ b/extensions/common/message_bundle.cc @@ -281,7 +281,8 @@ bool MessageBundle::IsValidName(const std::string& name) { std::string::const_iterator it = name.begin(); for (; it != name.end(); ++it) { // Allow only ascii 0-9, a-z, A-Z, and _ in the name. - if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '_' && *it != '@') + if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it) && *it != '_' && + *it != '@') return false; } diff --git a/extensions/common/permissions/socket_permission_entry.cc b/extensions/common/permissions/socket_permission_entry.cc index 0974ff8..6adf307 100644 --- a/extensions/common/permissions/socket_permission_entry.cc +++ b/extensions/common/permissions/socket_permission_entry.cc @@ -28,8 +28,8 @@ const uint16 kWildcardPortNumber = 0; const uint16 kInvalidPort = 65535; bool StartsOrEndsWithWhitespace(const std::string& str) { - return !str.empty() && - (IsWhitespace(str[0]) || IsWhitespace(str[str.length() - 1])); + return !str.empty() && (base::IsUnicodeWhitespace(str[0]) || + base::IsUnicodeWhitespace(str[str.length() - 1])); } } // namespace diff --git a/google_apis/gaia/oauth_request_signer.cc b/google_apis/gaia/oauth_request_signer.cc index 115c14d..2772c04 100644 --- a/google_apis/gaia/oauth_request_signer.cc +++ b/google_apis/gaia/oauth_request_signer.cc @@ -322,7 +322,7 @@ bool OAuthRequestSigner::Decode(const std::string& text, DCHECK(low >= 0 || low < kHexBase); char decoded = static_cast<char>(high * kHexBase + low); - DCHECK(!(IsAsciiAlpha(decoded) || IsAsciiDigit(decoded))); + DCHECK(!(base::IsAsciiAlpha(decoded) || base::IsAsciiDigit(decoded))); DCHECK(!(decoded && strchr("-._~", decoded))); accumulator += decoded; } else { @@ -340,7 +340,7 @@ std::string OAuthRequestSigner::Encode(const std::string& text) { std::string::const_iterator limit; for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) { char character = *cursor; - if (IsAsciiAlpha(character) || IsAsciiDigit(character)) { + if (base::IsAsciiAlpha(character) || base::IsAsciiDigit(character)) { result += character; } else { switch (character) { diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc index 9e670ef..535837c 100644 --- a/media/base/mime_util.cc +++ b/media/base/mime_util.cc @@ -495,7 +495,7 @@ void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() { // equal to the specified level." static bool IsValidH264BaselineProfile(const std::string& profile_str) { return (profile_str.size() == 4 && profile_str[0] == '4' && - profile_str[1] == '2' && IsHexDigit(profile_str[2]) && + profile_str[1] == '2' && base::IsHexDigit(profile_str[2]) && profile_str[3] == '0'); } diff --git a/media/blink/webcontentdecryptionmodulesession_impl.cc b/media/blink/webcontentdecryptionmodulesession_impl.cc index 3d77321..174ef50 100644 --- a/media/blink/webcontentdecryptionmodulesession_impl.cc +++ b/media/blink/webcontentdecryptionmodulesession_impl.cc @@ -170,7 +170,7 @@ static bool SanitizeSessionId(const blink::WebString& session_id, return false; for (const char c : *sanitized_session_id) { - if (!IsAsciiAlpha(c) && !IsAsciiDigit(c)) + if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c)) return false; } diff --git a/net/base/data_url.cc b/net/base/data_url.cc index b03d997..d558587 100644 --- a/net/base/data_url.cc +++ b/net/base/data_url.cc @@ -106,7 +106,7 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type, if (base64_encoded || !(mime_type->compare(0, 5, "text/") == 0 || mime_type->find("xml") != std::string::npos)) { temp_data.erase(std::remove_if(temp_data.begin(), temp_data.end(), - IsAsciiWhitespace<wchar_t>), + base::IsAsciiWhitespace<wchar_t>), temp_data.end()); } diff --git a/net/base/escape.cc b/net/base/escape.cc index 8e6f870..972c285 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -52,7 +52,7 @@ std::string Escape(const std::string& text, if (use_plus && ' ' == c) { escaped.push_back('+'); } else if (keep_escaped && '%' == c && i + 2 < text.length() && - IsHexDigit(text[i + 1]) && IsHexDigit(text[i + 2])) { + base::IsHexDigit(text[i + 1]) && base::IsHexDigit(text[i + 2])) { escaped.push_back('%'); } else if (charmap.Contains(c)) { escaped.push_back('%'); @@ -118,9 +118,9 @@ bool UnescapeUnsignedCharAtIndex(const STR& escaped_text, static_cast<typename STR::value_type>(escaped_text[index + 1])); const typename STR::value_type least_sig_digit( static_cast<typename STR::value_type>(escaped_text[index + 2])); - if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) { - *value = HexDigitToInt(most_sig_digit) * 16 + - HexDigitToInt(least_sig_digit); + if (base::IsHexDigit(most_sig_digit) && base::IsHexDigit(least_sig_digit)) { + *value = base::HexDigitToInt(most_sig_digit) * 16 + + base::HexDigitToInt(least_sig_digit); return true; } return false; diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc index 447f594..907c7c4 100644 --- a/net/base/mime_sniffer.cc +++ b/net/base/mime_sniffer.cc @@ -405,7 +405,7 @@ static bool SniffForHTML(const char* content, const char* const end = content + size; const char* pos; for (pos = content; pos < end; ++pos) { - if (!IsAsciiWhitespace(*pos)) + if (!base::IsAsciiWhitespace(*pos)) break; } static base::HistogramBase* counter(NULL); diff --git a/net/base/net_util.cc b/net/base/net_util.cc index ebd2bf3..c59b3cd 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -341,7 +341,7 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) { // Overflow is still possible for evil user inputs. for (size_t i = 0; i <= size; ++i) { // The string should be composed of only digits and commas. - if (i != size && !IsAsciiDigit(allowed_ports[i]) && + if (i != size && !base::IsAsciiDigit(allowed_ports[i]) && (allowed_ports[i] != kComma)) return; if (i == size || allowed_ports[i] == kComma) { diff --git a/net/base/net_util_icu.cc b/net/base/net_util_icu.cc index 01204a3..0c2644b 100644 --- a/net/base/net_util_icu.cc +++ b/net/base/net_util_icu.cc @@ -610,7 +610,7 @@ std::string GetDirectoryListingEntry(const base::string16& name, // Negative size means unknown or not applicable (e.g. directory). base::string16 size_string; if (size >= 0) - size_string = FormatBytesUnlocalized(size); + size_string = base::FormatBytesUnlocalized(size); base::EscapeJSONString(size_string, true, &result); result.append(","); diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc index 9ad6eaa..2723363 100644 --- a/net/cookies/cookie_util.cc +++ b/net/cookies/cookie_util.cc @@ -118,7 +118,7 @@ base::Time ParseCookieTime(const std::string& time_string) { while (tokenizer.GetNext()) { const std::string token = tokenizer.token(); DCHECK(!token.empty()); - bool numerical = IsAsciiDigit(token[0]); + bool numerical = base::IsAsciiDigit(token[0]); // String field if (!numerical) { diff --git a/net/http/http_content_disposition.cc b/net/http/http_content_disposition.cc index 06f815b..0e830f6 100644 --- a/net/http/http_content_disposition.cc +++ b/net/http/http_content_disposition.cc @@ -34,11 +34,11 @@ bool DecodeQEncoding(const std::string& input, std::string* output) { temp.push_back(' '); } else if (*it == '=') { if ((input.end() - it < 3) || - !IsHexDigit(static_cast<unsigned char>(*(it + 1))) || - !IsHexDigit(static_cast<unsigned char>(*(it + 2)))) + !base::IsHexDigit(static_cast<unsigned char>(*(it + 1))) || + !base::IsHexDigit(static_cast<unsigned char>(*(it + 2)))) return false; - unsigned char ch = HexDigitToInt(*(it + 1)) * 16 + - HexDigitToInt(*(it + 2)); + unsigned char ch = + base::HexDigitToInt(*(it + 1)) * 16 + base::HexDigitToInt(*(it + 2)); temp.push_back(static_cast<char>(ch)); ++it; ++it; diff --git a/net/http/http_security_headers.cc b/net/http/http_security_headers.cc index e8e3a47..d95e587 100644 --- a/net/http/http_security_headers.cc +++ b/net/http/http_security_headers.cc @@ -197,7 +197,7 @@ bool ParseHSTSHeader(const std::string& value, switch (state) { case START: case DIRECTIVE_END: - if (IsAsciiWhitespace(*tokenizer.token_begin())) + if (base::IsAsciiWhitespace(*tokenizer.token_begin())) continue; if (base::LowerCaseEqualsASCII(tokenizer.token(), "max-age")) { state = AFTER_MAX_AGE_LABEL; @@ -213,7 +213,7 @@ bool ParseHSTSHeader(const std::string& value, break; case AFTER_MAX_AGE_LABEL: - if (IsAsciiWhitespace(*tokenizer.token_begin())) + if (base::IsAsciiWhitespace(*tokenizer.token_begin())) continue; if (*tokenizer.token_begin() != '=') return false; @@ -222,7 +222,7 @@ bool ParseHSTSHeader(const std::string& value, break; case AFTER_MAX_AGE_EQUALS: - if (IsAsciiWhitespace(*tokenizer.token_begin())) + if (base::IsAsciiWhitespace(*tokenizer.token_begin())) continue; unquoted = HttpUtil::Unquote(tokenizer.token()); if (!MaxAgeToInt(unquoted.begin(), unquoted.end(), &max_age_candidate)) @@ -232,7 +232,7 @@ bool ParseHSTSHeader(const std::string& value, case AFTER_MAX_AGE: case AFTER_INCLUDE_SUBDOMAINS: - if (IsAsciiWhitespace(*tokenizer.token_begin())) + if (base::IsAsciiWhitespace(*tokenizer.token_begin())) continue; else if (*tokenizer.token_begin() == ';') state = DIRECTIVE_END; diff --git a/net/tools/dump_cache/url_to_filename_encoder.cc b/net/tools/dump_cache/url_to_filename_encoder.cc index b807ec0..083b9c5 100644 --- a/net/tools/dump_cache/url_to_filename_encoder.cc +++ b/net/tools/dump_cache/url_to_filename_encoder.cc @@ -18,7 +18,7 @@ namespace { // The function checks for '\0' for string termination. int HexDigitsPrefix(const char* buf, int num_digits) { for (int i = 0; i < num_digits; i++) { - if (!IsHexDigit(buf[i])) + if (!base::IsHexDigit(buf[i])) return 0; // This also detects end of string as '\0' is not xdigit. } return 1; diff --git a/net/tools/dump_cache/url_utilities.cc b/net/tools/dump_cache/url_utilities.cc index 7604494..807f187 100644 --- a/net/tools/dump_cache/url_utilities.cc +++ b/net/tools/dump_cache/url_utilities.cc @@ -87,7 +87,7 @@ std::string UrlUtilities::Unescape(const std::string& escaped_url) { ++iter; break; case ESCAPE1: - if (IsHexDigit(c)) { + if (base::IsHexDigit(c)) { escape_text.push_back(c); state = ESCAPE2; ++iter; @@ -98,7 +98,7 @@ std::string UrlUtilities::Unescape(const std::string& escaped_url) { } break; case ESCAPE2: - if (IsHexDigit(c)) { + if (base::IsHexDigit(c)) { escape_text.push_back(c); bool ok = base::HexStringToInt(escape_text, &escape_value); DCHECK(ok); diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 1672ec4..2825d8c 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -472,7 +472,7 @@ void FormatStringWithHyphens(base::string16* text) { current_hyphen_position = HyphenPosition(); current_hyphen_position.position = i; current_hyphen_position_is_valid = true; - } else if (IsWhitespace(current_char)) { + } else if (base::IsUnicodeWhitespace(current_char)) { if (current_hyphen_position_is_valid) { if (current_char != L'\r' && current_char != L'\n') current_hyphen_position.next_whitespace_position = i; diff --git a/rlz/lib/rlz_lib.cc b/rlz/lib/rlz_lib.cc index 14a4fae..4a3cfde 100644 --- a/rlz/lib/rlz_lib.cc +++ b/rlz/lib/rlz_lib.cc @@ -58,7 +58,7 @@ bool IsAccessPointSupported(rlz_lib::AccessPoint point) { // We will be more liberal and allow some additional chars, but not url meta // chars. bool IsGoodRlzChar(const char ch) { - if (IsAsciiAlpha(ch) || IsAsciiDigit(ch)) + if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch)) return true; switch (ch) { diff --git a/rlz/win/lib/machine_deal.cc b/rlz/win/lib/machine_deal.cc index aeab4f4..7c8bbaa 100644 --- a/rlz/win/lib/machine_deal.cc +++ b/rlz/win/lib/machine_deal.cc @@ -29,7 +29,7 @@ const wchar_t kDccValueName[] = L"DCC"; // We will be more liberal and allow some additional chars, but not url meta // chars. bool IsGoodDccChar(char ch) { - if (IsAsciiAlpha(ch) || IsAsciiDigit(ch)) + if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch)) return true; switch (ch) { diff --git a/sql/connection.cc b/sql/connection.cc index b17457b..d1b1049 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -812,7 +812,7 @@ int Connection::ExecuteAndReturnErrorCode(const char* sql) { // sqlite3_exec() does this, presumably to avoid spinning the parser for // trailing whitespace. // TODO(shess): Audit to see if this can become a DCHECK. - while (IsAsciiWhitespace(*sql)) { + while (base::IsAsciiWhitespace(*sql)) { sql++; } diff --git a/storage/browser/database/database_util.cc b/storage/browser/database/database_util.cc index 113f533..f020302 100644 --- a/storage/browser/database/database_util.cc +++ b/storage/browser/database/database_util.cc @@ -19,8 +19,8 @@ bool IsSafeSuffix(const base::string16& suffix) { for (base::string16::const_iterator it = suffix.begin(); it < suffix.end(); ++it) { base::char16 c = *it; - if (!(IsAsciiAlpha(c) || IsAsciiDigit(c) || - c == '-' || c == '.' || c == '_')) { + if (!(base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) || + c == '-' || c == '.' || c == '_')) { return false; } if (c == '.' && prev_c == '.') diff --git a/sync/util/get_session_name_mac.mm b/sync/util/get_session_name_mac.mm index e5f8b8f..ddd2c3c 100644 --- a/sync/util/get_session_name_mac.mm +++ b/sync/util/get_session_name_mac.mm @@ -36,7 +36,7 @@ std::string GetHardwareModelName() { size_t length = sizeof(modelBuffer); if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) { for (size_t i = 0; i < length; i++) { - if (IsAsciiDigit(modelBuffer[i])) + if (base::IsAsciiDigit(modelBuffer[i])) return std::string(modelBuffer, 0, i); } return std::string(modelBuffer, 0, length); diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc index c4c16bb..518a1b6 100644 --- a/tools/gn/command_args.cc +++ b/tools/gn/command_args.cc @@ -37,7 +37,7 @@ const char kSwitchShort[] = "short"; bool DoesLineBeginWithComment(const base::StringPiece& line) { // Skip whitespace. size_t i = 0; - while (i < line.size() && IsAsciiWhitespace(line[i])) + while (i < line.size() && base::IsAsciiWhitespace(line[i])) i++; return i < line.size() && line[i] == '#'; diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc index 67bb6e2..6e1c01d 100644 --- a/tools/gn/filesystem_utils.cc +++ b/tools/gn/filesystem_utils.cc @@ -100,7 +100,7 @@ bool DoesBeginWindowsDriveLetter(const base::StringPiece& path) { return false; // Check drive letter. - if (!IsAsciiAlpha(path[0])) + if (!base::IsAsciiAlpha(path[0])) return false; if (!IsSlash(path[2])) diff --git a/tools/gn/label.cc b/tools/gn/label.cc index 60ebf31..171511a 100644 --- a/tools/gn/label.cc +++ b/tools/gn/label.cc @@ -105,7 +105,7 @@ bool Resolve(const SourceDir& current_dir, return false; } if (input.size() > 3 && input[2] == ':' && IsSlash(input[3]) && - IsAsciiAlpha(input[1])) { + base::IsAsciiAlpha(input[1])) { // Skip over the drive letter colon. offset = 3; } diff --git a/tools/gn/label_pattern.cc b/tools/gn/label_pattern.cc index e5ea5cf..6c8addd 100644 --- a/tools/gn/label_pattern.cc +++ b/tools/gn/label_pattern.cc @@ -132,7 +132,7 @@ LabelPattern LabelPattern::GetPattern(const SourceDir& current_dir, return LabelPattern(); } if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) && - IsAsciiAlpha(str[1])) { + base::IsAsciiAlpha(str[1])) { // Skip over the drive letter colon. offset = 3; } diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc index 567fa72..be3223b 100644 --- a/tools/gn/tokenizer.cc +++ b/tools/gn/tokenizer.cc @@ -188,7 +188,7 @@ void Tokenizer::AdvanceToNextToken() { Token::Type Tokenizer::ClassifyCurrent() const { DCHECK(!at_end()); char next_char = cur_char(); - if (IsAsciiDigit(next_char)) + if (base::IsAsciiDigit(next_char)) return Token::INTEGER; if (next_char == '"') return Token::STRING; @@ -228,7 +228,7 @@ Token::Type Tokenizer::ClassifyCurrent() const { return Token::UNCLASSIFIED_OPERATOR; // Just the minus before end of // file. char following_char = input_[cur_ + 1]; - if (IsAsciiDigit(following_char)) + if (base::IsAsciiDigit(following_char)) return Token::INTEGER; return Token::UNCLASSIFIED_OPERATOR; } @@ -242,7 +242,7 @@ void Tokenizer::AdvanceToEndOfToken(const Location& location, case Token::INTEGER: do { Advance(); - } while (!at_end() && IsAsciiDigit(cur_char())); + } while (!at_end() && base::IsAsciiDigit(cur_char())); if (!at_end()) { // Require the char after a number to be some kind of space, scope, // or operator. diff --git a/tools/gn/tokenizer.h b/tools/gn/tokenizer.h index 497a170..29d107a 100644 --- a/tools/gn/tokenizer.h +++ b/tools/gn/tokenizer.h @@ -33,12 +33,12 @@ class Tokenizer { static bool IsNewline(const base::StringPiece& buffer, size_t offset); static bool IsIdentifierFirstChar(char c) { - return IsAsciiAlpha(c) || c == '_'; + return base::IsAsciiAlpha(c) || c == '_'; } static bool IsIdentifierContinuingChar(char c) { // Also allow digits after the first char. - return IsIdentifierFirstChar(c) || IsAsciiDigit(c); + return IsIdentifierFirstChar(c) || base::IsAsciiDigit(c); } private: diff --git a/ui/accessibility/ax_text_utils.cc b/ui/accessibility/ax_text_utils.cc index da336b6..1e68559 100644 --- a/ui/accessibility/ax_text_utils.cc +++ b/ui/accessibility/ax_text_utils.cc @@ -62,7 +62,7 @@ size_t FindAccessibleTextBoundary(const base::string16& text, NOTREACHED(); // These are handled above. break; case WORD_BOUNDARY: - if (IsWhitespace(text[pos])) + if (base::IsUnicodeWhitespace(text[pos])) return result; break; case PARAGRAPH_BOUNDARY: @@ -71,7 +71,8 @@ size_t FindAccessibleTextBoundary(const base::string16& text, break; case SENTENCE_BOUNDARY: if ((text[pos] == '.' || text[pos] == '!' || text[pos] == '?') && - (pos == text_size - 1 || IsWhitespace(text[pos + 1]))) { + (pos == text_size - 1 || + base::IsUnicodeWhitespace(text[pos + 1]))) { return result; } break; diff --git a/ui/app_list/search/term_break_iterator.cc b/ui/app_list/search/term_break_iterator.cc index 54a1c36..233a879 100644 --- a/ui/app_list/search/term_break_iterator.cc +++ b/ui/app_list/search/term_break_iterator.cc @@ -54,7 +54,7 @@ const base::string16 TermBreakIterator::GetCurrentTerm() const { } TermBreakIterator::State TermBreakIterator::GetNewState(base::char16 ch) { - if (IsAsciiDigit(ch) || ch == '.' || ch == ',') + if (base::IsAsciiDigit(ch) || ch == '.' || ch == ',') return STATE_NUMBER; const bool is_upper = !!u_isUUppercase(ch); diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc index 18317ca..a05e185 100644 --- a/ui/base/accelerators/accelerator.cc +++ b/ui/base/accelerators/accelerator.cc @@ -228,7 +228,7 @@ base::string16 Accelerator::GetShortcutText() const { base::string16 shortcut_rtl; bool adjust_shortcut_for_rtl = false; if (base::i18n::IsRTL() && shortcut.length() == 1 && - !IsAsciiAlpha(shortcut[0]) && !IsAsciiDigit(shortcut[0])) { + !base::IsAsciiAlpha(shortcut[0]) && !base::IsAsciiDigit(shortcut[0])) { adjust_shortcut_for_rtl = true; shortcut_rtl.assign(shortcut); } diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc index 3191a51..a1695e9 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -614,7 +614,7 @@ bool IsValidLocaleSyntax(const std::string& locale) { // underscore. for (size_t i = 0; i < prefix.size(); i++) { char ch = prefix[i]; - if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_') + if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) && ch != '_') return false; } @@ -627,7 +627,7 @@ bool IsValidLocaleSyntax(const std::string& locale) { return false; break; } - if (!IsAsciiAlpha(ch)) + if (!base::IsAsciiAlpha(ch)) return false; } diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_feedback.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_feedback.cc index dd329dc..72c16be 100644 --- a/ui/events/ozone/evdev/libgestures_glue/gesture_feedback.cc +++ b/ui/events/ozone/evdev/libgestures_glue/gesture_feedback.cc @@ -100,7 +100,7 @@ std::string GetCurrentTimeForLogging() { std::string GetCanonicalDeviceName(const std::string& name) { std::string ret(name); for (size_t i = 0; i < ret.size(); ++i) - if (!IsAsciiAlpha(ret[i])) + if (!base::IsAsciiAlpha(ret[i])) ret[i] = '_'; return ret; } |