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