From 931652ad9ef34c99e53007de9f92bfd5a397a219 Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Wed, 8 Jul 2020 20:25:09 +0200 Subject: Make it usable on Lua 5.4 --- README.md | 2 +- c-api/compat-5.3.h | 6 +++--- rockspecs/compat53-0.8-1.rockspec | 32 ++++++++++++++++++++++++++++++++ rockspecs/compat53-scm-0.rockspec | 4 ++-- tests/testmod.c | 2 ++ 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 rockspecs/compat53-0.8-1.rockspec diff --git a/README.md b/README.md index 4db06a7..0fcd657 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ require("compat53") a meaningful return value, so the usual idiom of storing the return of `require` in a local variable makes no sense. -When run under Lua 5.3, this module does nothing. +When run under Lua 5.3+, this module does nothing. When run under Lua 5.2 or 5.1, it replaces some of your standard functions and adds new ones to bring your environment closer to that diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index 082a6a0..b730a4b 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h @@ -399,11 +399,11 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, /* other Lua versions */ -#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 503 +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504 -# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)" +# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)" -#endif /* other Lua versions except 5.1, 5.2, and 5.3 */ +#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */ diff --git a/rockspecs/compat53-0.8-1.rockspec b/rockspecs/compat53-0.8-1.rockspec new file mode 100644 index 0000000..0ab17a0 --- /dev/null +++ b/rockspecs/compat53-0.8-1.rockspec @@ -0,0 +1,32 @@ +package = "compat53" +version = "0.8-1" +source = { + url = "https://github.com/keplerproject/lua-compat-5.3/archive/v0.8.zip", + dir = "lua-compat-5.3-0.8", +} +description = { + summary = "Compatibility module providing Lua-5.3-style APIs for Lua 5.2 and 5.1", + detailed = [[ + This is a small module that aims to make it easier to write Lua + code in a Lua-5.3-style that runs on Lua 5.1+. + It does *not* make Lua 5.2 (or even 5.1) entirely compatible + with Lua 5.3, but it brings the API closer to that of Lua 5.3. + ]], + homepage = "https://github.com/keplerproject/lua-compat-5.3", + license = "MIT" +} +dependencies = { + "lua >= 5.1, < 5.5", + --"struct" -- make Roberto's struct module optional +} +build = { + type = "builtin", + modules = { + ["compat53.init"] = "compat53/init.lua", + ["compat53.module"] = "compat53/module.lua", + ["compat53.utf8"] = "lutf8lib.c", + ["compat53.table"] = "ltablib.c", + ["compat53.string"] = "lstrlib.c", + } +} + diff --git a/rockspecs/compat53-scm-0.rockspec b/rockspecs/compat53-scm-0.rockspec index 317e18c..a83dfca 100644 --- a/rockspecs/compat53-scm-0.rockspec +++ b/rockspecs/compat53-scm-0.rockspec @@ -8,7 +8,7 @@ description = { summary = "Compatibility module providing Lua-5.3-style APIs for Lua 5.2 and 5.1", detailed = [[ This is a small module that aims to make it easier to write Lua - code in a Lua-5.3-style that runs on Lua 5.3, 5.2, and 5.1. + code in a Lua-5.3-style that runs on Lua 5.1+. It does *not* make Lua 5.2 (or even 5.1) entirely compatible with Lua 5.3, but it brings the API closer to that of Lua 5.3. ]], @@ -16,7 +16,7 @@ description = { license = "MIT" } dependencies = { - "lua >= 5.1, < 5.4", + "lua >= 5.1, < 5.5", --"struct" -- make Roberto's struct module optional } build = { diff --git a/tests/testmod.c b/tests/testmod.c index 3bf2cd3..0d73ed4 100644 --- a/tests/testmod.c +++ b/tests/testmod.c @@ -1,5 +1,6 @@ #include #include +#include #include "compat-5.3.h" @@ -285,6 +286,7 @@ static int test_buffer (lua_State *L) { static int test_exec (lua_State *L) { const char *cmd = luaL_checkstring(L, 1); + errno = 0; return luaL_execresult(L, system(cmd)); } -- cgit v1.2.3-55-g6feb