aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 1d8f8abf..4650b4b3 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.100 2002/10/22 19:41:08 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.101 2002/10/25 20:05:28 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -271,6 +271,25 @@ static int luaB_loadstring (lua_State *L) {
271} 271}
272 272
273 273
274static int writer (lua_State *L, const void* b, size_t size, void* B) {
275 (void)L;
276 luaL_addlstring((luaL_Buffer*) B, b, size);
277 return 1;
278}
279
280
281static int luaB_stringdump (lua_State *L) {
282 luaL_Buffer b;
283 luaL_check_type(L, 1, LUA_TFUNCTION);
284 luaL_buffinit(L,&b);
285 if (!lua_dump(L, writer, &b))
286 luaL_error(L, "unable to dump given function");
287 luaL_pushresult(&b);
288 return 1;
289}
290
291
292
274static int luaB_loadfile (lua_State *L) { 293static int luaB_loadfile (lua_State *L) {
275 const char *fname = luaL_opt_string(L, 1, NULL); 294 const char *fname = luaL_opt_string(L, 1, NULL);
276 return passresults(L, luaL_loadfile(L, fname)); 295 return passresults(L, luaL_loadfile(L, fname));
@@ -524,6 +543,7 @@ static const luaL_reg base_funcs[] = {
524 {"collectgarbage", luaB_collectgarbage}, 543 {"collectgarbage", luaB_collectgarbage},
525 {"gcinfo", luaB_gcinfo}, 544 {"gcinfo", luaB_gcinfo},
526 {"loadfile", luaB_loadfile}, 545 {"loadfile", luaB_loadfile},
546 {"stringdump", luaB_stringdump},
527 {"dofile", luaB_dofile}, 547 {"dofile", luaB_dofile},
528 {"loadstring", luaB_loadstring}, 548 {"loadstring", luaB_loadstring},
529 {"require", luaB_require}, 549 {"require", luaB_require},