diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-14 13:23:51 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-14 13:23:51 -0200 |
| commit | 0b04c561f5c08600831f3bb6126b062658d434b1 (patch) | |
| tree | 0a331e2eedd62fad572d89aff72adf888e597df0 | |
| parent | 90b0ac6495cb5b4f06b795bef3da346a55581284 (diff) | |
| download | lua-0b04c561f5c08600831f3bb6126b062658d434b1.tar.gz lua-0b04c561f5c08600831f3bb6126b062658d434b1.tar.bz2 lua-0b04c561f5c08600831f3bb6126b062658d434b1.zip | |
new syntax for Unicode escape '\u{012F}'
| -rw-r--r-- | llex.c | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 2.72 2014/02/04 18:57:34 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.73 2014/02/06 15:59:24 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -345,15 +345,18 @@ static int readhexaesc (LexState *ls) { | |||
| 345 | 345 | ||
| 346 | 346 | ||
| 347 | static unsigned int readutf8esc (LexState *ls) { | 347 | static unsigned int readutf8esc (LexState *ls) { |
| 348 | int i = 3; /* chars to be removed: '\', 'u', and first digit */ | 348 | unsigned int r; |
| 349 | unsigned int r = gethexa(ls); /* must have at least one digit */ | 349 | int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ |
| 350 | save_and_next(ls); /* skip 'u' */ | ||
| 351 | esccheck(ls, ls->current == '{', "missing '{'"); | ||
| 352 | r = gethexa(ls); /* must have at least one digit */ | ||
| 350 | while ((save_and_next(ls), lisxdigit(ls->current))) { | 353 | while ((save_and_next(ls), lisxdigit(ls->current))) { |
| 351 | i++; | 354 | i++; |
| 352 | r = (r << 4) + luaO_hexavalue(ls->current); | 355 | r = (r << 4) + luaO_hexavalue(ls->current); |
| 353 | esccheck(ls, r <= 0x10FFFF, "UTF-8 value too large"); | 356 | esccheck(ls, r <= 0x10FFFF, "UTF-8 value too large"); |
| 354 | } | 357 | } |
| 355 | esccheck(ls, ls->current == ';', "missing ';' in UTF-8 escape"); | 358 | esccheck(ls, ls->current == '}', "missing '}'"); |
| 356 | next(ls); /* skip ';' */ | 359 | next(ls); /* skip '}' */ |
| 357 | luaZ_buffremove(ls->buff, i); /* remove saved chars from buffer */ | 360 | luaZ_buffremove(ls->buff, i); /* remove saved chars from buffer */ |
| 358 | return r; | 361 | return r; |
| 359 | } | 362 | } |
