wget-lua icon indicating copy to clipboard operation
wget-lua copied to clipboard

Support newer version than Lua5.1

Open data-man opened this issue 6 years ago • 1 comments

Thanks for the fork! What version of Lua is used?

My patch for Lua > 5.1

--- a/src/luahooks.c
+++ b/src/luahooks.c
@@ -145,7 +145,7 @@ luahooks_init ()
if (opt.lua_filename == NULL)
return;

-  lua = lua_open ();
+  lua = luaL_newstate ();;
luaL_openlibs (lua);

/* Initialize constants. */
@@ -489,7 +489,7 @@ luahooks_lookup_host (const char *host)
return NULL;

/* Copy to the buffer. */
-      size_t ret_l = lua_strlen(lua, -1);
+      size_t ret_l = lua_rawlen(lua, -1);
ret_l = (ret_l <= MAX_HOST_LENGTH) ? ret_l : MAX_HOST_LENGTH;
strncpy (lookup_host_result, ret, ret_l);

data-man avatar Oct 15 '19 17:10 data-man

Lua 5.1 is the only officially supported Lua version for this project. Anything else may work through patches but isn't guaranteed to function in exactly the same way. I may be able to look into porting this to 5.2-5.4 at one point but not right at this moment. If you do have a patch that makes wget-lua work for 5.1 up to 5.4, feel free to open a pull request and I'll happily look into merging it.

Fusl avatar Feb 19 '20 22:02 Fusl