diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-11-19 14:59:08 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-11-19 14:59:08 -0200 |
commit | 10e48b91603a5228a9da2b282c74fa09ac03f4c6 (patch) | |
tree | 1fe01046284f562504b25dd199a5c95e953fdc7f | |
parent | 6f1ea817f5827523f8c7e429ab023e5984a84343 (diff) | |
download | lua-10e48b91603a5228a9da2b282c74fa09ac03f4c6.tar.gz lua-10e48b91603a5228a9da2b282c74fa09ac03f4c6.tar.bz2 lua-10e48b91603a5228a9da2b282c74fa09ac03f4c6.zip |
details
-rw-r--r-- | lparser.c | 7 | ||||
-rw-r--r-- | lstrlib.c | 20 |
2 files changed, 13 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.5 2004/05/31 18:51:50 roberto Exp $ | 2 | ** $Id: lparser.c,v 2.6 2004/10/04 19:01:53 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -157,7 +157,7 @@ static void checkname(LexState *ls, expdesc *e) { | |||
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | static int luaI_registerlocalvar (LexState *ls, TString *varname) { | 160 | static int registerlocalvar (LexState *ls, TString *varname) { |
161 | FuncState *fs = ls->fs; | 161 | FuncState *fs = ls->fs; |
162 | Proto *f = fs->f; | 162 | Proto *f = fs->f; |
163 | int oldsize = f->sizelocvars; | 163 | int oldsize = f->sizelocvars; |
@@ -177,8 +177,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) { | |||
177 | static void new_localvar (LexState *ls, TString *name, int n) { | 177 | static void new_localvar (LexState *ls, TString *name, int n) { |
178 | FuncState *fs = ls->fs; | 178 | FuncState *fs = ls->fs; |
179 | luaY_checklimit(fs, fs->nactvar+n+1, MAXVARS, "local variables"); | 179 | luaY_checklimit(fs, fs->nactvar+n+1, MAXVARS, "local variables"); |
180 | fs->actvar[fs->nactvar+n] = cast(unsigned short, | 180 | fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); |
181 | luaI_registerlocalvar(ls, name)); | ||
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.106 2004/08/09 13:30:33 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.107 2004/11/01 14:33:33 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -198,7 +198,7 @@ static int capture_to_close (MatchState *ms) { | |||
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | static const char *luaI_classend (MatchState *ms, const char *p) { | 201 | static const char *classend (MatchState *ms, const char *p) { |
202 | switch (*p++) { | 202 | switch (*p++) { |
203 | case ESC: { | 203 | case ESC: { |
204 | if (*p == '\0') | 204 | if (*p == '\0') |
@@ -264,7 +264,7 @@ static int matchbracketclass (int c, const char *p, const char *ec) { | |||
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | static int luaI_singlematch (int c, const char *p, const char *ep) { | 267 | static int singlematch (int c, const char *p, const char *ep) { |
268 | switch (*p) { | 268 | switch (*p) { |
269 | case '.': return 1; /* matches any char */ | 269 | case '.': return 1; /* matches any char */ |
270 | case ESC: return match_class(c, uchar(*(p+1))); | 270 | case ESC: return match_class(c, uchar(*(p+1))); |
@@ -300,7 +300,7 @@ static const char *matchbalance (MatchState *ms, const char *s, | |||
300 | static const char *max_expand (MatchState *ms, const char *s, | 300 | static const char *max_expand (MatchState *ms, const char *s, |
301 | const char *p, const char *ep) { | 301 | const char *p, const char *ep) { |
302 | sint32 i = 0; /* counts maximum expand for item */ | 302 | sint32 i = 0; /* counts maximum expand for item */ |
303 | while ((s+i)<ms->src_end && luaI_singlematch(uchar(*(s+i)), p, ep)) | 303 | while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep)) |
304 | i++; | 304 | i++; |
305 | /* keeps trying to match with the maximum repetitions */ | 305 | /* keeps trying to match with the maximum repetitions */ |
306 | while (i>=0) { | 306 | while (i>=0) { |
@@ -318,7 +318,7 @@ static const char *min_expand (MatchState *ms, const char *s, | |||
318 | const char *res = match(ms, s, ep+1); | 318 | const char *res = match(ms, s, ep+1); |
319 | if (res != NULL) | 319 | if (res != NULL) |
320 | return res; | 320 | return res; |
321 | else if (s<ms->src_end && luaI_singlematch(uchar(*s), p, ep)) | 321 | else if (s<ms->src_end && singlematch(uchar(*s), p, ep)) |
322 | s++; /* try with one more repetition */ | 322 | s++; /* try with one more repetition */ |
323 | else return NULL; | 323 | else return NULL; |
324 | } | 324 | } |
@@ -385,7 +385,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
385 | p += 2; | 385 | p += 2; |
386 | if (*p != '[') | 386 | if (*p != '[') |
387 | luaL_error(ms->L, "missing `[' after `%%f' in pattern"); | 387 | luaL_error(ms->L, "missing `[' after `%%f' in pattern"); |
388 | ep = luaI_classend(ms, p); /* points to what is next */ | 388 | ep = classend(ms, p); /* points to what is next */ |
389 | previous = (s == ms->src_init) ? '\0' : *(s-1); | 389 | previous = (s == ms->src_init) ? '\0' : *(s-1); |
390 | if (matchbracketclass(uchar(previous), p, ep-1) || | 390 | if (matchbracketclass(uchar(previous), p, ep-1) || |
391 | !matchbracketclass(uchar(*s), p, ep-1)) return NULL; | 391 | !matchbracketclass(uchar(*s), p, ep-1)) return NULL; |
@@ -410,8 +410,8 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
410 | else goto dflt; | 410 | else goto dflt; |
411 | } | 411 | } |
412 | default: dflt: { /* it is a pattern item */ | 412 | default: dflt: { /* it is a pattern item */ |
413 | const char *ep = luaI_classend(ms, p); /* points to what is next */ | 413 | const char *ep = classend(ms, p); /* points to what is next */ |
414 | int m = s<ms->src_end && luaI_singlematch(uchar(*s), p, ep); | 414 | int m = s<ms->src_end && singlematch(uchar(*s), p, ep); |
415 | switch (*ep) { | 415 | switch (*ep) { |
416 | case '?': { /* optional */ | 416 | case '?': { /* optional */ |
417 | const char *res; | 417 | const char *res; |
@@ -642,7 +642,7 @@ static int str_gsub (lua_State *L) { | |||
642 | #define MAX_FORMAT 20 | 642 | #define MAX_FORMAT 20 |
643 | 643 | ||
644 | 644 | ||
645 | static void luaI_addquoted (lua_State *L, luaL_Buffer *b, int arg) { | 645 | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { |
646 | size_t l; | 646 | size_t l; |
647 | const char *s = luaL_checklstring(L, arg, &l); | 647 | const char *s = luaL_checklstring(L, arg, &l); |
648 | luaL_putchar(b, '"'); | 648 | luaL_putchar(b, '"'); |
@@ -726,7 +726,7 @@ static int str_format (lua_State *L) { | |||
726 | break; | 726 | break; |
727 | } | 727 | } |
728 | case 'q': { | 728 | case 'q': { |
729 | luaI_addquoted(L, &b, arg); | 729 | addquoted(L, &b, arg); |
730 | continue; /* skip the `addsize' at the end */ | 730 | continue; /* skip the `addsize' at the end */ |
731 | } | 731 | } |
732 | case 's': { | 732 | case 's': { |