summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2009-04-04 23:06:56 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2009-04-04 23:06:56 +0000
commita1cd2822b2fd2e8e7b5db00c7069bef5a819dc8e (patch)
treea3368fa7ea307caadffb4634477dc64289e7afc5 /package
parentb3ce8c96a5b3dc77c60632f55f648b106ea062f5 (diff)
[package] lua: add support for loading gzip compressed source files, bump package revision
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@15108 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/lua/Makefile4
-rw-r--r--package/lua/patches-host/040-gzip-source-loader.patch134
-rw-r--r--package/lua/patches/040-gzip-source-loader.patch134
-rw-r--r--package/lua/patches/400-luaposix_5.1.4-embedded.patch4
4 files changed, 272 insertions, 4 deletions
diff --git a/package/lua/Makefile b/package/lua/Makefile
index 67f3175c7..689b845d5 100644
--- a/package/lua/Makefile
+++ b/package/lua/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2008 OpenWrt.org
+# Copyright (C) 2006-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=lua
PKG_VERSION:=5.1.4
-PKG_RELEASE:=3
+PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
diff --git a/package/lua/patches-host/040-gzip-source-loader.patch b/package/lua/patches-host/040-gzip-source-loader.patch
new file mode 100644
index 000000000..6fbafa206
--- /dev/null
+++ b/package/lua/patches-host/040-gzip-source-loader.patch
@@ -0,0 +1,134 @@
+diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
+--- lua-5.1.4.orig/src/Makefile 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/Makefile 2009-04-04 23:06:15.000000000 +0200
+@@ -12,7 +12,7 @@
+ AR= ar rcu
+ RANLIB= ranlib
+ RM= rm -f
+-LIBS= -lm $(MYLIBS)
++LIBS= -lm -lz $(MYLIBS)
+
+ MYCFLAGS=
+ MYLDFLAGS=
+diff -ur lua-5.1.4.orig/src/lauxlib.c lua-5.1.4/src/lauxlib.c
+--- lua-5.1.4.orig/src/lauxlib.c 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/lauxlib.c 2009-04-05 00:03:33.000000000 +0200
+@@ -11,6 +11,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <zlib.h>
+
+
+ /* This file uses only the official API of Lua.
+@@ -535,6 +536,12 @@
+ char buff[LUAL_BUFFERSIZE];
+ } LoadF;
+
++typedef struct LoadGZ {
++ int first_chunk;
++ gzFile f;
++ char buffer[LUAL_GZLDBUFFER];
++} LoadGZ;
++
+
+ static const char *getF (lua_State *L, void *ud, size_t *size) {
+ LoadF *lf = (LoadF *)ud;
+@@ -550,6 +557,26 @@
+ }
+
+
++static const char *getGZ (lua_State *L, void *ud, size_t *size) {
++ LoadGZ *lf = (LoadGZ *)ud;
++ char *sp = 0;
++ (void)L;
++ if (gzeof(lf->f)) return NULL;
++ *size = gzread(lf->f, lf->buffer, sizeof(lf->buffer));
++ if (*size > 0) {
++ if (lf->first_chunk) {
++ lf->first_chunk = 0;
++ if (strstr(lf->buffer, "#!") && (sp=strstr(lf->buffer, "\n")) != NULL) {
++ *size -= ((uint)sp - (uint)lf->buffer);
++ return sp;
++ }
++ }
++ return lf->buffer;
++ }
++ return NULL;
++}
++
++
+ static int errfile (lua_State *L, const char *what, int fnameindex) {
+ const char *serr = strerror(errno);
+ const char *filename = lua_tostring(L, fnameindex) + 1;
+@@ -560,6 +587,31 @@
+
+
+ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ if ((filename != NULL) && strstr(filename, ".lua.gz")) {
++ return luaL_loadfile_gzip(L, filename);
++ }
++ else {
++ return luaL_loadfile_plain(L, filename);
++ }
++}
++
++
++LUALIB_API int luaL_loadfile_gzip (lua_State *L, const char *filename) {
++ LoadGZ gzf;
++ int status;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lua_pushfstring(L, "@%s", filename);
++ gzf.f = gzopen(filename, "r");
++ gzf.first_chunk = 1;
++ if (gzf.f == Z_NULL) return errfile(L, "open", fnameindex);
++ status = lua_load(L, getGZ, &gzf, lua_tostring(L, -1));
++ (void)gzclose(gzf.f);
++ lua_remove(L, fnameindex);
++ return status;
++}
++
++
++LUALIB_API int luaL_loadfile_plain (lua_State *L, const char *filename) {
+ LoadF lf;
+ int status, readstatus;
+ int c;
+diff -ur lua-5.1.4.orig/src/lauxlib.h lua-5.1.4/src/lauxlib.h
+--- lua-5.1.4.orig/src/lauxlib.h 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/lauxlib.h 2009-04-04 23:06:15.000000000 +0200
+@@ -81,6 +81,8 @@
+ LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+ LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++LUALIB_API int (luaL_loadfile_gzip) (lua_State *L, const char *filename);
++LUALIB_API int (luaL_loadfile_plain) (lua_State *L, const char *filename);
+ LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
+ const char *name);
+ LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+diff -ur lua-5.1.4.orig/src/luaconf.h lua-5.1.4/src/luaconf.h
+--- lua-5.1.4.orig/src/luaconf.h 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/luaconf.h 2009-04-04 23:27:20.000000000 +0200
+@@ -101,7 +101,9 @@
+ #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
++ "./?.lua.gz;" LUA_LDIR"?.lua.gz;" LUA_LDIR"?/init.lua.gz;" \
++ LUA_CDIR"?.lua.gz;" LUA_CDIR"?/init.lua.gz"
+ #define LUA_CPATH_DEFAULT \
+ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
+ #endif
+@@ -506,6 +508,12 @@
+ */
+ #define LUAL_BUFFERSIZE BUFSIZ
+
++
++/*
++@@ LUAL_GZLDBUFFER is the buffer size used by the gzip source loader.
++*/
++#define LUAL_GZLDBUFFER 8192
++
+ /* }================================================================== */
+
+
diff --git a/package/lua/patches/040-gzip-source-loader.patch b/package/lua/patches/040-gzip-source-loader.patch
new file mode 100644
index 000000000..6fbafa206
--- /dev/null
+++ b/package/lua/patches/040-gzip-source-loader.patch
@@ -0,0 +1,134 @@
+diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
+--- lua-5.1.4.orig/src/Makefile 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/Makefile 2009-04-04 23:06:15.000000000 +0200
+@@ -12,7 +12,7 @@
+ AR= ar rcu
+ RANLIB= ranlib
+ RM= rm -f
+-LIBS= -lm $(MYLIBS)
++LIBS= -lm -lz $(MYLIBS)
+
+ MYCFLAGS=
+ MYLDFLAGS=
+diff -ur lua-5.1.4.orig/src/lauxlib.c lua-5.1.4/src/lauxlib.c
+--- lua-5.1.4.orig/src/lauxlib.c 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/lauxlib.c 2009-04-05 00:03:33.000000000 +0200
+@@ -11,6 +11,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <zlib.h>
+
+
+ /* This file uses only the official API of Lua.
+@@ -535,6 +536,12 @@
+ char buff[LUAL_BUFFERSIZE];
+ } LoadF;
+
++typedef struct LoadGZ {
++ int first_chunk;
++ gzFile f;
++ char buffer[LUAL_GZLDBUFFER];
++} LoadGZ;
++
+
+ static const char *getF (lua_State *L, void *ud, size_t *size) {
+ LoadF *lf = (LoadF *)ud;
+@@ -550,6 +557,26 @@
+ }
+
+
++static const char *getGZ (lua_State *L, void *ud, size_t *size) {
++ LoadGZ *lf = (LoadGZ *)ud;
++ char *sp = 0;
++ (void)L;
++ if (gzeof(lf->f)) return NULL;
++ *size = gzread(lf->f, lf->buffer, sizeof(lf->buffer));
++ if (*size > 0) {
++ if (lf->first_chunk) {
++ lf->first_chunk = 0;
++ if (strstr(lf->buffer, "#!") && (sp=strstr(lf->buffer, "\n")) != NULL) {
++ *size -= ((uint)sp - (uint)lf->buffer);
++ return sp;
++ }
++ }
++ return lf->buffer;
++ }
++ return NULL;
++}
++
++
+ static int errfile (lua_State *L, const char *what, int fnameindex) {
+ const char *serr = strerror(errno);
+ const char *filename = lua_tostring(L, fnameindex) + 1;
+@@ -560,6 +587,31 @@
+
+
+ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
++ if ((filename != NULL) && strstr(filename, ".lua.gz")) {
++ return luaL_loadfile_gzip(L, filename);
++ }
++ else {
++ return luaL_loadfile_plain(L, filename);
++ }
++}
++
++
++LUALIB_API int luaL_loadfile_gzip (lua_State *L, const char *filename) {
++ LoadGZ gzf;
++ int status;
++ int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
++ lua_pushfstring(L, "@%s", filename);
++ gzf.f = gzopen(filename, "r");
++ gzf.first_chunk = 1;
++ if (gzf.f == Z_NULL) return errfile(L, "open", fnameindex);
++ status = lua_load(L, getGZ, &gzf, lua_tostring(L, -1));
++ (void)gzclose(gzf.f);
++ lua_remove(L, fnameindex);
++ return status;
++}
++
++
++LUALIB_API int luaL_loadfile_plain (lua_State *L, const char *filename) {
+ LoadF lf;
+ int status, readstatus;
+ int c;
+diff -ur lua-5.1.4.orig/src/lauxlib.h lua-5.1.4/src/lauxlib.h
+--- lua-5.1.4.orig/src/lauxlib.h 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/lauxlib.h 2009-04-04 23:06:15.000000000 +0200
+@@ -81,6 +81,8 @@
+ LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
+
+ LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
++LUALIB_API int (luaL_loadfile_gzip) (lua_State *L, const char *filename);
++LUALIB_API int (luaL_loadfile_plain) (lua_State *L, const char *filename);
+ LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
+ const char *name);
+ LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
+diff -ur lua-5.1.4.orig/src/luaconf.h lua-5.1.4/src/luaconf.h
+--- lua-5.1.4.orig/src/luaconf.h 2009-04-04 23:06:04.000000000 +0200
++++ lua-5.1.4/src/luaconf.h 2009-04-04 23:27:20.000000000 +0200
+@@ -101,7 +101,9 @@
+ #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
++ "./?.lua.gz;" LUA_LDIR"?.lua.gz;" LUA_LDIR"?/init.lua.gz;" \
++ LUA_CDIR"?.lua.gz;" LUA_CDIR"?/init.lua.gz"
+ #define LUA_CPATH_DEFAULT \
+ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
+ #endif
+@@ -506,6 +508,12 @@
+ */
+ #define LUAL_BUFFERSIZE BUFSIZ
+
++
++/*
++@@ LUAL_GZLDBUFFER is the buffer size used by the gzip source loader.
++*/
++#define LUAL_GZLDBUFFER 8192
++
+ /* }================================================================== */
+
+
diff --git a/package/lua/patches/400-luaposix_5.1.4-embedded.patch b/package/lua/patches/400-luaposix_5.1.4-embedded.patch
index 73d8eb03b..f0757f0e4 100644
--- a/package/lua/patches/400-luaposix_5.1.4-embedded.patch
+++ b/package/lua/patches/400-luaposix_5.1.4-embedded.patch
@@ -6,8 +6,8 @@ Index: lua-5.1.4/src/Makefile
AR= ar rcu
RANLIB= ranlib
RM= rm -f
--LIBS= -lm $(MYLIBS)
-+LIBS= -lm -lcrypt $(MYLIBS)
+-LIBS= -lm -lz $(MYLIBS)
++LIBS= -lm -lz -lcrypt $(MYLIBS)
MYCFLAGS=
MYLDFLAGS=