lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 14.11.2013 00:05 schröbte Andrew Starks:

Now slnu compiles (with a bunch-o-warnings about casting) but the
sub-module `.utf8` isn't getting registered as an upvalue. In order to
make it 5.2-esque, the patch used a nifty macro hack that my limited
preprocessor skills were unable to penetrate. Also, I don't know 5.0
or 5.1 well enough to know what they or the author were trying to
accomplish in the first place.

The nifty macro tries to register all functions in a different subtable of the module table with a different upvalue each time. But it is broken. It should be

    #define PUSHLIB(mode, name) \
      ( lua_newtable(L), \
        lua_pushinteger(L, MODE_##mode), \
        luaL_setfuncs(L, uniclib, 1), \
        lua_setfield(L, -2, #name) )

Also replace `PUSHLIB(ASCII, string);` with `PUSHLIB(ASCII, ascii);` and remove the `lua_settop(L, 2);` at the end. With those modifications it builds and unit-tests fine for Lua 5.1 and Lua 5.2 (without compiler warnings, but I'm using gcc on Linux-x86_64).

(I didn't try any other optional defines, but the `WANT_EXT_MATCH`-part is not ported to Lua 5.2 yet).


-Andrew, better for having vented.

HTH,
Philipp



[1] https://github.com/LuaDist/slnunicode/blob/master/slnunico.c#L1227
[2] https://gist.github.com/starwing/2708924