aboutsummaryrefslogtreecommitdiff
path: root/table.c
diff options
context:
space:
mode:
Diffstat (limited to 'table.c')
-rw-r--r--table.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/table.c b/table.c
index 71912404..2bef4d0f 100644
--- a/table.c
+++ b/table.c
@@ -3,9 +3,10 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.64 1997/03/31 14:02:58 roberto Exp roberto $"; 6char *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*/
204void luaI_nextvar (void) 205void 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