diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-20 08:26:33 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-20 08:26:33 -0200 |
commit | 32fd039bb563b24cbe4621dcc9b3cc18d9e078b0 (patch) | |
tree | 381804f8030b6d1d09b5cc35bd46511d7dc29739 | |
parent | 75f73172c463af9643bc187eed7f1fd195238078 (diff) | |
download | lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.tar.gz lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.tar.bz2 lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.zip |
`openlib' functions return new module
-rw-r--r-- | ldblib.c | 4 | ||||
-rw-r--r-- | liolib.c | 4 | ||||
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 4 | ||||
-rw-r--r-- | ltablib.c | 4 | ||||
-rw-r--r-- | ltests.c | 25 |
6 files changed, 27 insertions, 18 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.75 2002/12/05 17:50:10 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.76 2002/12/19 11:11:55 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -292,6 +292,6 @@ LUALIB_API int lua_dblibopen (lua_State *L) { | |||
292 | lua_pushliteral(L, "_TRACEBACK"); | 292 | lua_pushliteral(L, "_TRACEBACK"); |
293 | lua_pushcfunction(L, errorfb); | 293 | lua_pushcfunction(L, errorfb); |
294 | lua_settable(L, LUA_GLOBALSINDEX); | 294 | lua_settable(L, LUA_GLOBALSINDEX); |
295 | return 0; | 295 | return 1; |
296 | } | 296 | } |
297 | 297 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.27 2002/12/04 15:27:17 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.28 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -732,6 +732,6 @@ LUALIB_API int lua_iolibopen (lua_State *L) { | |||
732 | registerfile(L, stdin, "stdin", IO_INPUT); | 732 | registerfile(L, stdin, "stdin", IO_INPUT); |
733 | registerfile(L, stdout, "stdout", IO_OUTPUT); | 733 | registerfile(L, stdout, "stdout", IO_OUTPUT); |
734 | registerfile(L, stderr, "stderr", NULL); | 734 | registerfile(L, stderr, "stderr", NULL); |
735 | return 0; | 735 | return 1; |
736 | } | 736 | } |
737 | 737 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.52 2002/11/14 15:41:38 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.53 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -241,6 +241,6 @@ LUALIB_API int lua_mathlibopen (lua_State *L) { | |||
241 | lua_pushliteral(L, "__pow"); | 241 | lua_pushliteral(L, "__pow"); |
242 | lua_pushcfunction(L, math_pow); | 242 | lua_pushcfunction(L, math_pow); |
243 | lua_settable(L, LUA_REGISTRYINDEX); | 243 | lua_settable(L, LUA_REGISTRYINDEX); |
244 | return 0; | 244 | return 1; |
245 | } | 245 | } |
246 | 246 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.91 2002/11/25 17:33:33 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.92 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -763,6 +763,6 @@ static const luaL_reg strlib[] = { | |||
763 | */ | 763 | */ |
764 | LUALIB_API int lua_strlibopen (lua_State *L) { | 764 | LUALIB_API int lua_strlibopen (lua_State *L) { |
765 | luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); | 765 | luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); |
766 | return 0; | 766 | return 1; |
767 | } | 767 | } |
768 | 768 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.16 2002/11/14 15:41:38 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.17 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -296,6 +296,6 @@ LUALIB_API int lua_tablibopen (lua_State *L) { | |||
296 | lua_pushliteral(L, "k"); | 296 | lua_pushliteral(L, "k"); |
297 | lua_rawset(L, -3); /* metatable(N).__mode = "k" */ | 297 | lua_rawset(L, -3); /* metatable(N).__mode = "k" */ |
298 | luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 1); | 298 | luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 1); |
299 | return 0; | 299 | return 1; |
300 | } | 300 | } |
301 | 301 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.148 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.149 2002/12/19 11:11:55 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -457,13 +457,21 @@ static int newstate (lua_State *L) { | |||
457 | return 1; | 457 | return 1; |
458 | } | 458 | } |
459 | 459 | ||
460 | |||
460 | static int loadlib (lua_State *L) { | 461 | static int loadlib (lua_State *L) { |
461 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_checknumber(L, 1))); | 462 | static const luaL_reg libs[] = { |
462 | lua_register(L1, "mathlibopen", lua_mathlibopen); | 463 | {"mathlibopen", lua_mathlibopen}, |
463 | lua_register(L1, "strlibopen", lua_strlibopen); | 464 | {"strlibopen", lua_strlibopen}, |
464 | lua_register(L1, "iolibopen", lua_iolibopen); | 465 | {"iolibopen", lua_iolibopen}, |
465 | lua_register(L1, "dblibopen", lua_dblibopen); | 466 | {"tablibopen", lua_tablibopen}, |
466 | lua_register(L1, "baselibopen", lua_baselibopen); | 467 | {"dblibopen", lua_dblibopen}, |
468 | {"baselibopen", lua_baselibopen}, | ||
469 | {NULL, NULL} | ||
470 | }; | ||
471 | lua_State *L1 = cast(lua_State *, | ||
472 | cast(unsigned long, luaL_checknumber(L, 1))); | ||
473 | lua_pushvalue(L1, LUA_GLOBALSINDEX); | ||
474 | luaL_openlib(L1, NULL, libs, 0); | ||
467 | return 0; | 475 | return 0; |
468 | } | 476 | } |
469 | 477 | ||
@@ -486,7 +494,8 @@ static int doremote (lua_State *L) { | |||
486 | if (status != 0) { | 494 | if (status != 0) { |
487 | lua_pushnil(L); | 495 | lua_pushnil(L); |
488 | lua_pushnumber(L, status); | 496 | lua_pushnumber(L, status); |
489 | return 2; | 497 | lua_pushstring(L, lua_tostring(L1, -1)); |
498 | return 3; | ||
490 | } | 499 | } |
491 | else { | 500 | else { |
492 | int i = 0; | 501 | int i = 0; |