Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions luachild-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build = {
["luachild"] = {
defines = { "USE_POSIX" },
incdirs = { "./" },
sources = { "luachild_common.c", "luachild_lua_5_3.c", "luachild_luajit_2_1.c", "luachild_posix.c", "luachild_windows.c", }
sources = { "luachild_common.c", "luachild_lua_5_3.c", "luachild_lua_5_1.c", "luachild_luajit_2_1.c", "luachild_posix.c", "luachild_windows.c", }
},
},
},
Expand All @@ -39,7 +39,7 @@ build = {
["luachild"] = {
defines = { "USE_WINDOWS" },
incdirs = { "./" },
sources = { "luachild_common.c", "luachild_lua_5_3.c", "luachild_luajit_2_1.c", "luachild_posix.c", "luachild_windows.c", }
sources = { "luachild_common.c", "luachild_lua_5_3.c", "luachild_lua_5_1.c", "luachild_luajit_2_1.c", "luachild_posix.c", "luachild_windows.c", }
},
},
},
Expand Down
9 changes: 8 additions & 1 deletion luachild_lua_5_1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "luachild.h"
#ifdef USE_LUAPUC
#if LUA_VERSION_NUM == 501

#include <stdio.h>
#include <errno.h>
Expand Down Expand Up @@ -40,10 +41,16 @@ int file_handler_creator(lua_State *L, const char * file_path, int get_path_from

void lua_pushcfile(lua_State *L, FILE * f){
FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
*pf = f;
luaL_getmetatable(L, LUA_FILEHANDLE);
lua_setmetatable(L, -2);
*pf = f;
// create and set an env table with a __close function field
lua_createtable(L, 0, 1);
lua_pushcfunction(L, file_close);
lua_setfield(L, -2, "__close");
lua_setfenv(L, -2);
}

#endif // LUA_VERSION_NUM == 501
#endif // USE_LUAPUC

2 changes: 2 additions & 0 deletions luachild_lua_5_3.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "luachild.h"
#ifdef USE_LUAPUC
#if LUA_VERSION_NUM >= 502

#include <stdio.h>
#include <errno.h>
Expand Down Expand Up @@ -46,5 +47,6 @@ void lua_pushcfile(lua_State *L, FILE * f){
lf->closef = &file_close;
}

#endif // LUA_VERSION_NUM >= 502
#endif // USE_LUAPUC