new auxiliary function `luaH_setstr'

This commit is contained in:
Roberto Ierusalimschy
2003-08-26 09:04:13 -03:00
parent 4b2e71ddb6
commit b114142799
3 changed files with 18 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltable.c,v 1.133 2003/04/28 13:31:46 roberto Exp roberto $
** $Id: ltable.c,v 1.134 2003/04/28 19:26:16 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -511,3 +511,15 @@ TObject *luaH_setnum (lua_State *L, Table *t, int key) {
}
}
TObject *luaH_setstr (lua_State *L, Table *t, TString *key) {
const TObject *p = luaH_getstr(t, key);
if (p != &luaO_nilobject)
return cast(TObject *, p);
else {
TObject k;
setsvalue(&k, key);
return newkey(L, t, &k);
}
}