diff --git a/lauxlib.c b/lauxlib.c index 38bc27d4..7179507a 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.217 2010/07/02 11:38:13 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.218 2010/07/02 12:01:53 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -664,6 +664,7 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { ** Compatibility with 5.1 module functions ** ======================================================= */ +#if defined(LUA_COMPAT_MODULE) static const char *luaL_findtablex (lua_State *L, int idx, const char *fname, int szhint) { @@ -735,6 +736,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, luaL_setfuncs(L, l, nup); } +#endif /* }====================================================== */ /* diff --git a/liolib.c b/liolib.c index 48687bf8..78ddb806 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.89 2010/07/02 11:38:13 roberto Exp roberto $ +** $Id: liolib.c,v 2.90 2010/07/25 15:18:19 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -583,7 +583,7 @@ static void createmeta (lua_State *L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, flib); /* add file methods to new metatable */ + luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ lua_pop(L, 1); /* pop new metatable */ } diff --git a/loadlib.c b/loadlib.c index 8509b225..d655480a 100644 --- a/loadlib.c +++ b/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.87 2010/07/02 11:38:13 roberto Exp roberto $ +** $Id: loadlib.c,v 1.88 2010/07/25 15:03:37 roberto Exp roberto $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -495,11 +495,10 @@ static int ll_require (lua_State *L) { ** 'module' function ** ======================================================= */ - +#if defined(LUA_COMPAT_MODULE) /* -** FOR COMPATIBILITY ONLY: changes the _ENV variable of -** calling function +** changes the _ENV variable of calling function */ static void set_env (lua_State *L) { lua_Debug ar; @@ -570,6 +569,17 @@ static int ll_seeall (lua_State *L) { } +#else + +static int ll_seeall (lua_State *L) { + return luaL_error(L, "deprecated function"); +} + +static int ll_module (lua_State *L) { + return luaL_error(L, "deprecated function"); +} + +#endif /* }====================================================== */ @@ -648,7 +658,7 @@ LUAMOD_API int luaopen_package (lua_State *L) { lua_setfield(L, -2, "preload"); lua_pushglobaltable(L); lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ - luaL_openlib(L, NULL, ll_funcs, 1); /* open lib into global table */ + luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ lua_pop(L, 1); /* pop global table */ return 1; /* return 'package' table */ } diff --git a/ltests.c b/ltests.c index ec70a954..5c429746 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.110 2010/06/25 12:18:10 roberto Exp roberto $ +** $Id: ltests.c,v 2.111 2010/07/02 11:38:13 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -1463,8 +1463,8 @@ int luaB_opentests (lua_State *L) { lua_assert(lua_getallocf(L, &ud) == debug_realloc); lua_assert(ud == cast(void *, &l_memcontrol)); lua_setallocf(L, lua_getallocf(L, NULL), ud); - luaL_register(L, "T", tests_funcs); - return 0; + luaL_newlib(L, tests_funcs); + return 1; } #endif diff --git a/ltests.h b/ltests.h index 73676f64..1fc1cd37 100644 --- a/ltests.h +++ b/ltests.h @@ -1,5 +1,5 @@ /* -** $Id: ltests.h,v 2.31 2010/04/12 16:07:29 roberto Exp roberto $ +** $Id: ltests.h,v 2.32 2010/04/19 17:40:13 roberto Exp roberto $ ** Internal Header for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -73,7 +73,8 @@ int luaB_opentests (lua_State *L); #if defined(lua_c) #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) -#define luaL_openlibs(L) { (luaL_openlibs)(L); luaB_opentests(L); } +#define luaL_openlibs(L) \ + { (luaL_openlibs)(L); luaL_requiref(L, "T", luaB_opentests, 1); } #endif diff --git a/luaconf.h b/luaconf.h index 8a81f189..ad4e65f9 100644 --- a/luaconf.h +++ b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.140 2010/07/18 14:34:45 roberto Exp roberto $ +** $Id: luaconf.h,v 1.141 2010/07/25 15:02:41 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -273,6 +273,12 @@ /* compatibility with previous wrong spelling */ #define luaL_typerror luaL_typeerror +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + #endif /* LUA_COMPAT_ALL */ /* }================================================================== */