From 76179a1014430f42148822ac2db23a9491817a0b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 4 Feb 1999 17:12:35 -0200 Subject: [PATCH] compile option EXTRALIB for builtin functions that can be written in Lua. --- lbuiltin.c | 24 ++++++++++++++---------- makefile | 11 +++++++---- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lbuiltin.c b/lbuiltin.c index 44b3bf23..a307e883 100644 --- a/lbuiltin.c +++ b/lbuiltin.c @@ -1,5 +1,5 @@ /* -** $Id: lbuiltin.c,v 1.47 1999/01/25 12:30:11 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.48 1999/01/26 15:38:01 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -71,11 +71,6 @@ static Hash *gethash (int arg) { return avalue(luaA_Address(luaL_tablearg(arg))); } - -static void luaB_getn (void) { - lua_pushnumber(getnarg(gethash(1))); -} - /* }====================================================== */ @@ -306,6 +301,7 @@ static void luaB_call (void) { /* }====================================================== */ +#ifdef EXTRALIB /* ** {====================================================== ** "Extra" functions @@ -385,6 +381,11 @@ static void luaB_foreachvar (void) { } +static void luaB_getn (void) { + lua_pushnumber(getnarg(gethash(1))); +} + + static void luaB_tinsert (void) { Hash *a = gethash(1); lua_Object v = lua_getparam(3); @@ -500,6 +501,7 @@ static void luaB_sort (void) { } /* }}===================================================== */ +#endif /* @@ -685,7 +687,6 @@ static struct luaL_reg builtin_funcs[] = { {"dostring", luaB_dostring}, {"error", luaB_error}, {"getglobal", luaB_getglobal}, - {"getn", luaB_getn}, {"gettagmethod", luaB_gettagmethod}, {"newtag", luaB_newtag}, {"next", luaB_next}, @@ -702,15 +703,18 @@ static struct luaL_reg builtin_funcs[] = { {"tag", luaB_luatag}, {"tonumber", luaB_tonumber}, {"tostring", luaB_tostring}, - {"type", luaB_type}, -/* "Extra" functions */ - {"assert", luaB_assert}, + {"type", luaB_type} +#ifdef EXTRALIB + /* "Extra" functions */ + ,{"assert", luaB_assert}, {"foreach", luaB_foreach}, {"foreachi", luaB_foreachi}, {"foreachvar", luaB_foreachvar}, + {"getn", luaB_getn}, {"sort", luaB_sort}, {"tinsert", luaB_tinsert}, {"tremove", luaB_tremove} +#endif }; diff --git a/makefile b/makefile index 2e0046c7..289bf037 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # -## $Id: makefile,v 1.15 1999/01/11 20:23:54 roberto Exp roberto $ +## $Id: makefile,v 1.16 1999/02/04 16:37:41 roberto Exp roberto $ ## Makefile ## See Copyright Notice in lua.h # @@ -12,16 +12,19 @@ # define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant # # define (undefine) OLD_ANSI if your system does NOT have some new ANSI -# facilities (e.g. strerror, locale.h, memmove). Although they are ANSI, -# SunOS does not comply; so, add "-DOLD_ANSI" on SunOS +# facilities (e.g. strerror, locale.h, memmove). SunOS does not comply; +# so, add "-DOLD_ANSI" on SunOS # # define LUA_COMPAT2_5 if yous system does need to be compatible with # version 2.5 (or older) # # define LUA_NUM_TYPE if you need numbers to be different from double # (for instance, -DLUA_NUM_TYPE=float) +# +# undefine EXTRALIB if you do not want builtin functions that can be +# written in Lua (sort, tinsert, tremove, assert, foreach*) -CONFIG = -DPOPEN -D_POSIX_SOURCE +CONFIG = -DPOPEN -D_POSIX_SOURCE -DEXTRALIB #CONFIG = -DLUA_COMPAT2_5 -DOLD_ANSI -DDEBUG