aboutsummaryrefslogtreecommitdiff
path: root/iolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-03-05 10:32:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-03-05 10:32:41 -0300
commitec422ec7d0f0af2bac368fe99b92d5ad7b381184 (patch)
treee7040d065df857e224a3c437cb59075d3cbe744f /iolib.c
parenta8a15ff1bdcb7526625b717c64c1d286f0625dd2 (diff)
downloadlua-ec422ec7d0f0af2bac368fe99b92d5ad7b381184.tar.gz
lua-ec422ec7d0f0af2bac368fe99b92d5ad7b381184.tar.bz2
lua-ec422ec7d0f0af2bac368fe99b92d5ad7b381184.zip
skips can be nested (why not?).
Diffstat (limited to 'iolib.c')
-rw-r--r--iolib.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/iolib.c b/iolib.c
index fb2c3b4b..bb352009 100644
--- a/iolib.c
+++ b/iolib.c
@@ -115,8 +115,14 @@ static void io_read (void)
115 int c = NEED_OTHER; 115 int c = NEED_OTHER;
116 luaI_addchar(0); 116 luaI_addchar(0);
117 while (*p) { 117 while (*p) {
118 if (*p == '{' || *p == '}') { 118 if (*p == '{') {
119 inskip = (*p == '{'); 119 inskip++;
120 p++;
121 }
122 else if (*p == '}') {
123 if (inskip == 0)
124 lua_error("unbalanced `{...}' in read pattern");
125 inskip--;
120 p++; 126 p++;
121 } 127 }
122 else { 128 else {
@@ -125,7 +131,7 @@ static void io_read (void)
125 if (c == NEED_OTHER) c = getc(lua_infile); 131 if (c == NEED_OTHER) c = getc(lua_infile);
126 m = (c == EOF) ? 0 : singlematch((char)c, p); 132 m = (c == EOF) ? 0 : singlematch((char)c, p);
127 if (m) { 133 if (m) {
128 if (!inskip) luaI_addchar(c); 134 if (inskip == 0) luaI_addchar(c);
129 c = NEED_OTHER; 135 c = NEED_OTHER;
130 } 136 }
131 switch (*ep) { 137 switch (*ep) {