| 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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 ++json_pos_; | 594 ++json_pos_; |
| 595 return true; | 595 return true; |
| 596 default: | 596 default: |
| 597 ++json_pos_; | 597 ++json_pos_; |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 } else if ('*' == next_char) { | 600 } else if ('*' == next_char) { |
| 601 // Block comment, read until */ | 601 // Block comment, read until */ |
| 602 json_pos_ += 2; | 602 json_pos_ += 2; |
| 603 while ('\0' != *json_pos_) { | 603 while ('\0' != *json_pos_) { |
| 604 switch (*json_pos_) { | 604 if ('*' == *json_pos_ && '/' == *(json_pos_ + 1)) { |
| 605 case '*': | 605 json_pos_ += 2; |
| 606 if ('/' == *(json_pos_ + 1)) { | 606 return true; |
| 607 json_pos_ += 2; | |
| 608 return true; | |
| 609 } | |
| 610 default: | |
| 611 ++json_pos_; | |
| 612 } | 607 } |
| 608 ++json_pos_; |
| 613 } | 609 } |
| 614 } else { | 610 } else { |
| 615 return false; | 611 return false; |
| 616 } | 612 } |
| 617 return true; | 613 return true; |
| 618 } | 614 } |
| 619 | 615 |
| 620 void JSONReader::SetErrorMessage(const char* description, | 616 void JSONReader::SetErrorMessage(const char* description, |
| 621 const wchar_t* error_pos) { | 617 const wchar_t* error_pos) { |
| 622 int line_number = 1; | 618 int line_number = 1; |
| 623 int column_number = 1; | 619 int column_number = 1; |
| 624 | 620 |
| 625 // Figure out the line and column the error occured at. | 621 // Figure out the line and column the error occured at. |
| 626 for (const wchar_t* pos = start_pos_; pos != error_pos; ++pos) { | 622 for (const wchar_t* pos = start_pos_; pos != error_pos; ++pos) { |
| 627 if (*pos == '\0') { | 623 if (*pos == '\0') { |
| 628 NOTREACHED(); | 624 NOTREACHED(); |
| 629 return; | 625 return; |
| 630 } | 626 } |
| 631 | 627 |
| 632 if (*pos == '\n') { | 628 if (*pos == '\n') { |
| 633 ++line_number; | 629 ++line_number; |
| 634 column_number = 1; | 630 column_number = 1; |
| 635 } else { | 631 } else { |
| 636 ++column_number; | 632 ++column_number; |
| 637 } | 633 } |
| 638 } | 634 } |
| 639 | 635 |
| 640 error_message_ = FormatErrorMessage(line_number, column_number, description); | 636 error_message_ = FormatErrorMessage(line_number, column_number, description); |
| 641 } | 637 } |
| OLD | NEW |