| 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/json_reader.h" | 5 #include "base/json_reader.h" |
| 6 | 6 |
| 7 #include "base/float_util.h" | 7 #include "base/float_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return kInvalidToken; | 350 return kInvalidToken; |
| 351 } | 351 } |
| 352 | 352 |
| 353 return token; | 353 return token; |
| 354 } | 354 } |
| 355 | 355 |
| 356 Value* JSONReader::DecodeNumber(const Token& token) { | 356 Value* JSONReader::DecodeNumber(const Token& token) { |
| 357 const std::wstring num_string(token.begin, token.length); | 357 const std::wstring num_string(token.begin, token.length); |
| 358 | 358 |
| 359 int num_int; | 359 int num_int; |
| 360 if (StringToInt(num_string, &num_int)) | 360 if (StringToInt(WideToUTF16Hack(num_string), &num_int)) |
| 361 return Value::CreateIntegerValue(num_int); | 361 return Value::CreateIntegerValue(num_int); |
| 362 | 362 |
| 363 double num_double; | 363 double num_double; |
| 364 if (StringToDouble(num_string, &num_double) && base::IsFinite(num_double)) | 364 if (StringToDouble(WideToUTF16Hack(num_string), &num_double) && |
| 365 base::IsFinite(num_double)) |
| 365 return Value::CreateRealValue(num_double); | 366 return Value::CreateRealValue(num_double); |
| 366 | 367 |
| 367 return NULL; | 368 return NULL; |
| 368 } | 369 } |
| 369 | 370 |
| 370 JSONReader::Token JSONReader::ParseStringToken() { | 371 JSONReader::Token JSONReader::ParseStringToken() { |
| 371 Token token(Token::STRING, json_pos_, 1); | 372 Token token(Token::STRING, json_pos_, 1); |
| 372 wchar_t c = token.NextChar(); | 373 wchar_t c = token.NextChar(); |
| 373 while ('\0' != c) { | 374 while ('\0' != c) { |
| 374 if ('\\' == c) { | 375 if ('\\' == c) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 if (*pos == '\n') { | 631 if (*pos == '\n') { |
| 631 ++line_number; | 632 ++line_number; |
| 632 column_number = 1; | 633 column_number = 1; |
| 633 } else { | 634 } else { |
| 634 ++column_number; | 635 ++column_number; |
| 635 } | 636 } |
| 636 } | 637 } |
| 637 | 638 |
| 638 error_message_ = FormatErrorMessage(line_number, column_number, description); | 639 error_message_ = FormatErrorMessage(line_number, column_number, description); |
| 639 } | 640 } |
| OLD | NEW |