Skip to content

Lua 5.3 compatibility #5

Open
Open

Description

@agraef

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

Activity

  1. agraef commented on Nov 1, 2017

    @agraef
    Author

    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;
  2. added a commit that references this issue on Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions