| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 } | 925 } |
| 926 case 'n': { | 926 case 'n': { |
| 927 const char kNullLiteral[] = "null"; | 927 const char kNullLiteral[] = "null"; |
| 928 const int kNullLen = static_cast<int>(strlen(kNullLiteral)); | 928 const int kNullLen = static_cast<int>(strlen(kNullLiteral)); |
| 929 if (!CanConsume(kNullLen - 1) || | 929 if (!CanConsume(kNullLen - 1) || |
| 930 !StringsAreEqual(pos_, kNullLiteral, kNullLen)) { | 930 !StringsAreEqual(pos_, kNullLiteral, kNullLen)) { |
| 931 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); | 931 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| 932 return NULL; | 932 return NULL; |
| 933 } | 933 } |
| 934 NextNChars(kNullLen - 1); | 934 NextNChars(kNullLen - 1); |
| 935 return Value::CreateNullValue(); | 935 return Value::CreateNullValue().release(); |
| 936 } | 936 } |
| 937 default: | 937 default: |
| 938 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); | 938 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); |
| 939 return NULL; | 939 return NULL; |
| 940 } | 940 } |
| 941 } | 941 } |
| 942 | 942 |
| 943 // static | 943 // static |
| 944 bool JSONParser::StringsAreEqual(const char* one, const char* two, size_t len) { | 944 bool JSONParser::StringsAreEqual(const char* one, const char* two, size_t len) { |
| 945 return strncmp(one, two, len) == 0; | 945 return strncmp(one, two, len) == 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 957 const std::string& description) { | 957 const std::string& description) { |
| 958 if (line || column) { | 958 if (line || column) { |
| 959 return StringPrintf("Line: %i, column: %i, %s", | 959 return StringPrintf("Line: %i, column: %i, %s", |
| 960 line, column, description.c_str()); | 960 line, column, description.c_str()); |
| 961 } | 961 } |
| 962 return description; | 962 return description; |
| 963 } | 963 } |
| 964 | 964 |
| 965 } // namespace internal | 965 } // namespace internal |
| 966 } // namespace base | 966 } // namespace base |
| OLD | NEW |