mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
From Lua 5.2: Change \* to \z. Reject undefined escape sequences.
This commit is contained in:
parent
9c58bd6689
commit
b261d0ec04
30
src/lj_lex.c
30
src/lj_lex.c
@ -238,9 +238,8 @@ static void read_string(LexState *ls, int delim, TValue *tv)
|
|||||||
lj_lex_error(ls, TK_string, LJ_ERR_XSTR);
|
lj_lex_error(ls, TK_string, LJ_ERR_XSTR);
|
||||||
continue;
|
continue;
|
||||||
case '\\': {
|
case '\\': {
|
||||||
int c;
|
int c = next(ls); /* Skip the '\\'. */
|
||||||
next(ls); /* Skip the '\\'. */
|
switch (c) {
|
||||||
switch (ls->current) {
|
|
||||||
case 'a': c = '\a'; break;
|
case 'a': c = '\a'; break;
|
||||||
case 'b': c = '\b'; break;
|
case 'b': c = '\b'; break;
|
||||||
case 'f': c = '\f'; break;
|
case 'f': c = '\f'; break;
|
||||||
@ -260,31 +259,30 @@ static void read_string(LexState *ls, int delim, TValue *tv)
|
|||||||
c += 9;
|
c += 9;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '*': /* Skip whitespace. */
|
case 'z': /* Skip whitespace. */
|
||||||
next(ls);
|
next(ls);
|
||||||
while (lj_char_isspace(ls->current))
|
while (lj_char_isspace(ls->current))
|
||||||
if (currIsNewline(ls)) inclinenumber(ls); else next(ls);
|
if (currIsNewline(ls)) inclinenumber(ls); else next(ls);
|
||||||
continue;
|
continue;
|
||||||
case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue;
|
case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue;
|
||||||
|
case '\\': case '\"': case '\'': break;
|
||||||
case END_OF_STREAM: continue;
|
case END_OF_STREAM: continue;
|
||||||
default:
|
default:
|
||||||
if (!lj_char_isdigit(ls->current)) {
|
if (!lj_char_isdigit(c))
|
||||||
save_and_next(ls); /* Handles '\\', '\"' and "\'". */
|
goto err_xesc;
|
||||||
} else { /* Decimal escape '\ddd'. */
|
c -= '0'; /* Decimal escape '\ddd'. */
|
||||||
c = (ls->current - '0');
|
if (lj_char_isdigit(next(ls))) {
|
||||||
|
c = c*10 + (ls->current - '0');
|
||||||
if (lj_char_isdigit(next(ls))) {
|
if (lj_char_isdigit(next(ls))) {
|
||||||
c = c*10 + (ls->current - '0');
|
c = c*10 + (ls->current - '0');
|
||||||
if (lj_char_isdigit(next(ls))) {
|
if (c > 255) {
|
||||||
c = c*10 + (ls->current - '0');
|
err_xesc:
|
||||||
if (c > 255) {
|
lj_lex_error(ls, TK_string, LJ_ERR_XESC);
|
||||||
err_xesc:
|
|
||||||
lj_lex_error(ls, TK_string, LJ_ERR_XESC);
|
|
||||||
}
|
|
||||||
next(ls);
|
|
||||||
}
|
}
|
||||||
|
next(ls);
|
||||||
}
|
}
|
||||||
save(ls, c);
|
|
||||||
}
|
}
|
||||||
|
save(ls, c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
save(ls, c);
|
save(ls, c);
|
||||||
|
Loading…
Reference in New Issue
Block a user