lua-cjson compatibility with Lua 5.5#123
Open
KritzelKratzel wants to merge 1 commit intoopenresty:masterfrom
Open
lua-cjson compatibility with Lua 5.5#123KritzelKratzel wants to merge 1 commit intoopenresty:masterfrom
KritzelKratzel wants to merge 1 commit intoopenresty:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key changes:
util.lua: Fixed a failure in negative test caseencode_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 usingpairs()andtable.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 inluaconf.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.