Skip to content

lua-cjson compatibility with Lua 5.5#123

Open
KritzelKratzel wants to merge 1 commit intoopenresty:masterfrom
KritzelKratzel:master
Open

lua-cjson compatibility with Lua 5.5#123
KritzelKratzel wants to merge 1 commit intoopenresty:masterfrom
KritzelKratzel:master

Conversation

@KritzelKratzel
Copy link

Key changes:

  • util.lua: Fixed a failure in negative test case encode_keep_buffer(nil, true). In Lua 5.5, the length operator (#) returns 0 for tables with a nil first element (e.g., { nil, true }), causing unpack() to pass zero arguments to the C function. Replaced implicit unpacking with an explicit length calculation using pairs() and table.unpack(t, 1, len) to ensure all arguments are correctly passed. See also discussion on Lua mailing list https://groups.google.com/g/lua-l/c/9CK0KhdeJRY.

  • lua_cjson.c: Resolved a compiler warning (C4005) regarding the redefinition of the 'lua_objlen' macro. Added an #ifndef check to respect the compatibility macro already provided by Lua 5.5 in luaconf.h.

  • tests/bench.lua: Updated benchmarking utility to ensure compatibility with Lua 5.5 environment changes.

These changes ensure that all 128 tests pass successfully on Lua 5.5 and fix issue #120.

Key changes:
- util.lua: Fixed a failure in negative test cases (specifically Test 118).
  In Lua 5.5, the length operator (#) returns 0 for tables with a nil
  first element (e.g., { nil, true }), causing unpack() to pass zero
  arguments to the C function. Replaced implicit unpacking with an
  explicit length calculation using pairs() and table.unpack(t, 1, len)
  to ensure all arguments are correctly passed.

- lua_cjson.c: Resolved a compiler warning (C4005) regarding the
  redefinition of the 'lua_objlen' macro. Added an #ifndef check to
  respect the compatibility macro already provided by Lua 5.5 in luaconf.h.

- tests/bench.lua: Updated benchmarking utility to ensure compatibility
  with Lua 5.5 environment changes.

These changes ensure that all 128 tests pass successfully on Lua 5.5
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

Successfully merging this pull request may close these issues.

1 participant