From: Ton Hospel Date: Sat, 29 Jan 2005 12:41:20 +0000 (+0000) Subject: Re: encoding neutral unpack X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ed7c1bbe9e393cef0b94251a5a51525bd4e04ad;p=p5sagit%2Fp5-mst-13.2.git Re: encoding neutral unpack From: perl5-porters[at]ton.iguana.be (Ton Hospel) Message-ID: Forgotten character progress while checksumming over partial b or B format. (plus a regression test) p4raw-id: //depot/perl@23915 --- diff --git a/pp_pack.c b/pp_pack.c index 8f76d69..cb3dd89 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -1085,7 +1085,7 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c len -= 8; } if (len) { - bits = *s; + bits = *s++; if (datumtype == 'b') { while (len-- > 0) { if (bits & 1) cuv++; diff --git a/t/op/pack.t b/t/op/pack.t index 102a0ce..d30ae94 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -12,7 +12,7 @@ my $no_endianness = $] > 5.009 ? '' : my $no_signedness = $] > 5.009 ? '' : "Signed/unsigned pack modifiers not available on this perl"; -plan tests => 13855; +plan tests => 13856; use strict; use warnings; @@ -1491,3 +1491,11 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_ is($a[-1], "01234567\n", "[perl #15288]"); is($a[-2], "X", "[perl #15288]"); } + +# checksums +{ + # verify that unpack advances correctly wrt a checksum + my (@x) = unpack("b10a", "abcd"); + my (@y) = unpack("%b10a", "abcd"); + is($x[1], $y[1], "checksum advance ok"); +}