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}
This commit is contained in:
base
json
process
strings
test
expectations
chrome
browser
chromeos
drive
extensions
install_verification
internal_auth.ccprofile_resetter
shell_integration_win.ccui
common
favicon
components
autofill
content_settings
core
gcm_driver
instance_id
omnibox
password_manager
resource_provider
search_engines
translate
core
language_detection
url_fixer
content
browser
appcache
download
fileapi
renderer_host
common
android
renderer
manifest
device
extensions
google_apis/gaia
media
net
base
cookies
http
tools
pdf/pdfium
rlz
sql
storage/browser/database
sync/util
tools/gn
ui
accessibility
app_list
search
base
events
ozone
evdev
libgestures_glue
@@ -31,7 +31,7 @@ const int32 kExtendedASCIIStart = 0x80;
|
|||||||
// optimization avoids about 2/3rds of string memory copies. The constructor
|
// 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
|
// takes ownership of the input string. The real root value is Swap()ed into
|
||||||
// the new instance.
|
// the new instance.
|
||||||
class DictionaryHiddenRootValue : public base::DictionaryValue {
|
class DictionaryHiddenRootValue : public DictionaryValue {
|
||||||
public:
|
public:
|
||||||
DictionaryHiddenRootValue(std::string* json, Value* root) : json_(json) {
|
DictionaryHiddenRootValue(std::string* json, Value* root) : json_(json) {
|
||||||
DCHECK(root->IsType(Value::TYPE_DICTIONARY));
|
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
|
// First deep copy to convert JSONStringValue to std::string and swap that
|
||||||
// copy with |other|, which contains the new contents of |this|.
|
// copy with |other|, which contains the new contents of |this|.
|
||||||
scoped_ptr<base::DictionaryValue> copy(DeepCopy());
|
scoped_ptr<DictionaryValue> copy(DeepCopy());
|
||||||
copy->Swap(other);
|
copy->Swap(other);
|
||||||
|
|
||||||
// Then erase the contents of the current dictionary and swap in the
|
// 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);
|
DISALLOW_COPY_AND_ASSIGN(DictionaryHiddenRootValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ListHiddenRootValue : public base::ListValue {
|
class ListHiddenRootValue : public ListValue {
|
||||||
public:
|
public:
|
||||||
ListHiddenRootValue(std::string* json, Value* root) : json_(json) {
|
ListHiddenRootValue(std::string* json, Value* root) : json_(json) {
|
||||||
DCHECK(root->IsType(Value::TYPE_LIST));
|
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
|
// First deep copy to convert JSONStringValue to std::string and swap that
|
||||||
// copy with |other|, which contains the new contents of |this|.
|
// copy with |other|, which contains the new contents of |this|.
|
||||||
scoped_ptr<base::ListValue> copy(DeepCopy());
|
scoped_ptr<ListValue> copy(DeepCopy());
|
||||||
copy->Swap(other);
|
copy->Swap(other);
|
||||||
|
|
||||||
// Then erase the contents of the current list and swap in the new contents,
|
// 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
|
// 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),
|
// 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.
|
// otherwise the referenced string will not be guaranteed to outlive it.
|
||||||
class JSONStringValue : public base::Value {
|
class JSONStringValue : public Value {
|
||||||
public:
|
public:
|
||||||
explicit JSONStringValue(const base::StringPiece& piece)
|
explicit JSONStringValue(const StringPiece& piece)
|
||||||
: Value(TYPE_STRING),
|
: Value(TYPE_STRING),
|
||||||
string_piece_(piece) {
|
string_piece_(piece) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overridden from base::Value:
|
// Overridden from Value:
|
||||||
bool GetAsString(std::string* out_value) const override {
|
bool GetAsString(std::string* out_value) const override {
|
||||||
string_piece_.CopyToString(out_value);
|
string_piece_.CopyToString(out_value);
|
||||||
return true;
|
return true;
|
||||||
@@ -157,7 +157,7 @@ class JSONStringValue : public base::Value {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// The location in the original input stream.
|
// The location in the original input stream.
|
||||||
base::StringPiece string_piece_;
|
StringPiece string_piece_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(JSONStringValue);
|
DISALLOW_COPY_AND_ASSIGN(JSONStringValue);
|
||||||
};
|
};
|
||||||
@@ -872,7 +872,7 @@ Value* JSONParser::ConsumeNumber() {
|
|||||||
return new FundamentalValue(num_int);
|
return new FundamentalValue(num_int);
|
||||||
|
|
||||||
double num_double;
|
double num_double;
|
||||||
if (base::StringToDouble(num_string.as_string(), &num_double) &&
|
if (StringToDouble(num_string.as_string(), &num_double) &&
|
||||||
std::isfinite(num_double)) {
|
std::isfinite(num_double)) {
|
||||||
return new FundamentalValue(num_double);
|
return new FundamentalValue(num_double);
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ const char kProcDir[] = "/proc";
|
|||||||
|
|
||||||
const char kStatFile[] = "stat";
|
const char kStatFile[] = "stat";
|
||||||
|
|
||||||
base::FilePath GetProcPidDir(pid_t pid) {
|
FilePath GetProcPidDir(pid_t pid) {
|
||||||
return base::FilePath(kProcDir).Append(IntToString(pid));
|
return FilePath(kProcDir).Append(IntToString(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t ProcDirSlotToPid(const char* d_name) {
|
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;
|
typedef std::map<std::string, std::string> ProcStatMap;
|
||||||
void ParseProcStat(const std::string& contents, ProcStatMap* output) {
|
void ParseProcStat(const std::string& contents, ProcStatMap* output) {
|
||||||
base::StringPairs key_value_pairs;
|
StringPairs key_value_pairs;
|
||||||
SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs);
|
SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs);
|
||||||
for (size_t i = 0; i < key_value_pairs.size(); ++i) {
|
for (size_t i = 0; i < key_value_pairs.size(); ++i) {
|
||||||
output->insert(key_value_pairs[i]);
|
output->insert(key_value_pairs[i]);
|
||||||
|
@@ -131,10 +131,10 @@ template<int BASE, typename CHAR> bool CharToDigit(CHAR c, uint8* digit) {
|
|||||||
return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit);
|
return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is an IsWhitespace for wchars defined in string_util.h, but it is
|
// There is an IsUnicodeWhitespace for wchars defined in string_util.h, but it
|
||||||
// locale independent, whereas the functions we are replacing were
|
// is locale independent, whereas the functions we are replacing were
|
||||||
// locale-dependent. TBD what is desired, but for the moment let's not introduce
|
// locale-dependent. TBD what is desired, but for the moment let's not
|
||||||
// a change in behaviour.
|
// introduce a change in behaviour.
|
||||||
template<typename CHAR> class WhitespaceHelper {
|
template<typename CHAR> class WhitespaceHelper {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -334,7 +334,7 @@ STR CollapseWhitespaceT(const STR& text,
|
|||||||
|
|
||||||
int chars_written = 0;
|
int chars_written = 0;
|
||||||
for (typename STR::const_iterator i(text.begin()); i != text.end(); ++i) {
|
for (typename STR::const_iterator i(text.begin()); i != text.end(); ++i) {
|
||||||
if (IsWhitespace(*i)) {
|
if (IsUnicodeWhitespace(*i)) {
|
||||||
if (!in_whitespace) {
|
if (!in_whitespace) {
|
||||||
// Reduce all whitespace sequences to a single space.
|
// Reduce all whitespace sequences to a single space.
|
||||||
in_whitespace = true;
|
in_whitespace = true;
|
||||||
@@ -617,7 +617,16 @@ bool EndsWith(const string16& str,
|
|||||||
CompareCase::SENSITIVE);
|
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[] = {
|
static const char* const kByteStringsUnlocalized[] = {
|
||||||
" B",
|
" B",
|
||||||
@@ -647,9 +656,11 @@ string16 FormatBytesUnlocalized(int64 bytes) {
|
|||||||
kByteStringsUnlocalized[dimension]);
|
kByteStringsUnlocalized[dimension]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base::ASCIIToUTF16(buf);
|
return ASCIIToUTF16(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
// Runs in O(n) time in the length of |str|.
|
// Runs in O(n) time in the length of |str|.
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
void DoReplaceSubstringsAfterOffset(StringType* str,
|
void DoReplaceSubstringsAfterOffset(StringType* str,
|
||||||
|
@@ -377,16 +377,6 @@ BASE_EXPORT bool EndsWith(const string16& str,
|
|||||||
const string16& search,
|
const string16& search,
|
||||||
bool case_sensitive);
|
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
|
// Determines the type of ASCII character, independent of locale (the C
|
||||||
// library versions will change based on locale).
|
// library versions will change based on locale).
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
@@ -409,20 +399,15 @@ inline bool IsHexDigit(Char c) {
|
|||||||
(c >= 'a' && c <= 'f');
|
(c >= 'a' && c <= 'f');
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
// Returns the integer corresponding to the given hex character. For example:
|
||||||
inline char HexDigitToInt(Char c) {
|
// '4' -> 4
|
||||||
DCHECK(IsHexDigit(c));
|
// 'a' -> 10
|
||||||
if (c >= '0' && c <= '9')
|
// 'B' -> 11
|
||||||
return static_cast<char>(c - '0');
|
// Assumes the input is a valid hex character. DCHECKs in debug builds if not.
|
||||||
if (c >= 'A' && c <= 'F')
|
BASE_EXPORT char HexDigitToInt(wchar_t c);
|
||||||
return static_cast<char>(c - 'A' + 10);
|
|
||||||
if (c >= 'a' && c <= 'f')
|
|
||||||
return static_cast<char>(c - 'a' + 10);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if it's a whitespace character.
|
// Returns true if it's a Unicode whitespace character.
|
||||||
inline bool IsWhitespace(wchar_t c) {
|
inline bool IsUnicodeWhitespace(wchar_t c) {
|
||||||
return wcschr(base::kWhitespaceWide, c) != NULL;
|
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
|
// 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
|
// highly recommended instead. TODO(avi): Figure out how to get callers to use
|
||||||
// FormatBytes instead; remove this.
|
// 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
|
// Starting at |start_offset| (usually 0), replace the first instance of
|
||||||
// |find_this| with |replace_with|.
|
// |find_this| with |replace_with|.
|
||||||
|
@@ -39,7 +39,7 @@ inline bool Parser::HasNext() {
|
|||||||
Parser::StateFunc Parser::Start() {
|
Parser::StateFunc Parser::Start() {
|
||||||
// If at the start of a line is whitespace, skip it and arrange to come back
|
// If at the start of a line is whitespace, skip it and arrange to come back
|
||||||
// here.
|
// here.
|
||||||
if (IsAsciiWhitespace(*pos_))
|
if (base::IsAsciiWhitespace(*pos_))
|
||||||
return SkipWhitespaceAndNewLines(&Parser::Start);
|
return SkipWhitespaceAndNewLines(&Parser::Start);
|
||||||
|
|
||||||
// Handle comments at the start of lines.
|
// Handle comments at the start of lines.
|
||||||
@@ -161,7 +161,7 @@ Parser::StateFunc Parser::End() {
|
|||||||
|
|
||||||
Parser::StateFunc Parser::ExtractString(StateFunc success) {
|
Parser::StateFunc Parser::ExtractString(StateFunc success) {
|
||||||
const char* start = pos_;
|
const char* start = pos_;
|
||||||
while (!IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) {
|
while (!base::IsAsciiWhitespace(*pos_) && *pos_ != ']' && HasNext()) {
|
||||||
++pos_;
|
++pos_;
|
||||||
if (*pos_ == '#') {
|
if (*pos_ == '#') {
|
||||||
return SyntaxError("Unexpected start of comment");
|
return SyntaxError("Unexpected start of comment");
|
||||||
@@ -179,7 +179,7 @@ Parser::StateFunc Parser::SkipWhitespace(Parser::StateFunc next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Parser::StateFunc Parser::SkipWhitespaceAndNewLines(Parser::StateFunc next) {
|
Parser::StateFunc Parser::SkipWhitespaceAndNewLines(Parser::StateFunc next) {
|
||||||
while (IsAsciiWhitespace(*pos_) && HasNext()) {
|
while (base::IsAsciiWhitespace(*pos_) && HasNext()) {
|
||||||
if (*pos_ == '\n') {
|
if (*pos_ == '\n') {
|
||||||
++line_number_;
|
++line_number_;
|
||||||
}
|
}
|
||||||
|
@@ -248,8 +248,8 @@ std::string UnescapeCacheFileName(const std::string& filename) {
|
|||||||
for (size_t i = 0; i < filename.size(); ++i) {
|
for (size_t i = 0; i < filename.size(); ++i) {
|
||||||
char c = filename[i];
|
char c = filename[i];
|
||||||
if (c == '%' && i + 2 < filename.length()) {
|
if (c == '%' && i + 2 < filename.length()) {
|
||||||
c = (HexDigitToInt(filename[i + 1]) << 4) +
|
c = (base::HexDigitToInt(filename[i + 1]) << 4) +
|
||||||
HexDigitToInt(filename[i + 2]);
|
base::HexDigitToInt(filename[i + 2]);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
unescaped.push_back(c);
|
unescaped.push_back(c);
|
||||||
|
@@ -108,7 +108,7 @@ bool ValidateExpireDateFormat(const std::string& input) {
|
|||||||
if (i == 4 || i == 7) {
|
if (i == 4 || i == 7) {
|
||||||
if (input[i] != '-')
|
if (input[i] != '-')
|
||||||
return false;
|
return false;
|
||||||
} else if (!IsAsciiDigit(input[i])) {
|
} else if (!base::IsAsciiDigit(input[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ void ParseAdditionalModuleID(
|
|||||||
|
|
||||||
for (base::StringPiece::const_iterator it = digest_piece.begin();
|
for (base::StringPiece::const_iterator it = digest_piece.begin();
|
||||||
it != digest_piece.end(); ++it) {
|
it != digest_piece.end(); ++it) {
|
||||||
if (!IsHexDigit(*it))
|
if (!base::IsHexDigit(*it))
|
||||||
return; // Second token has invalid characters.
|
return; // Second token has invalid characters.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,7 @@ bool IsVarSane(const std::string& var) {
|
|||||||
var.size() <= kStringLengthLimit &&
|
var.size() <= kStringLengthLimit &&
|
||||||
base::IsStringASCII(var) &&
|
base::IsStringASCII(var) &&
|
||||||
var.find_first_not_of(kAllowedChars) == std::string::npos &&
|
var.find_first_not_of(kAllowedChars) == std::string::npos &&
|
||||||
!IsAsciiDigit(var[0]);
|
!base::IsAsciiDigit(var[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValueSane(const std::string& value) {
|
bool IsValueSane(const std::string& value) {
|
||||||
@@ -448,7 +448,7 @@ bool InternalAuthVerification::VerifyPassport(
|
|||||||
void InternalAuthVerification::ChangeKey(const std::string& key) {
|
void InternalAuthVerification::ChangeKey(const std::string& key) {
|
||||||
base::AutoLock alk(g_verification_service_lock.Get());
|
base::AutoLock alk(g_verification_service_lock.Get());
|
||||||
g_verification_service.Get().ChangeKey(key);
|
g_verification_service.Get().ChangeKey(key);
|
||||||
};
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
int InternalAuthVerification::get_verification_window_ticks() {
|
int InternalAuthVerification::get_verification_window_ticks() {
|
||||||
|
@@ -39,7 +39,7 @@ bool Hasher::IsHash(const std::string& maybe_hash) {
|
|||||||
return false;
|
return false;
|
||||||
for (std::string::const_iterator it = maybe_hash.begin();
|
for (std::string::const_iterator it = maybe_hash.begin();
|
||||||
it != maybe_hash.end(); ++it) {
|
it != maybe_hash.end(); ++it) {
|
||||||
if (!IsHexDigit(*it))
|
if (!base::IsHexDigit(*it))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -73,8 +73,8 @@ base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) {
|
|||||||
|
|
||||||
// Generate profile_id from sanitized basenames.
|
// Generate profile_id from sanitized basenames.
|
||||||
for (size_t i = 0; i < basenames.length(); ++i) {
|
for (size_t i = 0; i < basenames.length(); ++i) {
|
||||||
if (IsAsciiAlpha(basenames[i]) ||
|
if (base::IsAsciiAlpha(basenames[i]) ||
|
||||||
IsAsciiDigit(basenames[i]) ||
|
base::IsAsciiDigit(basenames[i]) ||
|
||||||
basenames[i] == L'.')
|
basenames[i] == L'.')
|
||||||
profile_id += basenames[i];
|
profile_id += basenames[i];
|
||||||
}
|
}
|
||||||
|
@@ -1466,7 +1466,7 @@ bool OmniboxEditModel::CreatedKeywordSearchByInsertingSpaceInMiddle(
|
|||||||
return false;
|
return false;
|
||||||
size_t space_position = caret_position - 1;
|
size_t space_position = caret_position - 1;
|
||||||
if (!IsSpaceCharForAcceptingKeyword(new_text[space_position]) ||
|
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(0, space_position, old_text, 0, space_position) ||
|
||||||
!new_text.compare(space_position, new_text.length() - space_position,
|
!new_text.compare(space_position, new_text.length() - space_position,
|
||||||
old_text, space_position,
|
old_text, space_position,
|
||||||
|
@@ -42,7 +42,8 @@ base::string16 OmniboxView::SanitizeTextForPaste(const base::string16& text) {
|
|||||||
// TODO(shess): It may also make sense to ignore leading or
|
// TODO(shess): It may also make sense to ignore leading or
|
||||||
// trailing whitespace when making this determination.
|
// trailing whitespace when making this determination.
|
||||||
for (size_t i = 0; i < text.size(); ++i) {
|
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);
|
const base::string16 collapsed = base::CollapseWhitespace(text, false);
|
||||||
// If the user is pasting all-whitespace, paste a single space
|
// If the user is pasting all-whitespace, paste a single space
|
||||||
// rather than nothing, since pasting nothing feels broken.
|
// rather than nothing, since pasting nothing feels broken.
|
||||||
|
@@ -20,7 +20,7 @@ bool IsProviderValid(const base::string16& provider) {
|
|||||||
return false;
|
return false;
|
||||||
for (base::string16::const_iterator it = provider.begin();
|
for (base::string16::const_iterator it = provider.begin();
|
||||||
it != provider.end(); ++it) {
|
it != provider.end(); ++it) {
|
||||||
if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it))
|
if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -26,9 +26,10 @@ bool IsHexColorString(const std::string& color_str) {
|
|||||||
const size_t* end = kValidHexColorSizes + arraysize(kValidHexColorSizes);
|
const size_t* end = kValidHexColorSizes + arraysize(kValidHexColorSizes);
|
||||||
if (std::find(kValidHexColorSizes, end, len) == end)
|
if (std::find(kValidHexColorSizes, end, len) == end)
|
||||||
return false;
|
return false;
|
||||||
for (auto ch : color_str)
|
for (auto ch : color_str) {
|
||||||
if (!IsHexDigit(ch))
|
if (!base::IsHexDigit(ch))
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -496,7 +496,7 @@ void AutofillAgent::AcceptDataListSuggestion(
|
|||||||
base::string16 last_part = parts.back();
|
base::string16 last_part = parts.back();
|
||||||
// We want to keep just the leading whitespace.
|
// We want to keep just the leading whitespace.
|
||||||
for (size_t i = 0; i < last_part.size(); ++i) {
|
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);
|
last_part = last_part.substr(0, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,7 @@ bool IsValidCreditCardNumber(const base::string16& text) {
|
|||||||
for (base::string16::reverse_iterator iter = number.rbegin();
|
for (base::string16::reverse_iterator iter = number.rbegin();
|
||||||
iter != number.rend();
|
iter != number.rend();
|
||||||
++iter) {
|
++iter) {
|
||||||
if (!IsAsciiDigit(*iter))
|
if (!base::IsAsciiDigit(*iter))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int digit = *iter - '0';
|
int digit = *iter - '0';
|
||||||
@@ -111,7 +111,7 @@ bool IsValidCreditCardSecurityCode(const base::string16& text) {
|
|||||||
for (base::string16::const_iterator iter = text.begin();
|
for (base::string16::const_iterator iter = text.begin();
|
||||||
iter != text.end();
|
iter != text.end();
|
||||||
++iter) {
|
++iter) {
|
||||||
if (!IsAsciiDigit(*iter))
|
if (!base::IsAsciiDigit(*iter))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -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
|
// Returns true for all characters which we don't want to see in the logged IDs
|
||||||
// or names of HTML elements.
|
// or names of HTML elements.
|
||||||
bool IsUnwantedInElementID(char c) {
|
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.
|
// The UTF-8 version of SavePasswordProgressLogger::ScrubElementID.
|
||||||
|
@@ -152,7 +152,7 @@ void PatternParser::Parse(const std::string& pattern_spec,
|
|||||||
} else {
|
} else {
|
||||||
// Check if the port string represents a valid port.
|
// Check if the port string represents a valid port.
|
||||||
for (size_t i = 0; i < port.size(); ++i) {
|
for (size_t i = 0; i < port.size(); ++i) {
|
||||||
if (!IsAsciiDigit(port[i])) {
|
if (!base::IsAsciiDigit(port[i])) {
|
||||||
builder->Invalid();
|
builder->Invalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,8 @@ bool VerifyInstanceID(const std::string& str) {
|
|||||||
|
|
||||||
// Checks if it is URL-safe base64 encoded.
|
// Checks if it is URL-safe base64 encoded.
|
||||||
for (auto ch : str) {
|
for (auto ch : str) {
|
||||||
if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_' && ch != '-')
|
if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) &&
|
||||||
|
ch != '_' && ch != '-')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -39,7 +39,7 @@ bool HistoryProvider::PreventInlineAutocomplete(
|
|||||||
const AutocompleteInput& input) {
|
const AutocompleteInput& input) {
|
||||||
return input.prevent_inline_autocomplete() ||
|
return input.prevent_inline_autocomplete() ||
|
||||||
(!input.text().empty() &&
|
(!input.text().empty() &&
|
||||||
IsWhitespace(input.text()[input.text().length() - 1]));
|
base::IsUnicodeWhitespace(input.text()[input.text().length() - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryProvider::HistoryProvider(AutocompleteProvider::Type type,
|
HistoryProvider::HistoryProvider(AutocompleteProvider::Type type,
|
||||||
|
@@ -194,7 +194,7 @@ ScoredHistoryMatch::ScoredHistoryMatch(
|
|||||||
// For a URL like "http://www.washingtonmutual.com", this means
|
// For a URL like "http://www.washingtonmutual.com", this means
|
||||||
// typing "w" will inline "ashington..." instead of "ww.washington...".
|
// typing "w" will inline "ashington..." instead of "ww.washington...".
|
||||||
if (!url_matches.empty() && (terms_vector.size() == 1) &&
|
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 base::string16 gurl_spec = base::UTF8ToUTF16(gurl.spec());
|
||||||
const URLPrefix* best_inlineable_prefix =
|
const URLPrefix* best_inlineable_prefix =
|
||||||
URLPrefix::BestURLPrefix(gurl_spec, terms_vector[0]);
|
URLPrefix::BestURLPrefix(gurl_spec, terms_vector[0]);
|
||||||
|
@@ -43,7 +43,7 @@ base::StringPiece ComponentString(const std::string& uri,
|
|||||||
bool ContainsOnlyAlphanumericAnd(const base::StringPiece& input,
|
bool ContainsOnlyAlphanumericAnd(const base::StringPiece& input,
|
||||||
const base::StringPiece& other_characters) {
|
const base::StringPiece& other_characters) {
|
||||||
for (char c : input) {
|
for (char c : input) {
|
||||||
if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) &&
|
if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) &&
|
||||||
other_characters.find(c) == base::StringPiece::npos)
|
other_characters.find(c) == base::StringPiece::npos)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ namespace {
|
|||||||
// Replaces all non-digits in |str| by spaces.
|
// Replaces all non-digits in |str| by spaces.
|
||||||
std::string ScrubNonDigit(std::string str) {
|
std::string ScrubNonDigit(std::string str) {
|
||||||
std::replace_if(str.begin(), str.end(),
|
std::replace_if(str.begin(), str.end(),
|
||||||
[](char c) { return !IsAsciiDigit(c); }, ' ');
|
[](char c) { return !base::IsAsciiDigit(c); }, ' ');
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,8 @@ bool IsPathNameValid(const std::string& name) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (auto c : name) {
|
for (auto c : name) {
|
||||||
if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) && c != '_' && c != '.')
|
if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) &&
|
||||||
|
c != '_' && c != '.')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -63,13 +63,13 @@ bool IsValidEncodingString(const std::string& input_encoding) {
|
|||||||
if (input_encoding.empty())
|
if (input_encoding.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!IsAsciiAlpha(input_encoding[0]))
|
if (!base::IsAsciiAlpha(input_encoding[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 1, max = input_encoding.size(); i < max; ++i) {
|
for (size_t i = 1, max = input_encoding.size(); i < max; ++i) {
|
||||||
char c = input_encoding[i];
|
char c = input_encoding[i];
|
||||||
if (!IsAsciiAlpha(c) && !IsAsciiDigit(c) && c != '.' && c != '_' &&
|
if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) &&
|
||||||
c != '-') {
|
c != '.' && c != '_' && c != '-') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -324,7 +324,7 @@ bool IsValidLanguageCode(const std::string& code) {
|
|||||||
|
|
||||||
for (std::string::const_iterator it = main_code.begin();
|
for (std::string::const_iterator it = main_code.begin();
|
||||||
it != main_code.end(); ++it) {
|
it != main_code.end(); ++it) {
|
||||||
if (!IsAsciiAlpha(*it))
|
if (!base::IsAsciiAlpha(*it))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ bool IsValidLanguageCode(const std::string& code) {
|
|||||||
|
|
||||||
for (std::string::const_iterator it = sub_code.begin();
|
for (std::string::const_iterator it = sub_code.begin();
|
||||||
it != sub_code.end(); ++it) {
|
it != sub_code.end(); ++it) {
|
||||||
if (!IsAsciiAlpha(*it))
|
if (!base::IsAsciiAlpha(*it))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -343,7 +343,7 @@ bool HasPort(const std::string& original_text,
|
|||||||
|
|
||||||
// Scan the range to see if it is entirely digits.
|
// Scan the range to see if it is entirely digits.
|
||||||
for (size_t i = port_start; i < port_end; ++i) {
|
for (size_t i = port_start; i < port_end; ++i) {
|
||||||
if (!IsAsciiDigit(original_text[i]))
|
if (!base::IsAsciiDigit(original_text[i]))
|
||||||
return false;
|
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.
|
// We need to add a scheme in order for ParseStandardURL to be happy.
|
||||||
// Find the first non-whitespace character.
|
// Find the first non-whitespace character.
|
||||||
std::string::iterator first_nonwhite = text->begin();
|
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;
|
++first_nonwhite;
|
||||||
|
|
||||||
// Construct the text to parse by inserting the scheme.
|
// Construct the text to parse by inserting the scheme.
|
||||||
|
@@ -129,7 +129,7 @@ void EmitAppCacheInfo(const GURL& base_url,
|
|||||||
out->append("<ul>");
|
out->append("<ul>");
|
||||||
EmitListItem(
|
EmitListItem(
|
||||||
kSize,
|
kSize,
|
||||||
base::UTF16ToUTF8(FormatBytesUnlocalized(info->size)),
|
base::UTF16ToUTF8(base::FormatBytesUnlocalized(info->size)),
|
||||||
out);
|
out);
|
||||||
EmitListItem(
|
EmitListItem(
|
||||||
kCreationTime,
|
kCreationTime,
|
||||||
@@ -242,7 +242,7 @@ void EmitAppCacheResourceInfoVector(
|
|||||||
iter->url, iter->response_id,
|
iter->url, iter->response_id,
|
||||||
group_id),
|
group_id),
|
||||||
false, false, out);
|
false, false, out);
|
||||||
EmitTableData(base::UTF16ToUTF8(FormatBytesUnlocalized(iter->size)),
|
EmitTableData(base::UTF16ToUTF8(base::FormatBytesUnlocalized(iter->size)),
|
||||||
true, false, out);
|
true, false, out);
|
||||||
out->append("</tr>\n");
|
out->append("</tr>\n");
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ base::FilePath::StringType StripOrdinalNumber(
|
|||||||
|
|
||||||
for (base::FilePath::StringType::size_type i = l_paren_index + 1;
|
for (base::FilePath::StringType::size_type i = l_paren_index + 1;
|
||||||
i != r_paren_index; ++i) {
|
i != r_paren_index; ++i) {
|
||||||
if (!IsAsciiDigit(pure_file_name[i]))
|
if (!base::IsAsciiDigit(pure_file_name[i]))
|
||||||
return pure_file_name;
|
return pure_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ bool HasOrdinalNumber(const base::FilePath::StringType& filename) {
|
|||||||
|
|
||||||
for (base::FilePath::StringType::size_type i = l_paren_index + 1;
|
for (base::FilePath::StringType::size_type i = l_paren_index + 1;
|
||||||
i != r_paren_index; ++i) {
|
i != r_paren_index; ++i) {
|
||||||
if (!IsAsciiDigit(filename[i]))
|
if (!base::IsAsciiDigit(filename[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -265,7 +265,8 @@ class FileSystemDirURLRequestJobTest : public testing::Test {
|
|||||||
EXPECT_EQ(icu::UnicodeString(is_directory ? "1" : "0"),
|
EXPECT_EQ(icu::UnicodeString(is_directory ? "1" : "0"),
|
||||||
match.group(3, status));
|
match.group(3, status));
|
||||||
if (size >= 0) {
|
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));
|
EXPECT_EQ(size_string, match.group(4, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -498,8 +498,8 @@ std::string PepperFileSystemBrowserHost::GeneratePluginId(
|
|||||||
// Verify |output| contains only alphabets, digits, or "._-".
|
// Verify |output| contains only alphabets, digits, or "._-".
|
||||||
for (std::string::const_iterator it = output.begin(); it != output.end();
|
for (std::string::const_iterator it = output.begin(); it != output.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '.' && *it != '_' &&
|
if (!base::IsAsciiAlpha(*it) && !base::IsAsciiDigit(*it) &&
|
||||||
*it != '-') {
|
*it != '.' && *it != '_' && *it != '-') {
|
||||||
LOG(WARNING) << "Failed to generate a plugin id.";
|
LOG(WARNING) << "Failed to generate a plugin id.";
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,7 @@ bool HouseNumberParser::IsPreDelimiter(base::char16 character) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HouseNumberParser::IsPostDelimiter(base::char16 character) {
|
bool HouseNumberParser::IsPostDelimiter(base::char16 character) {
|
||||||
return IsWhitespace(character) || strchr(",\"'", character);
|
return base::IsUnicodeWhitespace(character) || strchr(",\"'", character);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HouseNumberParser::RestartOnNextDelimiter() {
|
void HouseNumberParser::RestartOnNextDelimiter() {
|
||||||
@@ -144,7 +144,7 @@ bool HouseNumberParser::Parse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// More digits. There should be no more after a letter was found.
|
// More digits. There should be no more after a letter was found.
|
||||||
if (IsAsciiDigit(*it_)) {
|
if (base::IsAsciiDigit(*it_)) {
|
||||||
if (num_digits_ >= kMaxHouseDigits) {
|
if (num_digits_ >= kMaxHouseDigits) {
|
||||||
RestartOnNextDelimiter();
|
RestartOnNextDelimiter();
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +154,7 @@ bool HouseNumberParser::Parse(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsAsciiAlpha(*it_)) {
|
if (base::IsAsciiAlpha(*it_)) {
|
||||||
// Handle special case 'one'.
|
// Handle special case 'one'.
|
||||||
if (result_chars_ == 0) {
|
if (result_chars_ == 0) {
|
||||||
if (it_ + 3 <= end_ && base::LowerCaseEqualsASCII(it_, it_ + 3, "one"))
|
if (it_ + 3 <= end_ && base::LowerCaseEqualsASCII(it_, it_ + 3, "one"))
|
||||||
@@ -168,7 +168,7 @@ bool HouseNumberParser::Parse(
|
|||||||
DCHECK_GT(result_chars_, 0U);
|
DCHECK_GT(result_chars_, 0U);
|
||||||
DCHECK(it_ != begin_);
|
DCHECK(it_ != begin_);
|
||||||
base::char16 previous = SafePreviousChar(it_, begin_);
|
base::char16 previous = SafePreviousChar(it_, begin_);
|
||||||
if (IsAsciiDigit(previous)) {
|
if (base::IsAsciiDigit(previous)) {
|
||||||
// Check cases like '12A'.
|
// Check cases like '12A'.
|
||||||
base::char16 next = SafeNextChar(it_, end_);
|
base::char16 next = SafeNextChar(it_, end_);
|
||||||
if (IsPostDelimiter(next)) {
|
if (IsPostDelimiter(next)) {
|
||||||
@@ -177,7 +177,7 @@ bool HouseNumberParser::Parse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle cases like 12a, 1st, 2nd, 3rd, 7th.
|
// Handle cases like 12a, 1st, 2nd, 3rd, 7th.
|
||||||
if (IsAsciiAlpha(next)) {
|
if (base::IsAsciiAlpha(next)) {
|
||||||
base::char16 last_digit = previous;
|
base::char16 last_digit = previous;
|
||||||
base::char16 first_letter = base::ToLowerASCII(*it_);
|
base::char16 first_letter = base::ToLowerASCII(*it_);
|
||||||
base::char16 second_letter = base::ToLowerASCII(next);
|
base::char16 second_letter = base::ToLowerASCII(next);
|
||||||
@@ -350,7 +350,7 @@ bool FindStateStartingInWord(WordList* words,
|
|||||||
|
|
||||||
const Word& first_word = words->at(state_first_word);
|
const Word& first_word = words->at(state_first_word);
|
||||||
int length = first_word.end - first_word.begin;
|
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;
|
return false;
|
||||||
|
|
||||||
// No state names start with x, y, z.
|
// No state names start with x, y, z.
|
||||||
@@ -362,7 +362,7 @@ bool FindStateStartingInWord(WordList* words,
|
|||||||
int first_index = first_letter - 'a';
|
int first_index = first_letter - 'a';
|
||||||
|
|
||||||
// Look for two-letter state names.
|
// 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));
|
base::char16 second_letter = base::ToLowerASCII(*(first_word.begin + 1));
|
||||||
DCHECK(second_letter >= 'a');
|
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) {
|
for (base::string16::const_iterator it = word.begin; it != word.end; ++it) {
|
||||||
size_t pos = it - word.begin;
|
size_t pos = it - word.begin;
|
||||||
if (IsAsciiDigit(*it) || (*it == '-' && pos == kZipDigits))
|
if (base::IsAsciiDigit(*it) || (*it == '-' && pos == kZipDigits))
|
||||||
continue;
|
continue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -503,8 +503,8 @@ bool IsZipValidForState(const Word& word, size_t state_index) {
|
|||||||
|
|
||||||
// Zip numeric value for the first two characters.
|
// Zip numeric value for the first two characters.
|
||||||
DCHECK(word.begin != word.end);
|
DCHECK(word.begin != word.end);
|
||||||
DCHECK(IsAsciiDigit(*word.begin));
|
DCHECK(base::IsAsciiDigit(*word.begin));
|
||||||
DCHECK(IsAsciiDigit(*(word.begin + 1)));
|
DCHECK(base::IsAsciiDigit(*(word.begin + 1)));
|
||||||
int zip_prefix = (*word.begin - '0') * 10 + (*(word.begin + 1) - '0');
|
int zip_prefix = (*word.begin - '0') * 10 + (*(word.begin + 1) - '0');
|
||||||
|
|
||||||
if ((zip_prefix >= zip_range[state_index].low &&
|
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],
|
location_names_accumulative[arraysize(location_names_accumulative) - 1],
|
||||||
static_cast<int>(arraysize(location_names)));
|
static_cast<int>(arraysize(location_names)));
|
||||||
|
|
||||||
if (!IsAsciiAlpha(*word.begin))
|
if (!base::IsAsciiAlpha(*word.begin))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// No location names start with y, z.
|
// No location names start with y, z.
|
||||||
|
@@ -26,7 +26,7 @@ bool IsValidIconWidthOrHeight(const std::string& str) {
|
|||||||
if (str.empty() || str[0] == '0')
|
if (str.empty() || str[0] == '0')
|
||||||
return false;
|
return false;
|
||||||
for (size_t i = 0; i < str.size(); ++i)
|
for (size_t i = 0; i < str.size(); ++i)
|
||||||
if (!IsAsciiDigit(str[i]))
|
if (!base::IsAsciiDigit(str[i]))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -241,7 +241,7 @@ std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) {
|
|||||||
|
|
||||||
canonicalized[i] = ':';
|
canonicalized[i] = ':';
|
||||||
} else {
|
} else {
|
||||||
if (!IsHexDigit(canonicalized[i]))
|
if (!base::IsHexDigit(canonicalized[i]))
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
canonicalized[i] = base::ToUpperASCII(canonicalized[i]);
|
canonicalized[i] = base::ToUpperASCII(canonicalized[i]);
|
||||||
|
@@ -40,7 +40,7 @@ void GetCanonicalUuid(std::string uuid,
|
|||||||
if (uuid[i] != '-')
|
if (uuid[i] != '-')
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!IsHexDigit(uuid[i]))
|
if (!base::IsHexDigit(uuid[i]))
|
||||||
return;
|
return;
|
||||||
uuid[i] = base::ToLowerASCII(uuid[i]);
|
uuid[i] = base::ToLowerASCII(uuid[i]);
|
||||||
}
|
}
|
||||||
|
@@ -171,8 +171,8 @@ std::string UdevDecodeString(const std::string& encoded) {
|
|||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
char c = encoded[i];
|
char c = encoded[i];
|
||||||
if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') {
|
if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') {
|
||||||
c = (HexDigitToInt(encoded[i + 2]) << 4) +
|
c = (base::HexDigitToInt(encoded[i + 2]) << 4) +
|
||||||
HexDigitToInt(encoded[i + 3]);
|
base::HexDigitToInt(encoded[i + 3]);
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
decoded.push_back(c);
|
decoded.push_back(c);
|
||||||
|
@@ -25,7 +25,7 @@ bool IsValidNonEmptyHexString(const std::string& input) {
|
|||||||
if (count == 0 || (count % 2) != 0)
|
if (count == 0 || (count % 2) != 0)
|
||||||
return false;
|
return false;
|
||||||
for (const char& c : input)
|
for (const char& c : input)
|
||||||
if (!IsHexDigit<char>(c))
|
if (!base::IsHexDigit<char>(c))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ bool CheckIPCIDRSanity(const std::string& value, bool cidr, bool ipv6) {
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
for (const auto& elem : value) {
|
for (const auto& elem : value) {
|
||||||
if (IsAsciiDigit(elem)) {
|
if (base::IsAsciiDigit(elem)) {
|
||||||
counter++;
|
counter++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ bool CheckIPCIDRSanity(const std::string& value, bool cidr, bool ipv6) {
|
|||||||
if (!colon)
|
if (!colon)
|
||||||
return false;
|
return false;
|
||||||
colon--;
|
colon--;
|
||||||
} else if (!hex_allowed || !IsHexDigit(elem)) {
|
} else if (!hex_allowed || !base::IsHexDigit(elem)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
counter++;
|
counter++;
|
||||||
|
@@ -35,7 +35,7 @@ bool GetDeclarationValue(const base::StringPiece& line,
|
|||||||
std::string temp(line.data() + index + prefix.length(),
|
std::string temp(line.data() + index + prefix.length(),
|
||||||
line.length() - index - prefix.length());
|
line.length() - index - prefix.length());
|
||||||
|
|
||||||
if (temp.empty() || !IsWhitespace(temp[0]))
|
if (temp.empty() || !base::IsUnicodeWhitespace(temp[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
base::TrimWhitespaceASCII(temp, base::TRIM_ALL, value);
|
base::TrimWhitespaceASCII(temp, base::TRIM_ALL, value);
|
||||||
|
@@ -83,7 +83,7 @@ bool isNonWildcardTLD(const std::string& url,
|
|||||||
// ":123456" or ":****" as valid, but that does not matter because the
|
// ":123456" or ":****" as valid, but that does not matter because the
|
||||||
// relaxing CSP directive will just be ignored by Blink.
|
// relaxing CSP directive will just be ignored by Blink.
|
||||||
for (size_t i = start_of_port + 1; i < end_of_host; ++i) {
|
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)
|
if (!is_valid_port)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -281,7 +281,8 @@ bool MessageBundle::IsValidName(const std::string& name) {
|
|||||||
std::string::const_iterator it = name.begin();
|
std::string::const_iterator it = name.begin();
|
||||||
for (; it != name.end(); ++it) {
|
for (; it != name.end(); ++it) {
|
||||||
// Allow only ascii 0-9, a-z, A-Z, and _ in the name.
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,8 +28,8 @@ const uint16 kWildcardPortNumber = 0;
|
|||||||
const uint16 kInvalidPort = 65535;
|
const uint16 kInvalidPort = 65535;
|
||||||
|
|
||||||
bool StartsOrEndsWithWhitespace(const std::string& str) {
|
bool StartsOrEndsWithWhitespace(const std::string& str) {
|
||||||
return !str.empty() &&
|
return !str.empty() && (base::IsUnicodeWhitespace(str[0]) ||
|
||||||
(IsWhitespace(str[0]) || IsWhitespace(str[str.length() - 1]));
|
base::IsUnicodeWhitespace(str[str.length() - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -322,7 +322,7 @@ bool OAuthRequestSigner::Decode(const std::string& text,
|
|||||||
DCHECK(low >= 0 || low < kHexBase);
|
DCHECK(low >= 0 || low < kHexBase);
|
||||||
|
|
||||||
char decoded = static_cast<char>(high * kHexBase + low);
|
char decoded = static_cast<char>(high * kHexBase + low);
|
||||||
DCHECK(!(IsAsciiAlpha(decoded) || IsAsciiDigit(decoded)));
|
DCHECK(!(base::IsAsciiAlpha(decoded) || base::IsAsciiDigit(decoded)));
|
||||||
DCHECK(!(decoded && strchr("-._~", decoded)));
|
DCHECK(!(decoded && strchr("-._~", decoded)));
|
||||||
accumulator += decoded;
|
accumulator += decoded;
|
||||||
} else {
|
} else {
|
||||||
@@ -340,7 +340,7 @@ std::string OAuthRequestSigner::Encode(const std::string& text) {
|
|||||||
std::string::const_iterator limit;
|
std::string::const_iterator limit;
|
||||||
for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) {
|
for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) {
|
||||||
char character = *cursor;
|
char character = *cursor;
|
||||||
if (IsAsciiAlpha(character) || IsAsciiDigit(character)) {
|
if (base::IsAsciiAlpha(character) || base::IsAsciiDigit(character)) {
|
||||||
result += character;
|
result += character;
|
||||||
} else {
|
} else {
|
||||||
switch (character) {
|
switch (character) {
|
||||||
|
@@ -495,7 +495,7 @@ void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
|
|||||||
// equal to the specified level."
|
// equal to the specified level."
|
||||||
static bool IsValidH264BaselineProfile(const std::string& profile_str) {
|
static bool IsValidH264BaselineProfile(const std::string& profile_str) {
|
||||||
return (profile_str.size() == 4 && profile_str[0] == '4' &&
|
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');
|
profile_str[3] == '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -170,7 +170,7 @@ static bool SanitizeSessionId(const blink::WebString& session_id,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (const char c : *sanitized_session_id) {
|
for (const char c : *sanitized_session_id) {
|
||||||
if (!IsAsciiAlpha(c) && !IsAsciiDigit(c))
|
if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,7 +106,7 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type,
|
|||||||
if (base64_encoded || !(mime_type->compare(0, 5, "text/") == 0 ||
|
if (base64_encoded || !(mime_type->compare(0, 5, "text/") == 0 ||
|
||||||
mime_type->find("xml") != std::string::npos)) {
|
mime_type->find("xml") != std::string::npos)) {
|
||||||
temp_data.erase(std::remove_if(temp_data.begin(), temp_data.end(),
|
temp_data.erase(std::remove_if(temp_data.begin(), temp_data.end(),
|
||||||
IsAsciiWhitespace<wchar_t>),
|
base::IsAsciiWhitespace<wchar_t>),
|
||||||
temp_data.end());
|
temp_data.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ std::string Escape(const std::string& text,
|
|||||||
if (use_plus && ' ' == c) {
|
if (use_plus && ' ' == c) {
|
||||||
escaped.push_back('+');
|
escaped.push_back('+');
|
||||||
} else if (keep_escaped && '%' == c && i + 2 < text.length() &&
|
} 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('%');
|
escaped.push_back('%');
|
||||||
} else if (charmap.Contains(c)) {
|
} else if (charmap.Contains(c)) {
|
||||||
escaped.push_back('%');
|
escaped.push_back('%');
|
||||||
@@ -118,9 +118,9 @@ bool UnescapeUnsignedCharAtIndex(const STR& escaped_text,
|
|||||||
static_cast<typename STR::value_type>(escaped_text[index + 1]));
|
static_cast<typename STR::value_type>(escaped_text[index + 1]));
|
||||||
const typename STR::value_type least_sig_digit(
|
const typename STR::value_type least_sig_digit(
|
||||||
static_cast<typename STR::value_type>(escaped_text[index + 2]));
|
static_cast<typename STR::value_type>(escaped_text[index + 2]));
|
||||||
if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) {
|
if (base::IsHexDigit(most_sig_digit) && base::IsHexDigit(least_sig_digit)) {
|
||||||
*value = HexDigitToInt(most_sig_digit) * 16 +
|
*value = base::HexDigitToInt(most_sig_digit) * 16 +
|
||||||
HexDigitToInt(least_sig_digit);
|
base::HexDigitToInt(least_sig_digit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -405,7 +405,7 @@ static bool SniffForHTML(const char* content,
|
|||||||
const char* const end = content + size;
|
const char* const end = content + size;
|
||||||
const char* pos;
|
const char* pos;
|
||||||
for (pos = content; pos < end; ++pos) {
|
for (pos = content; pos < end; ++pos) {
|
||||||
if (!IsAsciiWhitespace(*pos))
|
if (!base::IsAsciiWhitespace(*pos))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
static base::HistogramBase* counter(NULL);
|
static base::HistogramBase* counter(NULL);
|
||||||
|
@@ -341,7 +341,7 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) {
|
|||||||
// Overflow is still possible for evil user inputs.
|
// Overflow is still possible for evil user inputs.
|
||||||
for (size_t i = 0; i <= size; ++i) {
|
for (size_t i = 0; i <= size; ++i) {
|
||||||
// The string should be composed of only digits and commas.
|
// 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))
|
(allowed_ports[i] != kComma))
|
||||||
return;
|
return;
|
||||||
if (i == size || allowed_ports[i] == kComma) {
|
if (i == size || allowed_ports[i] == kComma) {
|
||||||
|
@@ -610,7 +610,7 @@ std::string GetDirectoryListingEntry(const base::string16& name,
|
|||||||
// Negative size means unknown or not applicable (e.g. directory).
|
// Negative size means unknown or not applicable (e.g. directory).
|
||||||
base::string16 size_string;
|
base::string16 size_string;
|
||||||
if (size >= 0)
|
if (size >= 0)
|
||||||
size_string = FormatBytesUnlocalized(size);
|
size_string = base::FormatBytesUnlocalized(size);
|
||||||
base::EscapeJSONString(size_string, true, &result);
|
base::EscapeJSONString(size_string, true, &result);
|
||||||
|
|
||||||
result.append(",");
|
result.append(",");
|
||||||
|
@@ -118,7 +118,7 @@ base::Time ParseCookieTime(const std::string& time_string) {
|
|||||||
while (tokenizer.GetNext()) {
|
while (tokenizer.GetNext()) {
|
||||||
const std::string token = tokenizer.token();
|
const std::string token = tokenizer.token();
|
||||||
DCHECK(!token.empty());
|
DCHECK(!token.empty());
|
||||||
bool numerical = IsAsciiDigit(token[0]);
|
bool numerical = base::IsAsciiDigit(token[0]);
|
||||||
|
|
||||||
// String field
|
// String field
|
||||||
if (!numerical) {
|
if (!numerical) {
|
||||||
|
@@ -34,11 +34,11 @@ bool DecodeQEncoding(const std::string& input, std::string* output) {
|
|||||||
temp.push_back(' ');
|
temp.push_back(' ');
|
||||||
} else if (*it == '=') {
|
} else if (*it == '=') {
|
||||||
if ((input.end() - it < 3) ||
|
if ((input.end() - it < 3) ||
|
||||||
!IsHexDigit(static_cast<unsigned char>(*(it + 1))) ||
|
!base::IsHexDigit(static_cast<unsigned char>(*(it + 1))) ||
|
||||||
!IsHexDigit(static_cast<unsigned char>(*(it + 2))))
|
!base::IsHexDigit(static_cast<unsigned char>(*(it + 2))))
|
||||||
return false;
|
return false;
|
||||||
unsigned char ch = HexDigitToInt(*(it + 1)) * 16 +
|
unsigned char ch =
|
||||||
HexDigitToInt(*(it + 2));
|
base::HexDigitToInt(*(it + 1)) * 16 + base::HexDigitToInt(*(it + 2));
|
||||||
temp.push_back(static_cast<char>(ch));
|
temp.push_back(static_cast<char>(ch));
|
||||||
++it;
|
++it;
|
||||||
++it;
|
++it;
|
||||||
|
@@ -197,7 +197,7 @@ bool ParseHSTSHeader(const std::string& value,
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case START:
|
case START:
|
||||||
case DIRECTIVE_END:
|
case DIRECTIVE_END:
|
||||||
if (IsAsciiWhitespace(*tokenizer.token_begin()))
|
if (base::IsAsciiWhitespace(*tokenizer.token_begin()))
|
||||||
continue;
|
continue;
|
||||||
if (base::LowerCaseEqualsASCII(tokenizer.token(), "max-age")) {
|
if (base::LowerCaseEqualsASCII(tokenizer.token(), "max-age")) {
|
||||||
state = AFTER_MAX_AGE_LABEL;
|
state = AFTER_MAX_AGE_LABEL;
|
||||||
@@ -213,7 +213,7 @@ bool ParseHSTSHeader(const std::string& value,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AFTER_MAX_AGE_LABEL:
|
case AFTER_MAX_AGE_LABEL:
|
||||||
if (IsAsciiWhitespace(*tokenizer.token_begin()))
|
if (base::IsAsciiWhitespace(*tokenizer.token_begin()))
|
||||||
continue;
|
continue;
|
||||||
if (*tokenizer.token_begin() != '=')
|
if (*tokenizer.token_begin() != '=')
|
||||||
return false;
|
return false;
|
||||||
@@ -222,7 +222,7 @@ bool ParseHSTSHeader(const std::string& value,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AFTER_MAX_AGE_EQUALS:
|
case AFTER_MAX_AGE_EQUALS:
|
||||||
if (IsAsciiWhitespace(*tokenizer.token_begin()))
|
if (base::IsAsciiWhitespace(*tokenizer.token_begin()))
|
||||||
continue;
|
continue;
|
||||||
unquoted = HttpUtil::Unquote(tokenizer.token());
|
unquoted = HttpUtil::Unquote(tokenizer.token());
|
||||||
if (!MaxAgeToInt(unquoted.begin(), unquoted.end(), &max_age_candidate))
|
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_MAX_AGE:
|
||||||
case AFTER_INCLUDE_SUBDOMAINS:
|
case AFTER_INCLUDE_SUBDOMAINS:
|
||||||
if (IsAsciiWhitespace(*tokenizer.token_begin()))
|
if (base::IsAsciiWhitespace(*tokenizer.token_begin()))
|
||||||
continue;
|
continue;
|
||||||
else if (*tokenizer.token_begin() == ';')
|
else if (*tokenizer.token_begin() == ';')
|
||||||
state = DIRECTIVE_END;
|
state = DIRECTIVE_END;
|
||||||
|
@@ -18,7 +18,7 @@ namespace {
|
|||||||
// The function checks for '\0' for string termination.
|
// The function checks for '\0' for string termination.
|
||||||
int HexDigitsPrefix(const char* buf, int num_digits) {
|
int HexDigitsPrefix(const char* buf, int num_digits) {
|
||||||
for (int i = 0; i < num_digits; i++) {
|
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 0; // This also detects end of string as '\0' is not xdigit.
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -87,7 +87,7 @@ std::string UrlUtilities::Unescape(const std::string& escaped_url) {
|
|||||||
++iter;
|
++iter;
|
||||||
break;
|
break;
|
||||||
case ESCAPE1:
|
case ESCAPE1:
|
||||||
if (IsHexDigit(c)) {
|
if (base::IsHexDigit(c)) {
|
||||||
escape_text.push_back(c);
|
escape_text.push_back(c);
|
||||||
state = ESCAPE2;
|
state = ESCAPE2;
|
||||||
++iter;
|
++iter;
|
||||||
@@ -98,7 +98,7 @@ std::string UrlUtilities::Unescape(const std::string& escaped_url) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESCAPE2:
|
case ESCAPE2:
|
||||||
if (IsHexDigit(c)) {
|
if (base::IsHexDigit(c)) {
|
||||||
escape_text.push_back(c);
|
escape_text.push_back(c);
|
||||||
bool ok = base::HexStringToInt(escape_text, &escape_value);
|
bool ok = base::HexStringToInt(escape_text, &escape_value);
|
||||||
DCHECK(ok);
|
DCHECK(ok);
|
||||||
|
@@ -472,7 +472,7 @@ void FormatStringWithHyphens(base::string16* text) {
|
|||||||
current_hyphen_position = HyphenPosition();
|
current_hyphen_position = HyphenPosition();
|
||||||
current_hyphen_position.position = i;
|
current_hyphen_position.position = i;
|
||||||
current_hyphen_position_is_valid = true;
|
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_hyphen_position_is_valid) {
|
||||||
if (current_char != L'\r' && current_char != L'\n')
|
if (current_char != L'\r' && current_char != L'\n')
|
||||||
current_hyphen_position.next_whitespace_position = i;
|
current_hyphen_position.next_whitespace_position = i;
|
||||||
|
@@ -58,7 +58,7 @@ bool IsAccessPointSupported(rlz_lib::AccessPoint point) {
|
|||||||
// We will be more liberal and allow some additional chars, but not url meta
|
// We will be more liberal and allow some additional chars, but not url meta
|
||||||
// chars.
|
// chars.
|
||||||
bool IsGoodRlzChar(const char ch) {
|
bool IsGoodRlzChar(const char ch) {
|
||||||
if (IsAsciiAlpha(ch) || IsAsciiDigit(ch))
|
if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@@ -29,7 +29,7 @@ const wchar_t kDccValueName[] = L"DCC";
|
|||||||
// We will be more liberal and allow some additional chars, but not url meta
|
// We will be more liberal and allow some additional chars, but not url meta
|
||||||
// chars.
|
// chars.
|
||||||
bool IsGoodDccChar(char ch) {
|
bool IsGoodDccChar(char ch) {
|
||||||
if (IsAsciiAlpha(ch) || IsAsciiDigit(ch))
|
if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@@ -812,7 +812,7 @@ int Connection::ExecuteAndReturnErrorCode(const char* sql) {
|
|||||||
// sqlite3_exec() does this, presumably to avoid spinning the parser for
|
// sqlite3_exec() does this, presumably to avoid spinning the parser for
|
||||||
// trailing whitespace.
|
// trailing whitespace.
|
||||||
// TODO(shess): Audit to see if this can become a DCHECK.
|
// TODO(shess): Audit to see if this can become a DCHECK.
|
||||||
while (IsAsciiWhitespace(*sql)) {
|
while (base::IsAsciiWhitespace(*sql)) {
|
||||||
sql++;
|
sql++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,8 +19,8 @@ bool IsSafeSuffix(const base::string16& suffix) {
|
|||||||
for (base::string16::const_iterator it = suffix.begin();
|
for (base::string16::const_iterator it = suffix.begin();
|
||||||
it < suffix.end(); ++it) {
|
it < suffix.end(); ++it) {
|
||||||
base::char16 c = *it;
|
base::char16 c = *it;
|
||||||
if (!(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
|
if (!(base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) ||
|
||||||
c == '-' || c == '.' || c == '_')) {
|
c == '-' || c == '.' || c == '_')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (c == '.' && prev_c == '.')
|
if (c == '.' && prev_c == '.')
|
||||||
|
@@ -36,7 +36,7 @@ std::string GetHardwareModelName() {
|
|||||||
size_t length = sizeof(modelBuffer);
|
size_t length = sizeof(modelBuffer);
|
||||||
if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) {
|
if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) {
|
||||||
for (size_t i = 0; i < length; i++) {
|
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, i);
|
||||||
}
|
}
|
||||||
return std::string(modelBuffer, 0, length);
|
return std::string(modelBuffer, 0, length);
|
||||||
|
@@ -37,7 +37,7 @@ const char kSwitchShort[] = "short";
|
|||||||
bool DoesLineBeginWithComment(const base::StringPiece& line) {
|
bool DoesLineBeginWithComment(const base::StringPiece& line) {
|
||||||
// Skip whitespace.
|
// Skip whitespace.
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (i < line.size() && IsAsciiWhitespace(line[i]))
|
while (i < line.size() && base::IsAsciiWhitespace(line[i]))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
return i < line.size() && line[i] == '#';
|
return i < line.size() && line[i] == '#';
|
||||||
|
@@ -100,7 +100,7 @@ bool DoesBeginWindowsDriveLetter(const base::StringPiece& path) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check drive letter.
|
// Check drive letter.
|
||||||
if (!IsAsciiAlpha(path[0]))
|
if (!base::IsAsciiAlpha(path[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!IsSlash(path[2]))
|
if (!IsSlash(path[2]))
|
||||||
|
@@ -105,7 +105,7 @@ bool Resolve(const SourceDir& current_dir,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (input.size() > 3 && input[2] == ':' && IsSlash(input[3]) &&
|
if (input.size() > 3 && input[2] == ':' && IsSlash(input[3]) &&
|
||||||
IsAsciiAlpha(input[1])) {
|
base::IsAsciiAlpha(input[1])) {
|
||||||
// Skip over the drive letter colon.
|
// Skip over the drive letter colon.
|
||||||
offset = 3;
|
offset = 3;
|
||||||
}
|
}
|
||||||
|
@@ -132,7 +132,7 @@ LabelPattern LabelPattern::GetPattern(const SourceDir& current_dir,
|
|||||||
return LabelPattern();
|
return LabelPattern();
|
||||||
}
|
}
|
||||||
if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) &&
|
if (str.size() > 3 && str[2] == ':' && IsSlash(str[3]) &&
|
||||||
IsAsciiAlpha(str[1])) {
|
base::IsAsciiAlpha(str[1])) {
|
||||||
// Skip over the drive letter colon.
|
// Skip over the drive letter colon.
|
||||||
offset = 3;
|
offset = 3;
|
||||||
}
|
}
|
||||||
|
@@ -188,7 +188,7 @@ void Tokenizer::AdvanceToNextToken() {
|
|||||||
Token::Type Tokenizer::ClassifyCurrent() const {
|
Token::Type Tokenizer::ClassifyCurrent() const {
|
||||||
DCHECK(!at_end());
|
DCHECK(!at_end());
|
||||||
char next_char = cur_char();
|
char next_char = cur_char();
|
||||||
if (IsAsciiDigit(next_char))
|
if (base::IsAsciiDigit(next_char))
|
||||||
return Token::INTEGER;
|
return Token::INTEGER;
|
||||||
if (next_char == '"')
|
if (next_char == '"')
|
||||||
return Token::STRING;
|
return Token::STRING;
|
||||||
@@ -228,7 +228,7 @@ Token::Type Tokenizer::ClassifyCurrent() const {
|
|||||||
return Token::UNCLASSIFIED_OPERATOR; // Just the minus before end of
|
return Token::UNCLASSIFIED_OPERATOR; // Just the minus before end of
|
||||||
// file.
|
// file.
|
||||||
char following_char = input_[cur_ + 1];
|
char following_char = input_[cur_ + 1];
|
||||||
if (IsAsciiDigit(following_char))
|
if (base::IsAsciiDigit(following_char))
|
||||||
return Token::INTEGER;
|
return Token::INTEGER;
|
||||||
return Token::UNCLASSIFIED_OPERATOR;
|
return Token::UNCLASSIFIED_OPERATOR;
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ void Tokenizer::AdvanceToEndOfToken(const Location& location,
|
|||||||
case Token::INTEGER:
|
case Token::INTEGER:
|
||||||
do {
|
do {
|
||||||
Advance();
|
Advance();
|
||||||
} while (!at_end() && IsAsciiDigit(cur_char()));
|
} while (!at_end() && base::IsAsciiDigit(cur_char()));
|
||||||
if (!at_end()) {
|
if (!at_end()) {
|
||||||
// Require the char after a number to be some kind of space, scope,
|
// Require the char after a number to be some kind of space, scope,
|
||||||
// or operator.
|
// or operator.
|
||||||
|
@@ -33,12 +33,12 @@ class Tokenizer {
|
|||||||
static bool IsNewline(const base::StringPiece& buffer, size_t offset);
|
static bool IsNewline(const base::StringPiece& buffer, size_t offset);
|
||||||
|
|
||||||
static bool IsIdentifierFirstChar(char c) {
|
static bool IsIdentifierFirstChar(char c) {
|
||||||
return IsAsciiAlpha(c) || c == '_';
|
return base::IsAsciiAlpha(c) || c == '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsIdentifierContinuingChar(char c) {
|
static bool IsIdentifierContinuingChar(char c) {
|
||||||
// Also allow digits after the first char.
|
// Also allow digits after the first char.
|
||||||
return IsIdentifierFirstChar(c) || IsAsciiDigit(c);
|
return IsIdentifierFirstChar(c) || base::IsAsciiDigit(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -62,7 +62,7 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
|
|||||||
NOTREACHED(); // These are handled above.
|
NOTREACHED(); // These are handled above.
|
||||||
break;
|
break;
|
||||||
case WORD_BOUNDARY:
|
case WORD_BOUNDARY:
|
||||||
if (IsWhitespace(text[pos]))
|
if (base::IsUnicodeWhitespace(text[pos]))
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
case PARAGRAPH_BOUNDARY:
|
case PARAGRAPH_BOUNDARY:
|
||||||
@@ -71,7 +71,8 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
|
|||||||
break;
|
break;
|
||||||
case SENTENCE_BOUNDARY:
|
case SENTENCE_BOUNDARY:
|
||||||
if ((text[pos] == '.' || text[pos] == '!' || text[pos] == '?') &&
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -54,7 +54,7 @@ const base::string16 TermBreakIterator::GetCurrentTerm() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TermBreakIterator::State TermBreakIterator::GetNewState(base::char16 ch) {
|
TermBreakIterator::State TermBreakIterator::GetNewState(base::char16 ch) {
|
||||||
if (IsAsciiDigit(ch) || ch == '.' || ch == ',')
|
if (base::IsAsciiDigit(ch) || ch == '.' || ch == ',')
|
||||||
return STATE_NUMBER;
|
return STATE_NUMBER;
|
||||||
|
|
||||||
const bool is_upper = !!u_isUUppercase(ch);
|
const bool is_upper = !!u_isUUppercase(ch);
|
||||||
|
@@ -228,7 +228,7 @@ base::string16 Accelerator::GetShortcutText() const {
|
|||||||
base::string16 shortcut_rtl;
|
base::string16 shortcut_rtl;
|
||||||
bool adjust_shortcut_for_rtl = false;
|
bool adjust_shortcut_for_rtl = false;
|
||||||
if (base::i18n::IsRTL() && shortcut.length() == 1 &&
|
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;
|
adjust_shortcut_for_rtl = true;
|
||||||
shortcut_rtl.assign(shortcut);
|
shortcut_rtl.assign(shortcut);
|
||||||
}
|
}
|
||||||
|
@@ -614,7 +614,7 @@ bool IsValidLocaleSyntax(const std::string& locale) {
|
|||||||
// underscore.
|
// underscore.
|
||||||
for (size_t i = 0; i < prefix.size(); i++) {
|
for (size_t i = 0; i < prefix.size(); i++) {
|
||||||
char ch = prefix[i];
|
char ch = prefix[i];
|
||||||
if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_')
|
if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) && ch != '_')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +627,7 @@ bool IsValidLocaleSyntax(const std::string& locale) {
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!IsAsciiAlpha(ch))
|
if (!base::IsAsciiAlpha(ch))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ std::string GetCurrentTimeForLogging() {
|
|||||||
std::string GetCanonicalDeviceName(const std::string& name) {
|
std::string GetCanonicalDeviceName(const std::string& name) {
|
||||||
std::string ret(name);
|
std::string ret(name);
|
||||||
for (size_t i = 0; i < ret.size(); ++i)
|
for (size_t i = 0; i < ret.size(); ++i)
|
||||||
if (!IsAsciiAlpha(ret[i]))
|
if (!base::IsAsciiAlpha(ret[i]))
|
||||||
ret[i] = '_';
|
ret[i] = '_';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user