mirror of https://github.com/rusefi/lua.git
no more 'zungetc' (better not to read next char)
This commit is contained in:
parent
fd5e810e08
commit
559bb554c9
38
llex.c
38
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 2.53 2011/07/08 20:01:38 roberto Exp roberto $
|
** $Id: llex.c,v 2.54 2011/07/15 12:30:41 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -320,7 +320,6 @@ static int readdecesc (LexState *ls) {
|
||||||
}
|
}
|
||||||
if (r > UCHAR_MAX)
|
if (r > UCHAR_MAX)
|
||||||
escerror(ls, c, i, "decimal escape too large");
|
escerror(ls, c, i, "decimal escape too large");
|
||||||
zungetc(ls->z);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,37 +339,38 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
||||||
int c; /* final character to be saved */
|
int c; /* final character to be saved */
|
||||||
next(ls); /* do not save the `\' */
|
next(ls); /* do not save the `\' */
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
case 'a': c = '\a'; break;
|
case 'a': c = '\a'; goto read_save;
|
||||||
case 'b': c = '\b'; break;
|
case 'b': c = '\b'; goto read_save;
|
||||||
case 'f': c = '\f'; break;
|
case 'f': c = '\f'; goto read_save;
|
||||||
case 'n': c = '\n'; break;
|
case 'n': c = '\n'; goto read_save;
|
||||||
case 'r': c = '\r'; break;
|
case 'r': c = '\r'; goto read_save;
|
||||||
case 't': c = '\t'; break;
|
case 't': c = '\t'; goto read_save;
|
||||||
case 'v': c = '\v'; break;
|
case 'v': c = '\v'; goto read_save;
|
||||||
case 'x': c = readhexaesc(ls); break;
|
case 'x': c = readhexaesc(ls); goto read_save;
|
||||||
case '\n':
|
case '\n': case '\r':
|
||||||
case '\r': save(ls, '\n'); inclinenumber(ls); continue;
|
inclinenumber(ls); c = '\n'; goto only_save;
|
||||||
case '\\': case '\"': case '\'': c = ls->current; break;
|
case '\\': case '\"': case '\'':
|
||||||
case EOZ: continue; /* will raise an error next loop */
|
c = ls->current; goto read_save;
|
||||||
|
case EOZ: goto no_save; /* will raise an error next loop */
|
||||||
case 'z': { /* zap following span of spaces */
|
case 'z': { /* zap following span of spaces */
|
||||||
next(ls); /* skip the 'z' */
|
next(ls); /* skip the 'z' */
|
||||||
while (lisspace(ls->current)) {
|
while (lisspace(ls->current)) {
|
||||||
if (currIsNewline(ls)) inclinenumber(ls);
|
if (currIsNewline(ls)) inclinenumber(ls);
|
||||||
else next(ls);
|
else next(ls);
|
||||||
}
|
}
|
||||||
continue; /* do not save 'c' */
|
goto no_save;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if (!lisdigit(ls->current))
|
if (!lisdigit(ls->current))
|
||||||
escerror(ls, &ls->current, 1, "invalid escape sequence");
|
escerror(ls, &ls->current, 1, "invalid escape sequence");
|
||||||
/* digital escape \ddd */
|
/* digital escape \ddd */
|
||||||
c = readdecesc(ls);
|
c = readdecesc(ls);
|
||||||
break;
|
goto only_save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next(ls);
|
read_save: next(ls); /* read next character */
|
||||||
save(ls, c);
|
only_save: save(ls, c); /* save 'c' */
|
||||||
break;
|
no_save: break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
save_and_next(ls);
|
save_and_next(ls);
|
||||||
|
|
4
lzio.h
4
lzio.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lzio.h,v 1.24 2011/02/23 13:13:10 roberto Exp roberto $
|
** $Id: lzio.h,v 1.25 2011/07/15 12:35:32 roberto Exp roberto $
|
||||||
** Buffered streams
|
** Buffered streams
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -19,8 +19,6 @@ typedef struct Zio ZIO;
|
||||||
|
|
||||||
#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
|
#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
|
||||||
|
|
||||||
#define zungetc(z) ((z)->n++, (z)->p--)
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct Mbuffer {
|
typedef struct Mbuffer {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
Loading…
Reference in New Issue