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

Side by Side Diff: src/json-parser.h

Issue 7541072: Port patch 8847 to the 3.4 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.4
Patch Set: Created 9 years, 4 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 | src/version.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 int count = end - start; 450 int count = end - start;
451 int max_length = count + source_length_ - position_; 451 int max_length = count + source_length_ - position_;
452 int length = Min(max_length, Max(kInitialSpecialStringLength, 2 * count)); 452 int length = Min(max_length, Max(kInitialSpecialStringLength, 2 * count));
453 Handle<StringType> seq_str = NewRawString<StringType>(isolate()->factory(), 453 Handle<StringType> seq_str = NewRawString<StringType>(isolate()->factory(),
454 length); 454 length);
455 // Copy prefix into seq_str. 455 // Copy prefix into seq_str.
456 SinkChar* dest = seq_str->GetChars(); 456 SinkChar* dest = seq_str->GetChars();
457 String::WriteToFlat(*prefix, dest, start, end); 457 String::WriteToFlat(*prefix, dest, start, end);
458 458
459 while (c0_ != '"') { 459 while (c0_ != '"') {
460 // Check for control character (0x00-0x1f) or unterminated string (<0).
461 if (c0_ < 0x20) return Handle<String>::null();
460 if (count >= length) { 462 if (count >= length) {
461 // We need to create a longer sequential string for the result. 463 // We need to create a longer sequential string for the result.
462 return SlowScanJsonString<StringType, SinkChar>(seq_str, 0, count); 464 return SlowScanJsonString<StringType, SinkChar>(seq_str, 0, count);
463 } 465 }
464 // Check for control character (0x00-0x1f) or unterminated string (<0).
465 if (c0_ < 0x20) return Handle<String>::null();
466 if (c0_ != '\\') { 466 if (c0_ != '\\') {
467 // If the sink can contain UC16 characters, or source_ contains only 467 // If the sink can contain UC16 characters, or source_ contains only
468 // ASCII characters, there's no need to test whether we can store the 468 // ASCII characters, there's no need to test whether we can store the
469 // character. Otherwise check whether the UC16 source character can fit 469 // character. Otherwise check whether the UC16 source character can fit
470 // in the ASCII sink. 470 // in the ASCII sink.
471 if (sizeof(SinkChar) == kUC16Size || 471 if (sizeof(SinkChar) == kUC16Size ||
472 seq_ascii || 472 seq_ascii ||
473 c0_ <= kMaxAsciiCharCode) { 473 c0_ <= kMaxAsciiCharCode) {
474 SeqStringSet(seq_str, count++, c0_); 474 SeqStringSet(seq_str, count++, c0_);
475 Advance(); 475 Advance();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 589 }
590 ASSERT_EQ('"', c0_); 590 ASSERT_EQ('"', c0_);
591 // Advance past the last '"'. 591 // Advance past the last '"'.
592 AdvanceSkipWhitespace(); 592 AdvanceSkipWhitespace();
593 return result; 593 return result;
594 } 594 }
595 595
596 } } // namespace v8::internal 596 } } // namespace v8::internal
597 597
598 #endif // V8_JSON_PARSER_H_ 598 #endif // V8_JSON_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698