From: Chip Salzenberg Date: Fri, 18 Apr 1997 00:00:00 +0000 (+0000) Subject: Fix (and test) spaces in {,un}pack() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bbdab0432496b4b2fda64f190e98e90b407f7023;p=p5sagit%2Fp5-mst-13.2.git Fix (and test) spaces in {,un}pack() --- diff --git a/pp.c b/pp.c index 34c4ed3..6423e27 100644 --- a/pp.c +++ b/pp.c @@ -2682,7 +2682,9 @@ PP(pp_unpack) } while (pat < patend) { reparse: - datumtype = *pat++; + datumtype = *pat++ & 0xFF; + if (isSPACE(datumtype)) + continue; if (pat >= patend) len = 1; else if (*pat == '*') { @@ -2698,7 +2700,7 @@ PP(pp_unpack) len = (datumtype != '@'); switch(datumtype) { default: - croak("Invalid type in unpack: '%c'", datumtype); + croak("Invalid type in unpack: '%c'", (int)datumtype); case '%': if (len == 1 && pat[-1] != '1') len = 16; @@ -3460,7 +3462,9 @@ PP(pp_pack) sv_setpvn(cat, "", 0); while (pat < patend) { #define NEXTFROM (items-- > 0 ? *MARK++ : &sv_no) - datumtype = *pat++; + datumtype = *pat++ & 0xFF; + if (isSPACE(datumtype)) + continue; if (*pat == '*') { len = strchr("@Xxu", datumtype) ? 0 : items; pat++; @@ -3474,7 +3478,7 @@ PP(pp_pack) len = 1; switch(datumtype) { default: - croak("Invalid type in pack: '%c'", datumtype); + croak("Invalid type in pack: '%c'", (int)datumtype); case '%': DIE("%% may only be used in unpack"); case '@': diff --git a/t/op/pack.t b/t/op/pack.t index b11fe23..223b9d1 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -4,7 +4,7 @@ print "1..25\n"; -$format = "c2x5CCxsdila6"; +$format = "c2 x5 C C x s d i l a6"; # Need the expression in here to force ary[5] to be numeric. This avoids # test2 failing because ary2 goes str->numeric->str and ary doesn't. @ary = (1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef");