diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-07-15 09:48:03 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-07-15 09:48:03 -0300 |
| commit | 559bb554c944ed166e363e522e48a71e60e1922d (patch) | |
| tree | 1130eec81df7a0dd07645474688f638d1add4d07 | |
| parent | fd5e810e0858162a2b11229db4f17dca489c9d41 (diff) | |
| download | lua-559bb554c944ed166e363e522e48a71e60e1922d.tar.gz lua-559bb554c944ed166e363e522e48a71e60e1922d.tar.bz2 lua-559bb554c944ed166e363e522e48a71e60e1922d.zip | |
no more 'zungetc' (better not to read next char)
| -rw-r--r-- | llex.c | 38 | ||||
| -rw-r--r-- | lzio.h | 4 |
2 files changed, 20 insertions, 22 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 2.53 2011/07/08 20:01:38 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.54 2011/07/15 12:30:41 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 | */ |
| @@ -320,7 +320,6 @@ static int readdecesc (LexState *ls) { | |||
| 320 | } | 320 | } |
| 321 | if (r > UCHAR_MAX) | 321 | if (r > UCHAR_MAX) |
| 322 | escerror(ls, c, i, "decimal escape too large"); | 322 | escerror(ls, c, i, "decimal escape too large"); |
| 323 | zungetc(ls->z); | ||
| 324 | return r; | 323 | return r; |
| 325 | } | 324 | } |
| 326 | 325 | ||
| @@ -340,37 +339,38 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { | |||
| 340 | int c; /* final character to be saved */ | 339 | int c; /* final character to be saved */ |
| 341 | next(ls); /* do not save the `\' */ | 340 | next(ls); /* do not save the `\' */ |
| 342 | switch (ls->current) { | 341 | switch (ls->current) { |
| 343 | case 'a': c = '\a'; break; | 342 | case 'a': c = '\a'; goto read_save; |
| 344 | case 'b': c = '\b'; break; | 343 | case 'b': c = '\b'; goto read_save; |
| 345 | case 'f': c = '\f'; break; | 344 | case 'f': c = '\f'; goto read_save; |
| 346 | case 'n': c = '\n'; break; | 345 | case 'n': c = '\n'; goto read_save; |
| 347 | case 'r': c = '\r'; break; | 346 | case 'r': c = '\r'; goto read_save; |
| 348 | case 't': c = '\t'; break; | 347 | case 't': c = '\t'; goto read_save; |
| 349 | case 'v': c = '\v'; break; | 348 | case 'v': c = '\v'; goto read_save; |
| 350 | case 'x': c = readhexaesc(ls); break; | 349 | case 'x': c = readhexaesc(ls); goto read_save; |
| 351 | case '\n': | 350 | case '\n': case '\r': |
| 352 | case '\r': save(ls, '\n'); inclinenumber(ls); continue; | 351 | inclinenumber(ls); c = '\n'; goto only_save; |
| 353 | case '\\': case '\"': case '\'': c = ls->current; break; | 352 | case '\\': case '\"': case '\'': |
| 354 | case EOZ: continue; /* will raise an error next loop */ | 353 | c = ls->current; goto read_save; |
| 354 | case EOZ: goto no_save; /* will raise an error next loop */ | ||
| 355 | case 'z': { /* zap following span of spaces */ | 355 | case 'z': { /* zap following span of spaces */ |
| 356 | next(ls); /* skip the 'z' */ | 356 | next(ls); /* skip the 'z' */ |
| 357 | while (lisspace(ls->current)) { | 357 | while (lisspace(ls->current)) { |
| 358 | if (currIsNewline(ls)) inclinenumber(ls); | 358 | if (currIsNewline(ls)) inclinenumber(ls); |
| 359 | else next(ls); | 359 | else next(ls); |
| 360 | } | 360 | } |
| 361 | continue; /* do not save 'c' */ | 361 | goto no_save; |
| 362 | } | 362 | } |
| 363 | default: { | 363 | default: { |
| 364 | if (!lisdigit(ls->current)) | 364 | if (!lisdigit(ls->current)) |
| 365 | escerror(ls, &ls->current, 1, "invalid escape sequence"); | 365 | escerror(ls, &ls->current, 1, "invalid escape sequence"); |
| 366 | /* digital escape \ddd */ | 366 | /* digital escape \ddd */ |
| 367 | c = readdecesc(ls); | 367 | c = readdecesc(ls); |
| 368 | break; | 368 | goto only_save; |
| 369 | } | 369 | } |
| 370 | } | 370 | } |
| 371 | next(ls); | 371 | read_save: next(ls); /* read next character */ |
| 372 | save(ls, c); | 372 | only_save: save(ls, c); /* save 'c' */ |
| 373 | break; | 373 | no_save: break; |
| 374 | } | 374 | } |
| 375 | default: | 375 | default: |
| 376 | save_and_next(ls); | 376 | save_and_next(ls); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lzio.h,v 1.24 2011/02/23 13:13:10 roberto Exp roberto $ | 2 | ** $Id: lzio.h,v 1.25 2011/07/15 12:35:32 roberto Exp roberto $ |
| 3 | ** Buffered streams | 3 | ** Buffered streams |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -19,8 +19,6 @@ typedef struct Zio ZIO; | |||
| 19 | 19 | ||
| 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) |
| 21 | 21 | ||
| 22 | #define zungetc(z) ((z)->n++, (z)->p--) | ||
| 23 | |||
| 24 | 22 | ||
| 25 | typedef struct Mbuffer { | 23 | typedef struct Mbuffer { |
| 26 | char *buffer; | 24 | char *buffer; |
