summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-07-07 13:44:26 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-07-07 13:44:26 -0300
commit067db30d715c999c3a5f6cb2da3cc7e863732603 (patch)
tree5d0a865c60034e9915c834c4cce61072c319fe14
parentda4dbe65b268a76a10f8294350aba0b239a0fbda (diff)
downloadlua-067db30d715c999c3a5f6cb2da3cc7e863732603.tar.gz
lua-067db30d715c999c3a5f6cb2da3cc7e863732603.tar.bz2
lua-067db30d715c999c3a5f6cb2da3cc7e863732603.zip
"next" & "nextvar" check if argument is a result of previous calls
-rw-r--r--hash.c11
-rw-r--r--table.c11
2 files changed, 13 insertions, 9 deletions
diff --git a/hash.c b/hash.c
index 5ff64c84..64b9b313 100644
--- a/hash.c
+++ b/hash.c
@@ -3,7 +3,7 @@
3** hash manager for lua 3** hash manager for lua
4*/ 4*/
5 5
6char *rcs_hash="$Id: hash.c,v 2.42 1997/05/08 20:43:30 roberto Exp roberto $"; 6char *rcs_hash="$Id: hash.c,v 2.43 1997/05/14 18:38:29 roberto Exp roberto $";
7 7
8 8
9#include "luamem.h" 9#include "luamem.h"
@@ -327,6 +327,11 @@ void lua_next (void)
327 t = avalue(luaI_Address(o)); 327 t = avalue(luaI_Address(o));
328 if (lua_isnil(r)) 328 if (lua_isnil(r))
329 hashnext(t, 0); 329 hashnext(t, 0);
330 else 330 else {
331 hashnext(t, present(t, luaI_Address(r))+1); 331 int i = present(t, luaI_Address(r));
332 Node *n = node(t, i);
333 luaL_arg_check(ttype(ref(n))!=LUA_T_NIL && ttype(val(n))!=LUA_T_NIL,
334 2, "key not found");
335 hashnext(t, i+1);
336 }
332} 337}
diff --git a/table.c b/table.c
index 1ca0b0ec..47ecd2e2 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.71 1997/06/09 17:28:14 roberto Exp roberto $"; 6char *rcs_table="$Id: table.c,v 2.72 1997/06/17 18:09:31 roberto Exp roberto $";
7 7
8#include "luamem.h" 8#include "luamem.h"
9#include "auxlib.h" 9#include "auxlib.h"
@@ -224,11 +224,10 @@ void lua_pack (void)
224*/ 224*/
225void luaI_nextvar (void) 225void luaI_nextvar (void)
226{ 226{
227 Word next; 227 Word next = lua_isnil(lua_getparam(1)) ? 0 :
228 if (lua_isnil(lua_getparam(1))) 228 luaI_findsymbolbyname(luaL_check_string(1))+1;
229 next = 0; 229 if (next != 0)
230 else 230 luaL_arg_check(s_ttype(next-1)!=LUA_T_NIL, 1, "undefined global name");
231 next = luaI_findsymbolbyname(luaL_check_string(1)) + 1;
232 while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) 231 while (next < lua_ntable && s_ttype(next) == LUA_T_NIL)
233 next++; 232 next++;
234 if (next < lua_ntable) { 233 if (next < lua_ntable) {