diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-11-05 09:59:14 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-11-05 09:59:14 -0200 |
| commit | fa198197a0202bd3a7b68d228cd1c2fd88166ff7 (patch) | |
| tree | 536f37e38fb5e80fa580c42f2d09d6e10410e075 /lauxlib.c | |
| parent | 1e944de6cb6a20f6abeaab6f5d1039d06d8d2812 (diff) | |
| download | lua-fa198197a0202bd3a7b68d228cd1c2fd88166ff7.tar.gz lua-fa198197a0202bd3a7b68d228cd1c2fd88166ff7.tar.bz2 lua-fa198197a0202bd3a7b68d228cd1c2fd88166ff7.zip | |
lua_(set)getglobal are ok to use
Diffstat (limited to 'lauxlib.c')
| -rw-r--r-- | lauxlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.106 2003/10/10 12:57:55 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.107 2003/10/20 18:32:55 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -238,13 +238,13 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
| 238 | const luaL_reg *l, int nup) { | 238 | const luaL_reg *l, int nup) { |
| 239 | if (libname) { | 239 | if (libname) { |
| 240 | /* check whether lib already exists */ | 240 | /* check whether lib already exists */ |
| 241 | lua_getfield(L, LUA_GLOBALSINDEX, libname); | 241 | lua_getglobal(L, libname); |
| 242 | if (lua_isnil(L, -1)) { /* no? */ | 242 | if (lua_isnil(L, -1)) { /* no? */ |
| 243 | lua_pop(L, 1); | 243 | lua_pop(L, 1); |
| 244 | lua_newtable(L); /* create it */ | 244 | lua_newtable(L); /* create it */ |
| 245 | lua_pushvalue(L, -1); | 245 | lua_pushvalue(L, -1); |
| 246 | /* register it with given name */ | 246 | /* register it with given name */ |
| 247 | lua_setfield(L, LUA_GLOBALSINDEX, libname); | 247 | lua_setglobal(L, libname); |
| 248 | } | 248 | } |
| 249 | lua_insert(L, -(nup+1)); /* move library table to below upvalues */ | 249 | lua_insert(L, -(nup+1)); /* move library table to below upvalues */ |
| 250 | } | 250 | } |
