From: Ton Hospel Date: Sat, 29 Jan 2005 13:07:38 +0000 (+0000) Subject: Re: encoding neutral unpack X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0c81e54bc30e3e0dec16be656a10a6c616817930;p=p5sagit%2Fp5-mst-13.2.git Re: encoding neutral unpack From: perl5-porters[at]ton.iguana.be (Ton Hospel) Message-ID: Make U0 and C0 scoped to () pack subtemplates. (plus a regression test) p4raw-id: //depot/perl@23923 --- diff --git a/pp_pack.c b/pp_pack.c index 97e0a06..cf020d6 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -991,6 +991,10 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c while (len--) { symptr->patptr = savsym.grpbeg; unpack_rec(symptr, ss, strbeg, strend, &ss ); + if (savsym.flags & FLAG_UNPACK_DO_UTF8) + symptr->flags |= FLAG_UNPACK_DO_UTF8; + else + symptr->flags &= ~FLAG_UNPACK_DO_UTF8; if (ss == strend && savsym.howlen == e_star) break; /* No way to continue */ } diff --git a/t/op/pack.t b/t/op/pack.t index 3fc4cfd..701b7b0 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 => 13857; +plan tests => 13859; use strict; use warnings; @@ -1502,3 +1502,10 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_ # verify that the checksum is not overflowed with C0 is(unpack("C0%128U", "abcd"), unpack("U0%128U", "abcd"), "checksum not overflowed"); } + +{ + # U0 and C0 must be scoped + my (@x) = unpack("a(U0)U", "b\341\277\274"); + is($x[0], 'b', 'before scope'); + is($x[1], 225, 'after scope'); +}