Browse Source

compile option EXTRALIB for builtin functions that can be written in Lua.

Roberto Ierusalimschy 26 years ago
parent
commit
76179a1014
2 changed files with 21 additions and 14 deletions
  1. 14 10
      lbuiltin.c
  2. 7 4
      makefile

+ 14 - 10
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
 };
 
 

+ 7 - 4
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