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

Unified Diff: frog/leg/scanner/byte_strings.dart

Issue 9301037: Made multiline string literals ignore an initial newline. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test that didn't expect initial newlines to disappear. Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | frog/leg/scanner/string_scanner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/scanner/byte_strings.dart
diff --git a/frog/leg/scanner/byte_strings.dart b/frog/leg/scanner/byte_strings.dart
index 8cbe6a9085ef4dea60f6e470c245a8d08a41b531..17777fcafd5fa9e4e4cf79f0407b159d5f670fe0 100644
--- a/frog/leg/scanner/byte_strings.dart
+++ b/frog/leg/scanner/byte_strings.dart
@@ -109,27 +109,17 @@ class Utf8String extends ByteString {
Iterator<int> iterator() => new Utf8Decoder(bytes, 0, length);
SourceString copyWithoutQuotes(int initial, int terminal) {
- assert(0 <= initial && initial <= 4);
- assert(initial !== 1 || bytes[offset] === $SQ ||
- bytes[offset] === $DQ);
- assert(initial !== 2 || (bytes[offset] === $AT &&
- (bytes[offset + 1] === $SQ ||
- bytes[offset + 1] === $DQ)));
- assert(initial !== 3 || ((bytes[offset] === $SQ ||
- bytes[offset] === $DQ) &&
- bytes[offset] === bytes[offset + 1] &&
- bytes[offset] === bytes[offset + 2]));
- assert(initial !== 4 || (bytes[offset] === $AT &&
- (bytes[offset + 1] === $SQ ||
- bytes[offset + 1] === $DQ) &&
- bytes[offset + 2] === bytes[offset + 1] &&
- bytes[offset + 3] === bytes[offset + 1]));
- assert(terminal === 0 || terminal === 1 || terminal === 3);
- assert(terminal === 0 || ((bytes[end - 1] == $AT ||
- bytes[end - 1] === $DQ) &&
- (terminal === 1 ||
- bytes[end - 2] === bytes[end - 1] &&
- bytes[end - 3] === bytes[end - 1])));
+ assert((){
+ // Only allow dropping ASCII characters, to guarantee that
+ // the resulting Utf8String is still valid.
+ for (int i = 0; i < initial; i++) {
+ if (bytes[offset + i] >= 0x80) return false;
+ }
+ for (int i = 0; i < terminal; i++) {
+ if (bytes[offset + length - terminal + i] >= 0x80) return false;
+ }
+ return true;
+ });
// TODO(lrn): Check that first and last bytes use the same type of quotes.
return new Utf8String(bytes, offset + initial,
length - initial - terminal);
« no previous file with comments | « no previous file | frog/leg/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698