From: Jay Freeman (saurik) Date: Tue, 24 Nov 2015 08:20:06 +0000 (-0800) Subject: Implement all of the crazy ECMAScript octal stuff. X-Git-Tag: v0.9.590~292 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/a703494adeea8b4b225e7bb58eacf94e7f881d01?ds=sidebyside Implement all of the crazy ECMAScript octal stuff. --- diff --git a/Cycript.l.in b/Cycript.l.in index 85db0e8..59ce0f8 100644 --- a/Cycript.l.in +++ b/Cycript.l.in @@ -148,7 +148,7 @@ int H(char c) { %option ecs %option align -Escape \\[\\'"bfnrtv]|\\0|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\\n +Escape \\[\\'"bfnrtv]|\\[0-7]|\\[4-7][0-7]|\\[0-3][0-7][0-7]?|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\\n IdentifierStart [a-zA-Z$_] IdentifierPart [a-zA-Z$_0-9] @@ -397,9 +397,11 @@ XMLName {XMLNameStart}{XMLNamePart}* {IdentifierStart}{IdentifierPart}* L C I(identifier, Identifier(Y), tk::Identifier_, hi::Identifier); +0[0-7]+ L C I(number, Number(strtoull(yytext + 1, NULL, 8)), tk::NumericLiteral, hi::Constant); +0[0-9]+ L C I(number, Number(strtoull(yytext + 1, NULL, 10)), tk::NumericLiteral, hi::Constant); 0[xX][0-9a-fA-F]+ L C I(number, Number(strtoull(yytext + 2, NULL, 16)), tk::NumericLiteral, hi::Constant); -0[0-7]+ L C I(number, Number(strtoull(yytext + 1, NULL, 8)), tk::NumericLiteral, hi::Constant); +0[oO][0-7]+ L C I(number, Number(strtoull(yytext + 2, NULL, 8)), tk::NumericLiteral, hi::Constant); 0[bB][0-1]+ L C I(number, Number(strtoull(yytext + 2, NULL, 2)), tk::NumericLiteral, hi::Constant); (\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?)([eE][+-]?[0-9]+)? L C I(number, Number(strtod(yytext, NULL)), tk::NumericLiteral, hi::Constant); @@ -425,7 +427,22 @@ XMLName {XMLNameStart}{XMLNamePart}* case 'r': next = '\r'; break; case 't': next = '\t'; break; case 'v': next = '\v'; break; - case '0': next = '\0'; break; + + case '0': case '1': case '2': case '3': + if (yytext[i + 1] < '0' || yytext[i + 1] > '7') + next = H(yytext[i]), i += 0; + else if (yytext[i + 2] < '0' || yytext[i + 2] > '7') + next = H(yytext[i]) << 3 | H(yytext[i + 1]), i += 1; + else + next = H(yytext[i]) << 6 | H(yytext[i + 1]) << 3 | H(yytext[i + 2]), i += 2; + break; + + case '4': case '5': case '6': case '7': + if (yytext[i + 1] < '0' || yytext[i + 1] > '7') + next = H(yytext[i]), i += 0; + else + next = H(yytext[i]) << 3 | H(yytext[i + 1]), i += 1; + break; case 'x': next = H(yytext[i + 1]) << 4 | H(yytext[i + 2]);