Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix unpack for templates using *
Fixes: Buf.new("asdf".ords).unpack("N*").say # also S*, v*, L*, V*, n*
  • Loading branch information
ugexe committed Oct 23, 2015
1 parent f25bbe7 commit d97f0b2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/Buf.pm
Expand Up @@ -169,12 +169,14 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is
}
when 'S' | 'v' {
for ^$pa {
last if @bytes.elems < 2;
@fields.append: shift(@bytes)
+ (shift(@bytes) +< 0x08);
}
}
when 'L' | 'V' {
for ^$pa {
last if @bytes.elems < 4;
@fields.append: shift(@bytes)
+ (shift(@bytes) +< 0x08)
+ (shift(@bytes) +< 0x10)
Expand All @@ -183,12 +185,14 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is
}
when 'n' {
for ^$pa {
last if @bytes.elems < 2;
@fields.append: (shift(@bytes) +< 0x08)
+ shift(@bytes);
}
}
when 'N' {
for ^$pa {
last if @bytes.elems < 4;
@fields.append: (shift(@bytes) +< 0x18)
+ (shift(@bytes) +< 0x10)
+ (shift(@bytes) +< 0x08)
Expand Down

0 comments on commit d97f0b2

Please sign in to comment.