Browse Source

using new lib auxlib.

v5-2
Roberto Ierusalimschy 28 years ago
parent
commit
9319735744
  1. 13
      hash.c
  2. 35
      table.c

13
hash.c

@ -3,7 +3,7 @@
** hash manager for lua
*/
char *rcs_hash="$Id: hash.c,v 2.38 1997/03/31 14:02:58 roberto Exp roberto $";
char *rcs_hash="$Id: hash.c,v 2.39 1997/03/31 14:17:09 roberto Exp roberto $";
#include "luamem.h"
@ -11,6 +11,7 @@ char *rcs_hash="$Id: hash.c,v 2.38 1997/03/31 14:02:58 roberto Exp roberto $";
#include "hash.h"
#include "table.h"
#include "lua.h"
#include "auxlib.h"
#define nhash(t) ((t)->nhash)
@ -82,7 +83,7 @@ int lua_equalObj (TObject *t1, TObject *t2)
case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf;
case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2);
default:
lua_error("internal error at `lua_equalObj'");
lua_error("internal error in `lua_equalObj'");
return 0; /* UNREACHEABLE */
}
}
@ -301,12 +302,8 @@ void lua_next (void)
Hash *t;
lua_Object o = lua_getparam(1);
lua_Object r = lua_getparam(2);
if (o == LUA_NOOBJECT || r == LUA_NOOBJECT)
lua_error ("too few arguments to function `next'");
if (lua_getparam(3) != LUA_NOOBJECT)
lua_error ("too many arguments to function `next'");
if (!lua_istable(o))
lua_error ("first argument of function `next' is not a table");
luaL_arg_check(lua_istable(o), "next", 1, "table expected");
luaL_arg_check(r != LUA_NOOBJECT, "next", 2, "value expected");
t = avalue(luaI_Address(o));
if (lua_isnil(r))
{

35
table.c

@ -3,9 +3,10 @@
** Module to control static tables
*/
char *rcs_table="$Id: table.c,v 2.64 1997/03/31 14:02:58 roberto Exp roberto $";
char *rcs_table="$Id: table.c,v 2.65 1997/03/31 14:17:09 roberto Exp roberto $";
#include "luamem.h"
#include "auxlib.h"
#include "opcode.h"
#include "tree.h"
#include "hash.h"
@ -203,27 +204,17 @@ void lua_pack (void)
*/
void luaI_nextvar (void)
{
Word next;
lua_Object o = lua_getparam(1);
if (o == LUA_NOOBJECT)
lua_error("too few arguments to function `nextvar'");
if (lua_getparam(2) != LUA_NOOBJECT)
lua_error("too many arguments to function `nextvar'");
if (lua_isnil(o))
next = 0;
else if (!lua_isstring(o))
{
lua_error("incorrect argument to function `nextvar'");
return; /* to avoid warnings */
}
else
next = luaI_findsymbolbyname(lua_getstring(o)) + 1;
while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) next++;
if (next < lua_ntable)
{
lua_pushstring(lua_table[next].varname->str);
luaI_pushobject(&s_object(next));
}
Word next;
if (lua_isnil(lua_getparam(1)))
next = 0;
else
next = luaI_findsymbolbyname(luaL_check_string(1, "nextvar")) + 1;
while (next < lua_ntable && s_ttype(next) == LUA_T_NIL)
next++;
if (next < lua_ntable) {
lua_pushstring(lua_table[next].varname->str);
luaI_pushobject(&s_object(next));
}
}

Loading…
Cancel
Save