summaryrefslogtreecommitdiff
path: root/www/elinks/patches/patch-ab
blob: 82913f784feb0c95e6d878f7035fcd83d29746ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$NetBSD: patch-ab,v 1.4 2006/09/04 20:23:30 abs Exp $

--- src/scripting/lua/core.c.orig	2006-09-04 21:19:38.000000000 +0100
+++ src/scripting/lua/core.c
@@ -644,23 +644,24 @@ do_hooks_file(LS, unsigned char *prefix,
 void
 init_lua(struct module *module)
 {
-        static const luaL_reg lualibs[] = {
-            { "base",       luaopen_base },
-            { "table",      luaopen_table },
-            { "io",         luaopen_io },
-            { "string",     luaopen_string },
-            { "math",       luaopen_math },
-            { NULL,         NULL }
-        };
-        const luaL_reg *lib;
+	static const luaL_Reg lualibs[] = {
+		{"", luaopen_base},
+		{LUA_TABLIBNAME, luaopen_table},
+		{LUA_IOLIBNAME, luaopen_io},
+		{LUA_OSLIBNAME, luaopen_os},
+		{LUA_STRLIBNAME, luaopen_string},
+		{LUA_MATHLIBNAME, luaopen_math},
+		{NULL, NULL}
+	};
+	const luaL_Reg *lib = lualibs;
 
 	L = lua_open();
 
-        for (lib = lualibs; lib->func != NULL; lib++) {
-                lib->func(l);           /* Open the library */
-                /* Flush stack to ignore any result from the library load */
-                lua_settop(l, 0);
-        }
+	for (; lib->func; lib++) {
+		lua_pushcfunction(L, lib->func);
+		lua_pushstring(L, lib->name);
+		lua_call(L, 1, 0);
+	}
 
 	lua_register(L, LUA_ALERT, l_alert);
 	lua_register(L, "current_url", l_current_url);