1 diff -bur LuaJIT-src-orig/src/lauxlib.h LuaJIT-src/src/lauxlib.h
2 --- LuaJIT-src-orig/src/lauxlib.h 2016-03-07 09:43:42.708069718 +0100
3 +++ LuaJIT-src/src/lauxlib.h 2016-03-04 16:52:23.000000000 +0100
10 +** {======================================================
11 +** File handles for IO library
12 +** =======================================================
16 +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
17 +** initial structure 'luaL_Stream' (it may contain other fields
18 +** after that initial structure).
21 +#define LUA_FILEHANDLE "FILE*"
24 +typedef struct luaL_Stream {
25 + FILE *f; /* stream (NULL for incompletely created streams) */
26 + lua_CFunction closef; /* to close stream (NULL for closed streams) */
29 +/* }====================================================== */
35 ** ===============================================================
38 LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
39 LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
41 +/* Luajittex needs this one because it overloads loadfile */
42 +LUALIB_API int (RESERVED_load_aux_JIT) (lua_State *L, int status, int envarg);
44 /* }====================================================== */
46 diff -bur LuaJIT-src-orig/src/lib_init.c LuaJIT-src/src/lib_init.c
47 --- LuaJIT-src-orig/src/lib_init.c 2016-03-07 09:43:42.720069718 +0100
48 +++ LuaJIT-src/src/lib_init.c 2016-03-07 11:47:15.847946480 +0100
50 { LUA_DBLIBNAME, luaopen_debug },
51 { LUA_BITLIBNAME, luaopen_bit },
52 { LUA_JITLIBNAME, luaopen_jit },
53 + { LUA_BITLIBNAME_32, luaopen_bit32 },
57 diff -bur LuaJIT-src-orig/src/lib_package.c LuaJIT-src/src/lib_package.c
58 --- LuaJIT-src-orig/src/lib_package.c 2016-03-07 09:43:42.712069718 +0100
59 +++ LuaJIT-src/src/lib_package.c 2016-03-07 11:49:15.655944489 +0100
61 return 1; /* library loaded successfully */
64 +#define LUA_POF "luaopen_"
65 +#define LUA_OFSEP "_"
68 +static const char *mkfuncname (lua_State *L, const char *modname) {
69 + const char *funcname;
70 + const char *mark = strchr(modname, *LUA_IGMARK);
71 + if (mark) modname = mark + 1;
72 + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
73 + funcname = lua_pushfstring(L, POF"%s", funcname);
74 + lua_remove(L, -2); /* remove 'gsub' result */
79 +int loader_C_luatex (lua_State *L, const char *name, const char *filename) {
80 + const char *funcname;
81 + funcname = mkfuncname(L, name);
82 + if (ll_loadfunc(L, filename, funcname,0) != 0)
83 + loaderror(L, filename);
84 + return 1; /* library loaded successfully */
87 static int lj_cf_package_loader_croot(lua_State *L)
94 +int loader_Call_luatex (lua_State *L, const char *name, const char *filename) {
95 + const char *funcname;
97 + if (filename == NULL) return 1; /* root not found */
98 + funcname = mkfuncname(L, name);
99 + if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) {
100 + if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */
101 + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
103 + return 1; /* function not found */
105 + return 1; /* library loaded successfully */
109 static int lj_cf_package_loader_preload(lua_State *L)
111 const char *name = luaL_checkstring(L, 1);
113 diff -bur LuaJIT-src-orig/src/lj_load.c LuaJIT-src/src/lj_load.c
114 --- LuaJIT-src-orig/src/lj_load.c 2016-03-07 09:43:42.716069718 +0100
115 +++ LuaJIT-src/src/lj_load.c 2016-03-07 12:09:10.771924621 +0100
120 +/* -- Luajittex needs this one because it overloads loadfile -- */
121 +LUALIB_API int RESERVED_load_aux_JIT(lua_State *L, int status, int envarg)
124 + if (tvistab(L->base+envarg-1)) {
125 + GCfunc *fn = funcV(L->top-1);
126 + GCtab *t = tabV(L->base+envarg-1);
127 + setgcref(fn->c.env, obj2gco(t));
128 + lj_gc_objbarrier(L, fn, t);
137 diff -bur LuaJIT-src-orig/src/lua.h LuaJIT-src/src/lua.h
138 --- LuaJIT-src-orig/src/lua.h 2016-03-07 09:43:42.716069718 +0100
139 +++ LuaJIT-src/src/lua.h 2016-03-07 11:56:24.855937353 +0100
141 typedef LUA_INTEGER lua_Integer;
144 +/* communication with LuaJiTTeX */
145 +LUA_API int luajittex_choose_hash_function;
149 ** state manipulation
151 const char *chunkname, const char *mode);
159 +/* see http://comments.gmane.org/gmane.comp.programming.swig/18673 */
160 +# define lua_rawlen lua_objlen
166 const char *name; /* (n) */
168 diff -bur LuaJIT-src-orig/src/lualib.h LuaJIT-src/src/lualib.h
169 --- LuaJIT-src-orig/src/lualib.h 2016-03-07 09:43:42.724069718 +0100
170 +++ LuaJIT-src/src/lualib.h 2016-03-07 11:58:19.151935453 +0100
172 #define LUA_JITLIBNAME "jit"
173 #define LUA_FFILIBNAME "ffi"
175 +#define LUA_BITLIBNAME_32 "bit32"
177 LUALIB_API int luaopen_base(lua_State *L);
178 LUALIB_API int luaopen_math(lua_State *L);
179 LUALIB_API int luaopen_string(lua_State *L);
181 LUALIB_API int luaopen_jit(lua_State *L);
182 LUALIB_API int luaopen_ffi(lua_State *L);
184 +LUALIB_API int luaopen_bit32(lua_State *L);
186 LUALIB_API void luaL_openlibs(lua_State *L);
190 diff -bur LuaJIT-src-orig/src/Makefile LuaJIT-src/src/Makefile
191 --- LuaJIT-src-orig/src/Makefile 2016-03-07 09:43:42.716069718 +0100
192 +++ LuaJIT-src/src/Makefile 2016-03-07 12:02:42.319931078 +0100
194 # enabled by default. Some other features that *might* break some existing
195 # code (e.g. __pairs or os.execute() return values) can be enabled here.
196 # Note: this does not provide full compatibility with Lua 5.2 at this time.
197 -#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
198 +XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
200 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
201 #XCFLAGS+= -DLUAJIT_DISABLE_JIT
206 -LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
207 +LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \
208 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
209 LJLIB_C= $(LJLIB_O:.o=.c)
211 diff -bur LuaJIT-src-orig/src/Makefile.dep LuaJIT-src/src/Makefile.dep
212 --- LuaJIT-src-orig/src/Makefile.dep 2016-03-07 09:43:42.696069718 +0100
213 +++ LuaJIT-src/src/Makefile.dep 2016-03-07 12:05:19.343928468 +0100
215 lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \
216 lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
217 lj_strfmt.h lj_lib.h lj_libdef.h
218 +lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h
219 lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
220 lj_arch.h lj_err.h lj_errmsg.h lj_buf.h lj_gc.h lj_str.h lj_strscan.h \
221 lj_strfmt.h lj_ctype.h lj_cdata.h lj_cconv.h lj_carith.h lj_ff.h \