소스 검색

easier to add new initialization functions

Roberto Ierusalimschy 24 년 전
부모
커밋
322b7b5fc5
3개의 변경된 파일14개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 7
      ltests.c
  2. 2 2
      ltests.h
  3. 11 3
      lua.c

+ 1 - 7
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 1.62 2001/02/02 15:13:05 roberto Exp roberto $
+** $Id: ltests.c,v 1.63 2001/02/06 16:01:29 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -652,12 +652,6 @@ void luaB_opentests (lua_State *L) {
   luaL_openl(L, tests_funcs);  /* open functions inside new table */
   lua_setglobals(L);  /* restore old table of globals */
   lua_setglobal(L, "T");  /* set new table as global T */
-  /* open other libraries */
-  lua_baselibopen(L);
-  lua_iolibopen(L);
-  lua_strlibopen(L);
-  lua_mathlibopen(L);
-  lua_dblibopen(L);
 }
 
 #endif

+ 2 - 2
ltests.h

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.h,v 1.2 2001/02/05 19:08:01 roberto Exp roberto $
+** $Id: ltests.h,v 1.3 2001/02/06 16:01:29 roberto Exp roberto $
 ** Internal Header for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -49,7 +49,7 @@ extern lua_State *lua_state;
 
 void luaB_opentests (lua_State *L);
 
-#define LUA_USERINIT(L) luaB_opentests(L)
+#define LUA_USERINIT(L) (luaB_opentests(L), openstdlibs(L))
 
 
 #endif

+ 11 - 3
lua.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.c,v 1.57 2001/01/22 18:01:38 roberto Exp roberto $
+** $Id: lua.c,v 1.58 2001/01/26 11:45:51 roberto Exp roberto $
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 */
@@ -30,8 +30,7 @@ static int isatty (int x) { return x==0; }  /* assume stdin is a tty */
 
 
 #ifndef LUA_USERINIT
-#define LUA_USERINIT(L)	(lua_baselibopen(L), lua_iolibopen(L), \
-    lua_strlibopen(L), lua_mathlibopen(L), lua_dblibopen(L))
+#define LUA_USERINIT(L)		openstdlibs(L)
 #endif
 
 
@@ -310,6 +309,15 @@ static void register_getargs (char *argv[]) {
 }
 
 
+static void openstdlibs (lua_State *l) {
+  lua_baselibopen(l);
+  lua_iolibopen(l);
+  lua_strlibopen(l);
+  lua_mathlibopen(l);
+  lua_dblibopen(l);
+}
+
+
 int main (int argc, char *argv[]) {
   struct Options opt;
   int status;