diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-22 16:13:12 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-22 16:13:12 -0300 |
| commit | d5feffdb607e4376bcea32c3642131962aa6857f (patch) | |
| tree | cb540b7352a2086156e5679a347ef1d72accce81 /lbuiltin.c | |
| parent | bb5627f3a4c9c8bf25b836f07708067b1170dde5 (diff) | |
| download | lua-d5feffdb607e4376bcea32c3642131962aa6857f.tar.gz lua-d5feffdb607e4376bcea32c3642131962aa6857f.tar.bz2 lua-d5feffdb607e4376bcea32c3642131962aa6857f.zip | |
new function lua_nextvar
Diffstat (limited to 'lbuiltin.c')
| -rw-r--r-- | lbuiltin.c | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbuiltin.c,v 1.51 1999/02/12 19:23:02 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.52 1999/02/22 14:17:24 roberto Exp roberto $ |
| 3 | ** Built-in functions | 3 | ** Built-in functions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -517,16 +517,12 @@ static void luaB_nextvar (void) { | |||
| 517 | TObject *o = luaA_Address(luaL_nonnullarg(1)); | 517 | TObject *o = luaA_Address(luaL_nonnullarg(1)); |
| 518 | TaggedString *g; | 518 | TaggedString *g; |
| 519 | if (ttype(o) == LUA_T_NIL) | 519 | if (ttype(o) == LUA_T_NIL) |
| 520 | g = (TaggedString *)L->rootglobal.next; /* first variable */ | 520 | g = NULL; |
| 521 | else { | 521 | else { |
| 522 | luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected"); | 522 | luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected"); |
| 523 | g = tsvalue(o); /* find given variable name */ | 523 | g = tsvalue(o); |
| 524 | /* check whether name is in global var list */ | ||
| 525 | luaL_arg_check((GCnode *)g != g->head.next, 1, "variable name expected"); | ||
| 526 | g = (TaggedString *)g->head.next; /* get next */ | ||
| 527 | } | 524 | } |
| 528 | while (g && g->u.s.globalval.ttype == LUA_T_NIL) /* skip globals with nil */ | 525 | g = luaA_nextvar(g); |
| 529 | g = (TaggedString *)g->head.next; | ||
| 530 | if (g) { | 526 | if (g) { |
| 531 | pushtagstring(g); | 527 | pushtagstring(g); |
| 532 | luaA_pushobject(&g->u.s.globalval); | 528 | luaA_pushobject(&g->u.s.globalval); |
