** When reading a UTF-8 escape sequence, save everything to the buffer ** for error reporting in case of errors; 'i' counts the number of ** saved characters, so that they can be removed if case of success. */
| 363 | ** saved characters, so that they can be removed if case of success. |
| 364 | */ |
| 365 | static l_uint32 readutf8esc (LexState *ls) { |
| 366 | l_uint32 r; |
| 367 | int i = 4; /* number of chars to be removed: start with #"\u{X" */ |
| 368 | save_and_next(ls); /* skip 'u' */ |
| 369 | esccheck(ls, ls->current == '{', "missing '{'"); |
| 370 | r = cast_uint(gethexa(ls)); /* must have at least one digit */ |
| 371 | while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) { |
| 372 | i++; |
| 373 | esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); |
| 374 | r = (r << 4) + luaO_hexavalue(ls->current); |
| 375 | } |
| 376 | esccheck(ls, ls->current == '}', "missing '}'"); |
| 377 | next(ls); /* skip '}' */ |
| 378 | luaZ_buffremove(ls->buff, i); /* remove saved chars from buffer */ |
| 379 | return r; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | static void utf8esc (LexState *ls) { |
no test coverage detected