mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
cannot pack objects other than the first one. closes #1.
This commit is contained in:
+2
-1
@@ -664,6 +664,7 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
|
||||
prepare_tmpl(mrb, &tmpl);
|
||||
|
||||
result = mrb_str_new(mrb, NULL, 128); /* allocate initial buffer */
|
||||
aidx = 0;
|
||||
ridx = 0;
|
||||
while (has_tmpl(&tmpl)) {
|
||||
read_tmpl(mrb, &tmpl, &dir, &type, &size, &count, &flags);
|
||||
@@ -671,7 +672,7 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
|
||||
if (dir == PACK_DIR_INVALID)
|
||||
continue;
|
||||
|
||||
for (aidx = 0; aidx < RARRAY_LEN(ary); aidx++) {
|
||||
for (; aidx < RARRAY_LEN(ary); aidx++) {
|
||||
if (count == 0 && !(flags & PACK_FLAG_WIDTH))
|
||||
break;
|
||||
|
||||
|
||||
@@ -83,3 +83,8 @@ assert('["abc"].pack("A")') do
|
||||
"abc\0".unpack("A4") == ["abc"] and
|
||||
"abc ".unpack("A4") == ["abc"]
|
||||
end
|
||||
|
||||
# regression tests
|
||||
assert('issue #1') do
|
||||
[1, 2].pack("nn") == "\000\001\000\002"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user