OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 // A helper method for ParseStringToken. It reads |digits| hex digits from the | 48 // A helper method for ParseStringToken. It reads |digits| hex digits from the |
49 // token. If the sequence if digits is not valid (contains other characters), | 49 // token. If the sequence if digits is not valid (contains other characters), |
50 // the method returns false. | 50 // the method returns false. |
51 bool ReadHexDigits(base::JSONReader::Token& token, int digits) { | 51 bool ReadHexDigits(base::JSONReader::Token& token, int digits) { |
52 for (int i = 1; i <= digits; ++i) { | 52 for (int i = 1; i <= digits; ++i) { |
53 wchar_t c = *(token.begin + token.length + i); | 53 wchar_t c = *(token.begin + token.length + i); |
54 if ('\0' == c) | 54 if ('\0' == c) |
55 return false; | 55 return false; |
56 if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || | 56 if (!IsHexDigit(c)) |
57 ('A' <= c && c <= 'F'))) { | |
58 return false; | 57 return false; |
59 } | |
60 } | 58 } |
61 | 59 |
62 token.length += digits; | 60 token.length += digits; |
63 return true; | 61 return true; |
64 } | 62 } |
65 | 63 |
66 } // namespace | 64 } // namespace |
67 | 65 |
68 namespace base { | 66 namespace base { |
69 | 67 |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 ++column_number; | 659 ++column_number; |
662 } | 660 } |
663 } | 661 } |
664 | 662 |
665 error_line_ = line_number; | 663 error_line_ = line_number; |
666 error_col_ = column_number; | 664 error_col_ = column_number; |
667 error_code_ = error; | 665 error_code_ = error; |
668 } | 666 } |
669 | 667 |
670 } // namespace base | 668 } // namespace base |
OLD | NEW |