Blame SOURCES/elinks-0.12pre6-lua51.patch

b07f02
From 0b72059e1bebb52f41a93de710ae12577769fb50 Mon Sep 17 00:00:00 2001
b07f02
From: Miciah Dashiel Butler Masters <miciah.masters@gmail.com>
b07f02
Date: Sun, 5 Apr 2009 12:57:35 +0000
b07f02
Subject: [PATCH 1/2] Lua: Report bad arguments to edit_bookmark_dialoga
b07f02
b07f02
If edit_bookamrk_dialogs is given the wrong number or types of
b07f02
arguments, report the problem to the user instead of failing silently.
b07f02
b07f02
[upstream commit 6a8e0ccd9bdb06e440b7b147c61f7741dd6d1fcd]
b07f02
b07f02
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b07f02
---
b07f02
 src/scripting/lua/core.c | 1 +
b07f02
 1 file changed, 1 insertion(+)
b07f02
b07f02
diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c
b07f02
index bff037b..7712dcd 100644
b07f02
--- a/src/scripting/lua/core.c
b07f02
+++ b/src/scripting/lua/core.c
b07f02
@@ -369,6 +369,7 @@ l_edit_bookmark_dialog(LS)
b07f02
 
b07f02
 	if (!lua_isstring(S, 1) || !lua_isstring(S, 2)
b07f02
 	    || !lua_isstring(S, 3) || !lua_isfunction(S, 4)) {
b07f02
+		alert_lua_error("bad arguments to edit_bookmark_dialog");
b07f02
 		lua_pushnil(S);
b07f02
 		return 1;
b07f02
 	}
b07f02
-- 
b07f02
1.8.3.1
b07f02
b07f02
b07f02
From 8ce643a489dd8dc195aa2f8dc4029ce347093c98 Mon Sep 17 00:00:00 2001
b07f02
From: Witold Filipczyk <witekfl@poczta.onet.pl>
b07f02
Date: Wed, 21 Jul 2010 19:07:49 +0200
b07f02
Subject: [PATCH 2/2] Link against lua51, not lua50.
b07f02
b07f02
[upstream commit 331a4dc62b0dbdecba3857d87dc4e12660e5d705]
b07f02
b07f02
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b07f02
---
b07f02
 configure.in              | 16 +++++++---------
b07f02
 src/scripting/lua/core.c  | 13 +++++--------
b07f02
 src/scripting/lua/hooks.c |  6 +++++-
b07f02
 3 files changed, 17 insertions(+), 18 deletions(-)
b07f02
b07f02
diff --git a/configure.in b/configure.in
b07f02
index 3ef8603..ca138ac 100644
b07f02
--- a/configure.in
b07f02
+++ b/configure.in
b07f02
@@ -854,10 +854,10 @@ if test -z "$disable_lua"; then
b07f02
 		withval="";
b07f02
 	fi
b07f02
 	for luadir in "$withval" "" /usr /usr/local; do
b07f02
-		for suffix in "" 50; do
b07f02
+		for suffix in "" 51; do
b07f02
 			if test "$cf_result" = no && ( test -f "$luadir/include/lua.h" || \
b07f02
 			   test -f "$luadir/include/lua$suffix/lua.h" ) ; then
b07f02
-				LUA_LIBS="-L$luadir/lib -llua$suffix -llualib$suffix -lm"
b07f02
+				LUA_LIBS="-L$luadir/lib -llua$suffix -lm"
b07f02
 				LUA_CFLAGS="-I$luadir/include -I$luadir/include/lua$suffix"
b07f02
 
b07f02
 				LIBS="$LUA_LIBS $LIBS_X"
b07f02
@@ -865,13 +865,11 @@ if test -z "$disable_lua"; then
b07f02
 				CPPFLAGS="$CPPFLAGS_X $LUA_CFLAGS"
b07f02
 
b07f02
 				# Check that it is a compatible Lua version
b07f02
-				AC_LINK_IFELSE([AC_LANG_PROGRAM([[	#include <lua.h>
b07f02
-						#include <lualib.h>]], [[	lua_State *L = lua_open();
b07f02
-						luaopen_base(L);
b07f02
-						luaopen_table(L);
b07f02
-						luaopen_io(L);
b07f02
-						luaopen_string(L);
b07f02
-						luaopen_math(L);
b07f02
+				AC_LINK_IFELSE([AC_LANG_PROGRAM([[	#include <lauxlib.h>]
b07f02
+						#include <lua.h>
b07f02
+						#include <lualib.h>
b07f02
+						], [[	lua_State *L = luaL_newstate();
b07f02
+						luaL_openlibs(L);
b07f02
 						lua_pushboolean(L, 1);
b07f02
 						lua_close(L);]])],[cf_result=yes],[cf_result=no])
b07f02
 			fi
b07f02
diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c
b07f02
index 7712dcd..1c4dbbc 100644
b07f02
--- a/src/scripting/lua/core.c
b07f02
+++ b/src/scripting/lua/core.c
b07f02
@@ -12,6 +12,7 @@
b07f02
 #include <unistd.h>
b07f02
 #endif
b07f02
 
b07f02
+#include <lauxlib.h>
b07f02
 #include <lua.h>
b07f02
 #include <lualib.h>
b07f02
 
b07f02
@@ -659,7 +660,7 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char *filename)
b07f02
 	if (file_can_read(file)) {
b07f02
 		int oldtop = lua_gettop(S);
b07f02
 
b07f02
-		if (lua_dofile(S, file) != 0)
b07f02
+		if (luaL_dofile(S, file) != 0)
b07f02
 			sleep(3); /* Let some time to see error messages. */
b07f02
 		lua_settop(S, oldtop);
b07f02
 	}
b07f02
@@ -670,13 +671,9 @@ do_hooks_file(LS, unsigned char *prefix, unsigned char *filename)
b07f02
 void
b07f02
 init_lua(struct module *module)
b07f02
 {
b07f02
-	L = lua_open();
b07f02
+	L = luaL_newstate();
b07f02
 
b07f02
-	luaopen_base(L);
b07f02
-	luaopen_table(L);
b07f02
-	luaopen_io(L);
b07f02
-	luaopen_string(L);
b07f02
-	luaopen_math(L);
b07f02
+	luaL_openlibs(L);
b07f02
 
b07f02
 	lua_register(L, LUA_ALERT, l_alert);
b07f02
 	lua_register(L, "current_url", l_current_url);
b07f02
@@ -781,7 +778,7 @@ handle_ret_eval(struct session *ses)
b07f02
 		int oldtop = lua_gettop(L);
b07f02
 
b07f02
 		if (prepare_lua(ses) == 0) {
b07f02
-			lua_dostring(L, expr);
b07f02
+			luaL_dostring(L, expr);
b07f02
 			lua_settop(L, oldtop);
b07f02
 			finish_lua();
b07f02
 		}
b07f02
diff --git a/src/scripting/lua/hooks.c b/src/scripting/lua/hooks.c
b07f02
index d79ad80..49b6414 100644
b07f02
--- a/src/scripting/lua/hooks.c
b07f02
+++ b/src/scripting/lua/hooks.c
b07f02
@@ -4,6 +4,10 @@
b07f02
 #include "config.h"
b07f02
 #endif
b07f02
 
b07f02
+#include <lauxlib.h>
b07f02
+#include <lua.h>
b07f02
+#include <lualib.h>
b07f02
+
b07f02
 #include "elinks.h"
b07f02
 
b07f02
 #include "cache/cache.h"
b07f02
@@ -200,7 +204,7 @@ static enum evhook_status
b07f02
 script_hook_quit(va_list ap, void *data)
b07f02
 {
b07f02
 	if (!prepare_lua(NULL)) {
b07f02
-		lua_dostring(lua_state, "if quit_hook then quit_hook() end");
b07f02
+		luaL_dostring(lua_state, "if quit_hook then quit_hook() end");
b07f02
 		finish_lua();
b07f02
 	}
b07f02
 
b07f02
-- 
b07f02
1.8.3.1
b07f02