Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua 5.3 compatibility #5

Open
agraef opened this issue Nov 1, 2017 · 1 comment
Open

Lua 5.3 compatibility #5

agraef opened this issue Nov 1, 2017 · 1 comment

Comments

@agraef
Copy link

agraef commented Nov 1, 2017

This code isn't 100% compatible with Lua 5.3, but that's easy to fix. Suggested patch attached.

lua-5.3-fix.diff.zip

@agraef
Copy link
Author

agraef commented Nov 1, 2017

In fact, it's simple enough to just be included here. I found this in a commit of some other Lua project which had the same issue.

diff --git a/rng.c b/rng.c
index 8c3c857..c2b37fe 100644
--- a/rng.c
+++ b/rng.c
@@ -44,6 +44,18 @@ static int rng__tostring (lua_State *L) {
  *    Core
  * ======================================================================} */
 
+
+#if LUA_VERSION_NUM >= 503
+/* one can simply enable LUA_COMPAT_5_2 to be backward compatible.
+However, this does not work when we are trying to use system-installed lua,
+hence these redefines
+*/
+#define luaL_optlong(L,n,d)     ((long)luaL_optinteger(L, (n), (d)))
+#define luaL_optint(L,n,d)  ((int)luaL_optinteger(L, (n), (d)))
+#define luaL_checklong(L,n)     ((long)luaL_checkinteger(L, (n)))
+#define luaL_checkint(L,n)      ((int)luaL_checkinteger(L, (n)))
+#endif
+
 static int new_rng (lua_State *L) {
   init_genrand(newrng(L), luaL_optlong(L, 1, RNG_SEED));
   return 1;

notCalle added a commit to notCalle/numlua that referenced this issue Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant