Ilya Zakharevich <ilya@math.ohio-state.edu> wrote > This is clearly a bug. Either \0 should not have been inserted, or > (better) the length should have been marked as 10. Since Z is defined to *always* insert a \0, the length should be 10. > But this is a bug in pack(). I do not see why any change should be > done to unpack(). Agreed. Patch attached. Mike Guy --- ./pp.c.orig Thu Apr 27 18:11:50 2000 +++ ./pp.c Thu Apr 27 18:04:17 2000 @@ -4445,7 +4445,8 @@ if ((*pat != 'a' && *pat != 'A' && *pat != 'Z') || pat[1] != '*') DIE(aTHX_ "/ must be followed by a*, A* or Z*"); lengthcode = sv_2mortal(newSViv(sv_len(items > 0 - ? *MARK : &PL_sv_no))); + ? *MARK : &PL_sv_no) + + (*pat == 'Z' ? 1 : 0))); } switch(datumtype) { default: --- ./t/op/pack.t.orig Thu Apr 27 18:11:50 2000 +++ ./t/op/pack.t Thu Apr 27 18:12:05 2000 @@ -372,8 +372,9 @@ eval { ($x) = pack '/a*','hello' }; print 'not ' unless $@; print "ok $test\n"; $test++; -$z = pack 'n/a* w/A*','string','etc'; -print 'not ' unless $z eq "\000\006string\003etc"; print "ok $test\n"; $test++; +$z = pack 'n/a* N/Z* w/A*','string','hi there ','etc'; +print 'not ' unless $z eq "\000\006string\0\0\0\012hi there \000\003etc"; +print "ok $test\n"; $test++; eval { ($x) = unpack 'a/a*/a*', '212ab345678901234567' }; print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; End of patchThread Previous | Thread Next