OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 5 #include "base/string_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 }; | 234 }; |
235 | 235 |
236 class WStringToDoubleTraits { | 236 class WStringToDoubleTraits { |
237 public: | 237 public: |
238 typedef std::wstring string_type; | 238 typedef std::wstring string_type; |
239 typedef double value_type; | 239 typedef double value_type; |
240 static inline value_type convert_func(const string_type::value_type* str, | 240 static inline value_type convert_func(const string_type::value_type* str, |
241 string_type::value_type** endptr, | 241 string_type::value_type** endptr, |
242 bool locale_dependent) { | 242 bool locale_dependent) { |
243 if (base::LOCALE_DEPENDENT == locale_dependent) { | 243 if (locale_dependent) { |
244 return wcstod(str, endptr); | 244 return wcstod(str, endptr); |
245 } else { | 245 } else { |
246 // Because dmg_fp::strtod does not like wchar_t, we convert it to ASCII. | 246 // Because dmg_fp::strtod does not like wchar_t, we convert it to ASCII. |
247 // In theory, this should be safe, but it's possible that wide chars | 247 // In theory, this should be safe, but it's possible that wide chars |
248 // might get ignored by accident causing something to be parsed when it | 248 // might get ignored by accident causing something to be parsed when it |
249 // shouldn't. | 249 // shouldn't. |
250 std::string ascii_string = WideToASCII(std::wstring(str)); | 250 std::string ascii_string = WideToASCII(std::wstring(str)); |
251 char* ascii_end = NULL; | 251 char* ascii_end = NULL; |
252 value_type ret = dmg_fp::strtod(ascii_string.c_str(), &ascii_end); | 252 value_type ret = dmg_fp::strtod(ascii_string.c_str(), &ascii_end); |
253 if (ascii_string.c_str() + ascii_string.length() == ascii_end) { | 253 if (ascii_string.c_str() + ascii_string.length() == ascii_end) { |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 int rstr_len = (max_len - 3) / 2; | 1547 int rstr_len = (max_len - 3) / 2; |
1548 int lstr_len = rstr_len + ((max_len - 3) % 2); | 1548 int lstr_len = rstr_len + ((max_len - 3) % 2); |
1549 output->assign(input.substr(0, lstr_len) + L"..." + | 1549 output->assign(input.substr(0, lstr_len) + L"..." + |
1550 input.substr(input.length() - rstr_len)); | 1550 input.substr(input.length() - rstr_len)); |
1551 break; | 1551 break; |
1552 } | 1552 } |
1553 } | 1553 } |
1554 | 1554 |
1555 return true; | 1555 return true; |
1556 } | 1556 } |
OLD | NEW |