From 5e8a9e324ccdba03b326f8a8fafa0446042975a5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 15 Aug 2005 11:12:32 -0300 Subject: luaL_openlib -> luaL_register, luaL_putchar -> luaL_addchar --- lbaselib.c | 6 +++--- ldblib.c | 4 ++-- liolib.c | 6 +++--- lmathlib.c | 4 ++-- loadlib.c | 4 ++-- loslib.c | 4 ++-- lstrlib.c | 32 ++++++++++++++++---------------- ltablib.c | 4 ++-- ltests.c | 6 +++--- luaconf.h | 11 ++++++++++- 10 files changed, 45 insertions(+), 36 deletions(-) diff --git a/lbaselib.c b/lbaselib.c index 00f613cf..d4a93005 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.179 2005/07/07 15:48:29 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.180 2005/07/12 18:15:11 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -602,7 +602,7 @@ static void auxopen (lua_State *L, const char *name, static void base_open (lua_State *L) { lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */ + luaL_register(L, NULL, base_funcs); /* open lib into global table */ lua_pushliteral(L, LUA_VERSION); lua_setglobal(L, "_VERSION"); /* set global _VERSION */ /* `ipairs' and `pairs' need auxiliary functions as upvalues */ @@ -627,7 +627,7 @@ static void base_open (lua_State *L) { LUALIB_API int luaopen_base (lua_State *L) { base_open(L); - luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0); + luaL_register(L, LUA_COLIBNAME, co_funcs); return 2; } diff --git a/ldblib.c b/ldblib.c index ac516ca8..3716a4dd 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.98 2005/05/17 19:49:15 roberto Exp roberto $ +** $Id: ldblib.c,v 1.99 2005/07/12 14:32:08 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -384,7 +384,7 @@ static const luaL_reg dblib[] = { LUALIB_API int luaopen_debug (lua_State *L) { - luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); + luaL_register(L, LUA_DBLIBNAME, dblib); return 1; } diff --git a/liolib.c b/liolib.c index 3f5771ad..a029190d 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.63 2005/06/06 18:42:21 roberto Exp roberto $ +** $Id: liolib.c,v 2.64 2005/07/12 14:32:08 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -493,7 +493,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_openlib(L, NULL, flib, 0); /* file methods */ + luaL_register(L, NULL, flib); /* file methods */ } @@ -513,7 +513,7 @@ LUALIB_API int luaopen_io (lua_State *L) { lua_newtable(L); lua_replace(L, LUA_ENVIRONINDEX); /* open library */ - luaL_openlib(L, LUA_IOLIBNAME, iolib, 0); + luaL_register(L, LUA_IOLIBNAME, iolib); /* create (and set) default files */ createstdfile(L, stdin, IO_INPUT, "stdin"); createstdfile(L, stdout, IO_OUTPUT, "stdout"); diff --git a/lmathlib.c b/lmathlib.c index 17253b28..45c204f9 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.64 2005/06/13 21:20:14 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.65 2005/07/11 23:58:35 roberto Exp roberto $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -249,7 +249,7 @@ static const luaL_reg mathlib[] = { ** Open math library */ LUALIB_API int luaopen_math (lua_State *L) { - luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); + luaL_register(L, LUA_MATHLIBNAME, mathlib); lua_pushnumber(L, PI); lua_setfield(L, -2, "pi"); lua_pushnumber(L, HUGE_VAL); diff --git a/loadlib.c b/loadlib.c index 55c9d477..d50a587a 100644 --- a/loadlib.c +++ b/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.36 2005/08/09 17:58:09 roberto Exp roberto $ +** $Id: loadlib.c,v 1.37 2005/08/10 18:06:58 roberto Exp roberto $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -625,7 +625,7 @@ LUALIB_API int luaopen_package (lua_State *L) { #endif lua_setfield(L, -2, "loadlib"); lua_pushvalue(L, LUA_GLOBALSINDEX); - luaL_openlib(L, NULL, ll_funcs, 0); /* open lib into global table */ + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ return 1; } diff --git a/loslib.c b/loslib.c index 48dc9179..0be07e53 100644 --- a/loslib.c +++ b/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.9 2005/05/17 19:49:15 roberto Exp roberto $ +** $Id: loslib.c,v 1.10 2005/05/25 13:21:26 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -229,7 +229,7 @@ static const luaL_reg syslib[] = { LUALIB_API int luaopen_os (lua_State *L) { - luaL_openlib(L, LUA_OSLIBNAME, syslib, 0); + luaL_register(L, LUA_OSLIBNAME, syslib); return 1; } diff --git a/lstrlib.c b/lstrlib.c index a80a00ba..1c1f9add 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.120 2005/07/31 16:47:34 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.121 2005/08/09 17:42:02 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -58,7 +58,7 @@ static int str_reverse (lua_State *L) { luaL_Buffer b; const char *s = luaL_checklstring(L, 1, &l); luaL_buffinit(L, &b); - while (l--) luaL_putchar(&b, s[l]); + while (l--) luaL_addchar(&b, s[l]); luaL_pushresult(&b); return 1; } @@ -71,7 +71,7 @@ static int str_lower (lua_State *L) { const char *s = luaL_checklstring(L, 1, &l); luaL_buffinit(L, &b); for (i=0; isrc) /* non empty match? */ src = e; /* skip it */ else if (src < ms.src_end) - luaL_putchar(&b, *src++); + luaL_addchar(&b, *src++); else break; if (anchor) break; } @@ -673,12 +673,12 @@ static int str_gsub (lua_State *L) { static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { size_t l; const char *s = luaL_checklstring(L, arg, &l); - luaL_putchar(b, '"'); + luaL_addchar(b, '"'); while (l--) { switch (*s) { case '"': case '\\': case '\n': { - luaL_putchar(b, '\\'); - luaL_putchar(b, *s); + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); break; } case '\0': { @@ -686,13 +686,13 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { break; } default: { - luaL_putchar(b, *s); + luaL_addchar(b, *s); break; } } s++; } - luaL_putchar(b, '"'); + luaL_addchar(b, '"'); } @@ -728,9 +728,9 @@ static int str_format (lua_State *L) { luaL_buffinit(L, &b); while (strfrmt < strfrmt_end) { if (*strfrmt != L_ESC) - luaL_putchar(&b, *strfrmt++); + luaL_addchar(&b, *strfrmt++); else if (*++strfrmt == L_ESC) - luaL_putchar(&b, *strfrmt++); /* %% */ + luaL_addchar(&b, *strfrmt++); /* %% */ else { /* format item */ char form[MAX_FORMAT]; /* to store the format (`%...') */ char buff[MAX_ITEM]; /* to store the formatted item */ @@ -818,7 +818,7 @@ static void createmetatable (lua_State *L) { ** Open string library */ LUALIB_API int luaopen_string (lua_State *L) { - luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); + luaL_register(L, LUA_STRLIBNAME, strlib); #if defined(LUA_COMPAT_GFIND) lua_getfield(L, -1, "gmatch"); lua_setfield(L, -2, "gfind"); diff --git a/ltablib.c b/ltablib.c index a9182d25..a319b6b2 100644 --- a/ltablib.c +++ b/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.32 2005/07/11 18:48:02 roberto Exp roberto $ +** $Id: ltablib.c,v 1.33 2005/07/12 14:32:08 roberto Exp roberto $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -250,7 +250,7 @@ static const luaL_reg tab_funcs[] = { LUALIB_API int luaopen_table (lua_State *L) { - luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 0); + luaL_register(L, LUA_TABLIBNAME, tab_funcs); return 1; } diff --git a/ltests.c b/ltests.c index a6d39b7b..ba2f01a1 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.26 2005/07/11 14:00:59 roberto Exp roberto $ +** $Id: ltests.c,v 2.27 2005/07/12 14:32:08 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -730,7 +730,7 @@ static int loadlib (lua_State *L) { lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_checknumber(L, 1))); lua_pushvalue(L1, LUA_GLOBALSINDEX); - luaL_openlib(L1, NULL, libs, 0); + luaL_register(L1, NULL, libs); return 0; } @@ -1161,7 +1161,7 @@ int luaB_opentests (lua_State *L) { lua_assert(ud == cast(void *, &memcontrol)); lua_atpanic(L, l_panic); lua_state = L; /* keep first state to be opened */ - luaL_openlib(L, "T", tests_funcs, 0); + luaL_register(L, "T", tests_funcs); atexit(fim); return 0; } diff --git a/luaconf.h b/luaconf.h index 650ee8cf..34c4c05e 100644 --- a/luaconf.h +++ b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.57 2005/08/04 13:37:10 roberto Exp roberto $ +** $Id: luaconf.h,v 1.58 2005/08/09 17:57:29 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -330,6 +330,15 @@ #define LUA_COMPAT_GFIND +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_registry' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + /* @@ luai_apicheck is the assert macro used by the Lua-C API. -- cgit v1.2.3-55-g6feb