Skip to content

fix handle 's' case boundary conditions - #17

Merged
iryont merged 3 commits into
iryont:masterfrom
zhucebuliaopx:master
Aug 27, 2020
Merged

iryont merged 3 commits into
iryont:masterfrom
zhucebuliaopx:master

Conversation

@zhucebuliaopx

Copy link
Copy Markdown
Contributor

fix handle 's' case boundary conditions

@iryont

iryont commented Aug 27, 2020

Copy link
Copy Markdown
Owner

Sounds good.

@iryont
iryont merged commit 3b857ce into iryont:master Aug 27, 2020
@squeek502

Copy link
Copy Markdown

I assume this is meant to fix an 'end of stream' case, but this breaks the 'zero-terminated' aspect of string unpacking.

For example, the following now fails:

local struct = require "struct"

local packed = struct.pack('ss', "first", "second")
local first, second = struct.unpack('ss', packed)
assert(first == "first", "expected 'first', got '"..first:gsub('%z', "\\0").."'")
assert(second == "second", "expected 'second', got '"..second:gsub('%z', "\\0").."'")

with

test-struct.lua:5: expected 'first', got 'first\0second\0'

@zhucebuliaopx

Copy link
Copy Markdown
Contributor Author

@squeek502 you are right, fix in #19

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.

3 participants