Debian Codegraph @

libs/luajit/TLpatches/patch-lib_package

raw
1 diff -bu a/source/libs/luajit/LuaJIT-src/src/lib_package.c b/source/libs/luajit/LuaJIT-src/src/lib_package.c
2 --- a/source/libs/luajit/LuaJIT-src/src/lib_package.c
3 +++ b/source/libs/luajit/LuaJIT-src/src/lib_package.c
4 @@ -378,6 +378,29 @@
5 return 1; /* library loaded successfully */
6 }
7
8 +#define LUA_POF "luaopen_"
9 +#define LUA_OFSEP "_"
10 +#define POF LUA_POF
11 +
12 +static const char *mkfuncname (lua_State *L, const char *modname) {
13 + const char *funcname;
14 + const char *mark = strchr(modname, *LUA_IGMARK);
15 + if (mark) modname = mark + 1;
16 + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
17 + funcname = lua_pushfstring(L, POF"%s", funcname);
18 + lua_remove(L, -2); /* remove 'gsub' result */
19 + return funcname;
20 +}
21 +
22 +int loader_C_luatex (lua_State *L, const char *name, const char *filename) {
23 + const char *funcname;
24 + funcname = mkfuncname(L, name);
25 + if (ll_loadfunc(L, filename, funcname,0) != 0)
26 + loaderror(L, filename);
27 + return 1; /* library loaded successfully */
28 +}
29 +
30 +
31 static int lj_cf_package_loader_c(lua_State *L)
32 {
33 const char *name = luaL_checkstring(L, 1);
34 @@ -407,6 +430,20 @@
35 return 1;
36 }
37
38 +int loader_Call_luatex (lua_State *L, const char *name, const char *filename) {
39 + const char *funcname;
40 + int stat;
41 + if (filename == NULL) return 1; /* root not found */
42 + funcname = mkfuncname(L, name);
43 + if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) {
44 + if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */
45 + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
46 + name, filename);
47 + return 1; /* function not found */
48 + }
49 + return 1; /* library loaded successfully */
50 +}
51 +
52 static int lj_cf_package_loader_preload(lua_State *L)
53 {
54 const char *name = luaL_checkstring(L, 1);