Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: runtime/lib/convert_patch.dart

Issue 387323002: Fix error message for unexpected characters in JSON. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Actually fix the problem, using existing variables. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/convert/json_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:typed_data"; 5 import "dart:typed_data";
6 6
7 // JSON conversion. 7 // JSON conversion.
8 8
9 patch _parseJson(String json, reviver(var key, var value)) { 9 patch _parseJson(String json, reviver(var key, var value)) {
10 _BuildJsonListener listener; 10 _BuildJsonListener listener;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // At that time, position points to the next character, and isDouble 497 // At that time, position points to the next character, and isDouble
498 // is set if the literal contains a decimal point or an exponential. 498 // is set if the literal contains a decimal point or an exponential.
499 parsing: { 499 parsing: {
500 if (char == MINUS) { 500 if (char == MINUS) {
501 intSign = -1; 501 intSign = -1;
502 position++; 502 position++;
503 if (position == length) fail(position, "Missing expected digit"); 503 if (position == length) fail(position, "Missing expected digit");
504 char = source.codeUnitAt(position); 504 char = source.codeUnitAt(position);
505 } 505 }
506 if (char < CHAR_0 || char > CHAR_9) { 506 if (char < CHAR_0 || char > CHAR_9) {
507 if (negative) { 507 if (intSign < 0) {
508 fail(position, "Missing expected digit"); 508 fail(position, "Missing expected digit");
509 } else { 509 } else {
510 // If it doesn't even start out as a numeral. 510 // If it doesn't even start out as a numeral.
511 fail(position, "Unexpected character"); 511 fail(position, "Unexpected character");
512 } 512 }
513 } 513 }
514 if (char == CHAR_0) { 514 if (char == CHAR_0) {
515 position++; 515 position++;
516 if (position == length) break parsing; 516 if (position == length) break parsing;
517 char = source.codeUnitAt(position); 517 char = source.codeUnitAt(position);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 if (message == null) message = "Unexpected character"; 574 if (message == null) message = "Unexpected character";
575 throw new FormatException(message, source, position); 575 throw new FormatException(message, source, position);
576 } 576 }
577 } 577 }
578 578
579 // UTF-8 conversion. 579 // UTF-8 conversion.
580 580
581 patch class _Utf8Encoder { 581 patch class _Utf8Encoder {
582 /* patch */ static List<int> _createBuffer(int size) => new Uint8List(size); 582 /* patch */ static List<int> _createBuffer(int size) => new Uint8List(size);
583 } 583 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/convert/json_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698