diff --git a/lauxlib.h b/lauxlib.h index 708297f5..b996a6f1 100644 --- a/lauxlib.h +++ b/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.13 1999/08/16 20:52:00 roberto Exp roberto $ +** $Id: lauxlib.h,v 1.14 1999/11/22 13:12:07 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -22,12 +22,13 @@ struct luaL_reg { #define luaL_arg_check(L, cond,numarg,extramsg) if (!(cond)) \ luaL_argerror(L, numarg,extramsg) -#define luaL_check_string(L, n) (luaL_check_lstr(L, (n), NULL)) -#define luaL_opt_string(L, n, d) (luaL_opt_lstr(L, (n), (d), NULL)) -#define luaL_check_int(L, n) ((int)luaL_check_number(L, n)) -#define luaL_check_long(L, n) ((long)luaL_check_number(L, n)) -#define luaL_opt_int(L, n,d) ((int)luaL_opt_number(L, n,d)) -#define luaL_opt_long(L, n,d) ((long)luaL_opt_number(L, n,d)) +#define luaL_check_string(L,n) (luaL_check_lstr(L, (n), NULL)) +#define luaL_opt_string(L,n,d) (luaL_opt_lstr(L, (n), (d), NULL)) +#define luaL_check_int(L,n) ((int)luaL_check_number(L, n)) +#define luaL_check_long(L,n) ((long)luaL_check_number(L, n)) +#define luaL_opt_int(L,n,d) ((int)luaL_opt_number(L, n,d)) +#define luaL_opt_long(L,n,d) ((long)luaL_opt_number(L, n,d)) +#define luaL_openl(L,a) luaL_openlib(L, a, (sizeof(a)/sizeof(a[0]))) #else @@ -39,6 +40,7 @@ struct luaL_reg { #define luaL_check_long(n) ((long)luaL_check_number(n)) #define luaL_opt_int(n,d) ((int)luaL_opt_number(n,d)) #define luaL_opt_long(n,d) ((long)luaL_opt_number(n,d)) +#define luaL_openl(a) luaL_openlib(a, (sizeof(a)/sizeof(a[0]))) #endif diff --git a/lbuiltin.c b/lbuiltin.c index da8a573c..13b111de 100644 --- a/lbuiltin.c +++ b/lbuiltin.c @@ -1,5 +1,5 @@ /* -** $Id: lbuiltin.c,v 1.73 1999/11/16 12:50:48 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.74 1999/11/22 13:12:07 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -810,7 +810,7 @@ void luaB_predefine (lua_State *L) { /* pre-register mem error messages, to avoid loop when error arises */ luaS_newfixedstring(L, tableEM); luaS_newfixedstring(L, memEM); - luaL_openlib(L, builtin_funcs, (sizeof(builtin_funcs)/sizeof(builtin_funcs[0]))); + luaL_openl(L, builtin_funcs); lua_pushstring(L, LUA_VERSION); lua_setglobal(L, "_VERSION"); } diff --git a/ldblib.c b/ldblib.c index 0bd3cc52..3c3dd468 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.6 1999/08/16 20:52:00 roberto Exp roberto $ +** $Id: ldblib.c,v 1.7 1999/11/22 13:12:07 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -214,6 +214,6 @@ static const struct luaL_reg dblib[] = { void lua_dblibopen (lua_State *L) { - luaL_openlib(L, dblib, (sizeof(dblib)/sizeof(dblib[0]))); + luaL_openl(L, dblib); } diff --git a/liolib.c b/liolib.c index 1a414a9d..e2bac28c 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.50 1999/11/09 17:59:35 roberto Exp roberto $ +** $Id: liolib.c,v 1.51 1999/11/22 13:12:07 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -632,8 +632,7 @@ static void openwithtags (lua_State *L) { } void lua_iolibopen (lua_State *L) { - /* register lib functions */ - luaL_openlib(L, iolib, (sizeof(iolib)/sizeof(iolib[0]))); + luaL_openl(L, iolib); openwithtags(L); } diff --git a/lmathlib.c b/lmathlib.c index ee688a50..83c8e0bc 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.19 1999/08/18 14:40:51 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.20 1999/11/22 13:12:07 roberto Exp roberto $ ** Lua standard mathematical library ** See Copyright Notice in lua.h */ @@ -199,7 +199,7 @@ static const struct luaL_reg mathlib[] = { ** Open math library */ void lua_mathlibopen (lua_State *L) { - luaL_openlib(L, mathlib, (sizeof(mathlib)/sizeof(mathlib[0]))); + luaL_openl(L, mathlib); lua_pushcfunction(L, math_pow); lua_pushnumber(L, 0); /* to get its tag */ lua_settagmethod(L, lua_tag(L, lua_pop(L)), "pow"); diff --git a/lstrlib.c b/lstrlib.c index c973d0e4..4f67a72c 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.36 1999/11/11 16:45:04 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.37 1999/11/22 13:12:07 roberto Exp roberto $ ** Standard library for strings and pattern-matching ** See Copyright Notice in lua.h */ @@ -614,7 +614,6 @@ static const struct luaL_reg strlib[] = { /* ** Open string library */ -void lua_strlibopen (lua_State *L) -{ - luaL_openlib(L, strlib, (sizeof(strlib)/sizeof(strlib[0]))); +void lua_strlibopen (lua_State *L) { + luaL_openl(L, strlib); }