aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-07-19 20:58:10 +0200
committerMike Pall <mike>2011-07-19 20:58:10 +0200
commitb261d0ec046d3b20bc37826344be3049a144de24 (patch)
tree28bce61fff83e849dd783b5a2bb7cdd6eebd8d06 /src
parent9c58bd6689876e36879ff24f357bb32d9e780b03 (diff)
downloadluajit-b261d0ec046d3b20bc37826344be3049a144de24.tar.gz
luajit-b261d0ec046d3b20bc37826344be3049a144de24.tar.bz2
luajit-b261d0ec046d3b20bc37826344be3049a144de24.zip
From Lua 5.2: Change \* to \z. Reject undefined escape sequences.
Diffstat (limited to 'src')
-rw-r--r--src/lj_lex.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c
index 01e0c641..00daccd5 100644
--- a/src/lj_lex.c
+++ b/src/lj_lex.c
@@ -238,9 +238,8 @@ static void read_string(LexState *ls, int delim, TValue *tv)
238 lj_lex_error(ls, TK_string, LJ_ERR_XSTR); 238 lj_lex_error(ls, TK_string, LJ_ERR_XSTR);
239 continue; 239 continue;
240 case '\\': { 240 case '\\': {
241 int c; 241 int c = next(ls); /* Skip the '\\'. */
242 next(ls); /* Skip the '\\'. */ 242 switch (c) {
243 switch (ls->current) {
244 case 'a': c = '\a'; break; 243 case 'a': c = '\a'; break;
245 case 'b': c = '\b'; break; 244 case 'b': c = '\b'; break;
246 case 'f': c = '\f'; break; 245 case 'f': c = '\f'; break;
@@ -260,31 +259,30 @@ static void read_string(LexState *ls, int delim, TValue *tv)
260 c += 9; 259 c += 9;
261 } 260 }
262 break; 261 break;
263 case '*': /* Skip whitespace. */ 262 case 'z': /* Skip whitespace. */
264 next(ls); 263 next(ls);
265 while (lj_char_isspace(ls->current)) 264 while (lj_char_isspace(ls->current))
266 if (currIsNewline(ls)) inclinenumber(ls); else next(ls); 265 if (currIsNewline(ls)) inclinenumber(ls); else next(ls);
267 continue; 266 continue;
268 case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; 267 case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue;
268 case '\\': case '\"': case '\'': break;
269 case END_OF_STREAM: continue; 269 case END_OF_STREAM: continue;
270 default: 270 default:
271 if (!lj_char_isdigit(ls->current)) { 271 if (!lj_char_isdigit(c))
272 save_and_next(ls); /* Handles '\\', '\"' and "\'". */ 272 goto err_xesc;
273 } else { /* Decimal escape '\ddd'. */ 273 c -= '0'; /* Decimal escape '\ddd'. */
274 c = (ls->current - '0'); 274 if (lj_char_isdigit(next(ls))) {
275 c = c*10 + (ls->current - '0');
275 if (lj_char_isdigit(next(ls))) { 276 if (lj_char_isdigit(next(ls))) {
276 c = c*10 + (ls->current - '0'); 277 c = c*10 + (ls->current - '0');
277 if (lj_char_isdigit(next(ls))) { 278 if (c > 255) {
278 c = c*10 + (ls->current - '0'); 279 err_xesc:
279 if (c > 255) { 280 lj_lex_error(ls, TK_string, LJ_ERR_XESC);
280 err_xesc:
281 lj_lex_error(ls, TK_string, LJ_ERR_XESC);
282 }
283 next(ls);
284 } 281 }
282 next(ls);
285 } 283 }
286 save(ls, c);
287 } 284 }
285 save(ls, c);
288 continue; 286 continue;
289 } 287 }
290 save(ls, c); 288 save(ls, c);