| Index: runtime/vm/object.cc
|
| ===================================================================
|
| --- runtime/vm/object.cc (revision 20219)
|
| +++ runtime/vm/object.cc (working copy)
|
| @@ -251,7 +251,9 @@
|
| (value == '\b') ||
|
| (value == '\t') ||
|
| (value == '\v') ||
|
| - (value == '\r'));
|
| + (value == '\r') ||
|
| + (value == '\\') ||
|
| + (value == '$'));
|
| }
|
|
|
|
|
| @@ -271,6 +273,10 @@
|
| return 'v';
|
| } else if (value == '\r') {
|
| return 'r';
|
| + } else if (value == '\\') {
|
| + return '\\';
|
| + } else if (value == '$') {
|
| + return '$';
|
| }
|
| UNREACHABLE();
|
| return '\0';
|
| @@ -4844,37 +4850,17 @@
|
|
|
| // Handle the current token.
|
| if (curr == Token::kSTRING) {
|
| - bool is_raw_string = false;
|
| bool escape_characters = false;
|
| for (intptr_t i = 0; i < literal.Length(); i++) {
|
| if (IsSpecialCharacter(literal.CharAt(i))) {
|
| escape_characters = true;
|
| }
|
| - // TODO(4995): Temp solution for raw strings, this will break
|
| - // if we saw a string that is not a raw string but has back slashes
|
| - // in it.
|
| - if ((literal.CharAt(i) == '\\')) {
|
| - if ((next != Token::kINTERPOL_VAR) &&
|
| - (next != Token::kINTERPOL_START) &&
|
| - (prev != Token::kINTERPOL_VAR) &&
|
| - (prev != Token::kINTERPOL_END)) {
|
| - is_raw_string = true;
|
| - } else {
|
| - escape_characters = true;
|
| - }
|
| - }
|
| - if ((literal.CharAt(i) == '$')) {
|
| - escape_characters = true;
|
| - }
|
| }
|
| if ((prev != Token::kINTERPOL_VAR) && (prev != Token::kINTERPOL_END)) {
|
| - if (is_raw_string) {
|
| - literals.Add(Symbols::LowercaseR());
|
| - }
|
| literals.Add(Symbols::DoubleQuotes());
|
| }
|
| if (escape_characters) {
|
| - literal = String::EscapeSpecialCharacters(literal, is_raw_string);
|
| + literal = String::EscapeSpecialCharacters(literal);
|
| literals.Add(literal);
|
| } else {
|
| literals.Add(literal);
|
| @@ -11136,12 +11122,12 @@
|
| }
|
|
|
|
|
| -RawString* String::EscapeSpecialCharacters(const String& str, bool raw_str) {
|
| +RawString* String::EscapeSpecialCharacters(const String& str) {
|
| if (str.IsOneByteString()) {
|
| - return OneByteString::EscapeSpecialCharacters(str, raw_str);
|
| + return OneByteString::EscapeSpecialCharacters(str);
|
| }
|
| ASSERT(str.IsTwoByteString());
|
| - return TwoByteString::EscapeSpecialCharacters(str, raw_str);
|
| + return TwoByteString::EscapeSpecialCharacters(str);
|
| }
|
|
|
|
|
| @@ -11529,16 +11515,13 @@
|
| }
|
|
|
|
|
| -RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str,
|
| - bool raw_str) {
|
| +RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str) {
|
| intptr_t len = str.Length();
|
| if (len > 0) {
|
| intptr_t num_escapes = 0;
|
| intptr_t index = 0;
|
| for (intptr_t i = 0; i < len; i++) {
|
| - if (IsSpecialCharacter(*CharAddr(str, i)) ||
|
| - (!raw_str && (*CharAddr(str, i) == '$')) ||
|
| - (!raw_str && (*CharAddr(str, i) == '\\'))) {
|
| + if (IsSpecialCharacter(*CharAddr(str, i))) {
|
| num_escapes += 1;
|
| }
|
| }
|
| @@ -11549,14 +11532,6 @@
|
| *(CharAddr(dststr, index)) = '\\';
|
| *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i));
|
| index += 2;
|
| - } else if (!raw_str && (*CharAddr(str, i) == '$')) {
|
| - *(CharAddr(dststr, index)) = '\\';
|
| - *(CharAddr(dststr, index + 1)) = '$';
|
| - index += 2;
|
| - } else if (!raw_str && (*CharAddr(str, i) == '\\')) {
|
| - *(CharAddr(dststr, index)) = '\\';
|
| - *(CharAddr(dststr, index + 1)) = '\\';
|
| - index += 2;
|
| } else {
|
| *(CharAddr(dststr, index)) = *CharAddr(str, i);
|
| index += 1;
|
| @@ -11718,15 +11693,13 @@
|
| }
|
|
|
|
|
| -RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str,
|
| - bool raw_str) {
|
| +RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str) {
|
| intptr_t len = str.Length();
|
| if (len > 0) {
|
| intptr_t num_escapes = 0;
|
| intptr_t index = 0;
|
| for (intptr_t i = 0; i < len; i++) {
|
| - if (IsSpecialCharacter(*CharAddr(str, i)) ||
|
| - (!raw_str && (*CharAddr(str, i) == '\\'))) {
|
| + if (IsSpecialCharacter(*CharAddr(str, i))) {
|
| num_escapes += 1;
|
| }
|
| }
|
| @@ -11737,10 +11710,6 @@
|
| *(CharAddr(dststr, index)) = '\\';
|
| *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i));
|
| index += 2;
|
| - } else if (!raw_str && (*CharAddr(str, i) == '\\')) {
|
| - *(CharAddr(dststr, index)) = '\\';
|
| - *(CharAddr(dststr, index + 1)) = '\\';
|
| - index += 2;
|
| } else {
|
| *(CharAddr(dststr, index)) = *CharAddr(str, i);
|
| index += 1;
|
|
|