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

Side by Side Diff: base/string_util.cc

Issue 10713: fix bug in locale dependence check (Closed)
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698