| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/json_reader.h" | 5 #include "base/json/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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 Value* JSONReader::DecodeNumber(const Token& token) { | 389 Value* JSONReader::DecodeNumber(const Token& token) { |
| 390 const std::wstring num_string(token.begin, token.length); | 390 const std::wstring num_string(token.begin, token.length); |
| 391 | 391 |
| 392 int num_int; | 392 int num_int; |
| 393 if (StringToInt(WideToUTF8(num_string), &num_int)) | 393 if (StringToInt(WideToUTF8(num_string), &num_int)) |
| 394 return Value::CreateIntegerValue(num_int); | 394 return Value::CreateIntegerValue(num_int); |
| 395 | 395 |
| 396 double num_double; | 396 double num_double; |
| 397 if (StringToDouble(WideToUTF8(num_string), &num_double) && | 397 if (StringToDouble(WideToUTF8(num_string), &num_double) && |
| 398 base::IsFinite(num_double)) | 398 base::IsFinite(num_double)) |
| 399 return Value::CreateRealValue(num_double); | 399 return Value::CreateDoubleValue(num_double); |
| 400 | 400 |
| 401 return NULL; | 401 return NULL; |
| 402 } | 402 } |
| 403 | 403 |
| 404 JSONReader::Token JSONReader::ParseStringToken() { | 404 JSONReader::Token JSONReader::ParseStringToken() { |
| 405 Token token(Token::STRING, json_pos_, 1); | 405 Token token(Token::STRING, json_pos_, 1); |
| 406 wchar_t c = token.NextChar(); | 406 wchar_t c = token.NextChar(); |
| 407 while ('\0' != c) { | 407 while ('\0' != c) { |
| 408 if ('\\' == c) { | 408 if ('\\' == c) { |
| 409 ++token.length; | 409 ++token.length; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 ++column_number; | 664 ++column_number; |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 error_line_ = line_number; | 668 error_line_ = line_number; |
| 669 error_col_ = column_number; | 669 error_col_ = column_number; |
| 670 error_code_ = error; | 670 error_code_ = error; |
| 671 } | 671 } |
| 672 | 672 |
| 673 } // namespace base | 673 } // namespace base |
| OLD | NEW |