OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <stdarg.h> | 10 #include <stdarg.h> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 }; | 92 }; |
93 #if defined(WCHAR_T_IS_UTF32) | 93 #if defined(WCHAR_T_IS_UTF32) |
94 template<> struct NonASCIIMask<4, wchar_t> { | 94 template<> struct NonASCIIMask<4, wchar_t> { |
95 static inline uint32_t value() { return 0xFFFFFF80U; } | 95 static inline uint32_t value() { return 0xFFFFFF80U; } |
96 }; | 96 }; |
97 template<> struct NonASCIIMask<8, wchar_t> { | 97 template<> struct NonASCIIMask<8, wchar_t> { |
98 static inline uint64_t value() { return 0xFFFFFF80FFFFFF80ULL; } | 98 static inline uint64_t value() { return 0xFFFFFF80FFFFFF80ULL; } |
99 }; | 99 }; |
100 #endif // WCHAR_T_IS_UTF32 | 100 #endif // WCHAR_T_IS_UTF32 |
101 | 101 |
102 // DO NOT USE. http://crbug.com/24917 | |
103 // | |
104 // tolower() will given incorrect results for non-ASCII characters. Use the | |
105 // ASCII version, base::i18n::ToLower, or base::i18n::FoldCase. This is here | |
106 // for backwards-compat for StartsWith until such calls can be updated. | |
107 struct CaseInsensitiveCompareDeprecated { | |
108 public: | |
109 bool operator()(char16 x, char16 y) const { | |
110 return tolower(x) == tolower(y); | |
111 } | |
112 }; | |
113 | |
114 } // namespace | 102 } // namespace |
115 | 103 |
116 bool IsWprintfFormatPortable(const wchar_t* format) { | 104 bool IsWprintfFormatPortable(const wchar_t* format) { |
117 for (const wchar_t* position = format; *position != '\0'; ++position) { | 105 for (const wchar_t* position = format; *position != '\0'; ++position) { |
118 if (*position == '%') { | 106 if (*position == '%') { |
119 bool in_specification = true; | 107 bool in_specification = true; |
120 bool modifier_l = false; | 108 bool modifier_l = false; |
121 while (in_specification) { | 109 while (in_specification) { |
122 // Eat up characters until reaching a known specifier. | 110 // Eat up characters until reaching a known specifier. |
123 if (*++position == '\0') { | 111 if (*++position == '\0') { |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 } // namespace | 997 } // namespace |
1010 | 998 |
1011 size_t strlcpy(char* dst, const char* src, size_t dst_size) { | 999 size_t strlcpy(char* dst, const char* src, size_t dst_size) { |
1012 return lcpyT<char>(dst, src, dst_size); | 1000 return lcpyT<char>(dst, src, dst_size); |
1013 } | 1001 } |
1014 size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 1002 size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
1015 return lcpyT<wchar_t>(dst, src, dst_size); | 1003 return lcpyT<wchar_t>(dst, src, dst_size); |
1016 } | 1004 } |
1017 | 1005 |
1018 } // namespace base | 1006 } // namespace base |
OLD | NEW |