mirror of https://github.com/lua/lua
skips can be nested (why not?).
This commit is contained in:
parent
a8a15ff1bd
commit
ec422ec7d0
12
iolib.c
12
iolib.c
|
@ -115,8 +115,14 @@ static void io_read (void)
|
||||||
int c = NEED_OTHER;
|
int c = NEED_OTHER;
|
||||||
luaI_addchar(0);
|
luaI_addchar(0);
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (*p == '{' || *p == '}') {
|
if (*p == '{') {
|
||||||
inskip = (*p == '{');
|
inskip++;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
else if (*p == '}') {
|
||||||
|
if (inskip == 0)
|
||||||
|
lua_error("unbalanced `{...}' in read pattern");
|
||||||
|
inskip--;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -125,7 +131,7 @@ static void io_read (void)
|
||||||
if (c == NEED_OTHER) c = getc(lua_infile);
|
if (c == NEED_OTHER) c = getc(lua_infile);
|
||||||
m = (c == EOF) ? 0 : singlematch((char)c, p);
|
m = (c == EOF) ? 0 : singlematch((char)c, p);
|
||||||
if (m) {
|
if (m) {
|
||||||
if (!inskip) luaI_addchar(c);
|
if (inskip == 0) luaI_addchar(c);
|
||||||
c = NEED_OTHER;
|
c = NEED_OTHER;
|
||||||
}
|
}
|
||||||
switch (*ep) {
|
switch (*ep) {
|
||||||
|
|
Loading…
Reference in New Issue