OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_parser.h" | 5 #include "base/json/json_parser.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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 return T_INVALID_TOKEN; | 397 return T_INVALID_TOKEN; |
398 } | 398 } |
399 } | 399 } |
400 | 400 |
401 void JSONParser::EatWhitespaceAndComments() { | 401 void JSONParser::EatWhitespaceAndComments() { |
402 while (pos_ < end_pos_) { | 402 while (pos_ < end_pos_) { |
403 switch (*pos_) { | 403 switch (*pos_) { |
404 case '\r': | 404 case '\r': |
405 case '\n': | 405 case '\n': |
406 index_last_line_ = index_; | 406 index_last_line_ = index_; |
407 ++line_number_; | 407 // Don't increment line_number_ twice for "\r\n". |
| 408 if (!(*pos_ == '\n' && pos_ > start_pos_ && *(pos_ - 1) == '\r')) |
| 409 ++line_number_; |
408 // Fall through. | 410 // Fall through. |
409 case ' ': | 411 case ' ': |
410 case '\t': | 412 case '\t': |
411 NextChar(); | 413 NextChar(); |
412 break; | 414 break; |
413 case '/': | 415 case '/': |
414 if (!EatComment()) | 416 if (!EatComment()) |
415 return; | 417 return; |
416 break; | 418 break; |
417 default: | 419 default: |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 const std::string& description) { | 955 const std::string& description) { |
954 if (line || column) { | 956 if (line || column) { |
955 return StringPrintf("Line: %i, column: %i, %s", | 957 return StringPrintf("Line: %i, column: %i, %s", |
956 line, column, description.c_str()); | 958 line, column, description.c_str()); |
957 } | 959 } |
958 return description; | 960 return description; |
959 } | 961 } |
960 | 962 |
961 } // namespace internal | 963 } // namespace internal |
962 } // namespace base | 964 } // namespace base |
OLD | NEW |