1 diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
2 --- lua-5.1.4.orig/src/Makefile 2009-04-04 23:06:04.000000000 +0200
3 +++ lua-5.1.4/src/Makefile 2009-04-04 23:06:15.000000000 +0200
9 +LIBS= -lm -lz $(MYLIBS)
13 diff -ur lua-5.1.4.orig/src/lauxlib.c lua-5.1.4/src/lauxlib.c
14 --- lua-5.1.4.orig/src/lauxlib.c 2009-04-04 23:06:04.000000000 +0200
15 +++ lua-5.1.4/src/lauxlib.c 2009-04-05 03:35:24.000000000 +0200
23 /* This file uses only the official API of Lua.
25 char buff[LUAL_BUFFERSIZE];
28 +typedef struct LoadGZ {
31 + char buffer[LUAL_GZLDBUFFER];
35 static const char *getF (lua_State *L, void *ud, size_t *size) {
36 LoadF *lf = (LoadF *)ud;
41 +static const char *getGZ (lua_State *L, void *ud, size_t *size) {
42 + LoadGZ *lf = (LoadGZ *)ud;
45 + if (gzeof(lf->f)) return NULL;
46 + *size = gzread(lf->f, lf->buffer, sizeof(lf->buffer));
48 + if (lf->first_chunk) {
49 + lf->first_chunk = 0;
50 + if ((lf->buffer[0] == '#') && (lf->buffer[1] == '!') &&
51 + (sp=strstr(lf->buffer, "\n")) != NULL)
53 + *size -= ((uint)sp - (uint)lf->buffer);
63 static int errfile (lua_State *L, const char *what, int fnameindex) {
64 const char *serr = strerror(errno);
65 const char *filename = lua_tostring(L, fnameindex) + 1;
69 LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
70 + if ((filename != NULL) && strstr(filename, ".lua.gz")) {
71 + return luaL_loadfile_gzip(L, filename);
74 + return luaL_loadfile_plain(L, filename);
79 +LUALIB_API int luaL_loadfile_gzip (lua_State *L, const char *filename) {
82 + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
83 + lua_pushfstring(L, "@%s", filename);
84 + gzf.f = gzopen(filename, "r");
85 + gzf.first_chunk = 1;
86 + if (gzf.f == Z_NULL) return errfile(L, "open", fnameindex);
87 + status = lua_load(L, getGZ, &gzf, lua_tostring(L, -1));
88 + (void)gzclose(gzf.f);
89 + lua_remove(L, fnameindex);
94 +LUALIB_API int luaL_loadfile_plain (lua_State *L, const char *filename) {
96 int status, readstatus;
98 diff -ur lua-5.1.4.orig/src/lauxlib.h lua-5.1.4/src/lauxlib.h
99 --- lua-5.1.4.orig/src/lauxlib.h 2009-04-04 23:06:04.000000000 +0200
100 +++ lua-5.1.4/src/lauxlib.h 2009-04-04 23:06:15.000000000 +0200
102 LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
104 LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
105 +LUALIB_API int (luaL_loadfile_gzip) (lua_State *L, const char *filename);
106 +LUALIB_API int (luaL_loadfile_plain) (lua_State *L, const char *filename);
107 LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
109 LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
110 diff -ur lua-5.1.4.orig/src/luaconf.h lua-5.1.4/src/luaconf.h
111 --- lua-5.1.4.orig/src/luaconf.h 2009-04-04 23:06:04.000000000 +0200
112 +++ lua-5.1.4/src/luaconf.h 2009-04-04 23:27:20.000000000 +0200
114 #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
115 #define LUA_PATH_DEFAULT \
116 "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
117 - LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
118 + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
119 + "./?.lua.gz;" LUA_LDIR"?.lua.gz;" LUA_LDIR"?/init.lua.gz;" \
120 + LUA_CDIR"?.lua.gz;" LUA_CDIR"?/init.lua.gz"
121 #define LUA_CPATH_DEFAULT \
122 "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
126 #define LUAL_BUFFERSIZE BUFSIZ
130 +@@ LUAL_GZLDBUFFER is the buffer size used by the gzip source loader.
132 +#define LUAL_GZLDBUFFER 8192
134 /* }================================================================== */