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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 } | 797 } |
798 case 'n': { | 798 case 'n': { |
799 const char kNullLiteral[] = "null"; | 799 const char kNullLiteral[] = "null"; |
800 const int kNullLen = static_cast<int>(strlen(kNullLiteral)); | 800 const int kNullLen = static_cast<int>(strlen(kNullLiteral)); |
801 if (!CanConsume(kNullLen - 1) || | 801 if (!CanConsume(kNullLen - 1) || |
802 !StringsAreEqual(pos_, kNullLiteral, kNullLen)) { | 802 !StringsAreEqual(pos_, kNullLiteral, kNullLen)) { |
803 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); | 803 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
804 return nullptr; | 804 return nullptr; |
805 } | 805 } |
806 NextNChars(kNullLen - 1); | 806 NextNChars(kNullLen - 1); |
807 return Value::CreateNullValue(); | 807 return MakeUnique<Value>(); |
808 } | 808 } |
809 default: | 809 default: |
810 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); | 810 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); |
811 return nullptr; | 811 return nullptr; |
812 } | 812 } |
813 } | 813 } |
814 | 814 |
815 // static | 815 // static |
816 bool JSONParser::StringsAreEqual(const char* one, const char* two, size_t len) { | 816 bool JSONParser::StringsAreEqual(const char* one, const char* two, size_t len) { |
817 return strncmp(one, two, len) == 0; | 817 return strncmp(one, two, len) == 0; |
(...skipping 11 matching lines...) Expand all Loading... |
829 const std::string& description) { | 829 const std::string& description) { |
830 if (line || column) { | 830 if (line || column) { |
831 return StringPrintf("Line: %i, column: %i, %s", | 831 return StringPrintf("Line: %i, column: %i, %s", |
832 line, column, description.c_str()); | 832 line, column, description.c_str()); |
833 } | 833 } |
834 return description; | 834 return description; |
835 } | 835 } |
836 | 836 |
837 } // namespace internal | 837 } // namespace internal |
838 } // namespace base | 838 } // namespace base |
OLD | NEW |