diff options
Diffstat (limited to 'table.c')
-rw-r--r-- | table.c | 35 |
1 files changed, 13 insertions, 22 deletions
@@ -3,9 +3,10 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.64 1997/03/31 14:02:58 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.65 1997/03/31 14:17:09 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include "luamem.h" | 8 | #include "luamem.h" |
9 | #include "auxlib.h" | ||
9 | #include "opcode.h" | 10 | #include "opcode.h" |
10 | #include "tree.h" | 11 | #include "tree.h" |
11 | #include "hash.h" | 12 | #include "hash.h" |
@@ -203,27 +204,17 @@ void lua_pack (void) | |||
203 | */ | 204 | */ |
204 | void luaI_nextvar (void) | 205 | void luaI_nextvar (void) |
205 | { | 206 | { |
206 | Word next; | 207 | Word next; |
207 | lua_Object o = lua_getparam(1); | 208 | if (lua_isnil(lua_getparam(1))) |
208 | if (o == LUA_NOOBJECT) | 209 | next = 0; |
209 | lua_error("too few arguments to function `nextvar'"); | 210 | else |
210 | if (lua_getparam(2) != LUA_NOOBJECT) | 211 | next = luaI_findsymbolbyname(luaL_check_string(1, "nextvar")) + 1; |
211 | lua_error("too many arguments to function `nextvar'"); | 212 | while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) |
212 | if (lua_isnil(o)) | 213 | next++; |
213 | next = 0; | 214 | if (next < lua_ntable) { |
214 | else if (!lua_isstring(o)) | 215 | lua_pushstring(lua_table[next].varname->str); |
215 | { | 216 | luaI_pushobject(&s_object(next)); |
216 | lua_error("incorrect argument to function `nextvar'"); | 217 | } |
217 | return; /* to avoid warnings */ | ||
218 | } | ||
219 | else | ||
220 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; | ||
221 | while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) next++; | ||
222 | if (next < lua_ntable) | ||
223 | { | ||
224 | lua_pushstring(lua_table[next].varname->str); | ||
225 | luaI_pushobject(&s_object(next)); | ||
226 | } | ||
227 | } | 218 | } |
228 | 219 | ||
229 | 220 | ||