From c5333953a555847ef4f1457905bf0f111a79eb72 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 18 May 2011 14:35:47 -0700 Subject: [PATCH] =?utf8?q?[perl=20#90160]=20U*=20gives=20=E2=80=98U0=20mod?= =?utf8?q?e=20on=20an=20empty=20string=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is a regression in 5.10 caused by change 23966/08ca2aa38a29, which added a bit of faulty logic. It was treating U* in the middle of a pack template as equivalent to U0, if the input string was empty. --- pp_pack.c | 2 +- t/op/pack.t | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pp_pack.c b/pp_pack.c index 5229fc3..c62754f 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -1660,7 +1660,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c break; case 'U': if (len == 0) { - if (explicit_length) { + if (explicit_length && howlen != e_star) { /* Switch to "bytes in UTF-8" mode */ if (symptr->flags & FLAG_DO_UTF8) utf8 = 0; else diff --git a/t/op/pack.t b/t/op/pack.t index 025bb09..43189ab 100644 --- 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 => 14699; +plan tests => 14700; use strict; use warnings qw(FATAL all); @@ -1993,3 +1993,7 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_ my $y = runperl( prog => 'print split( /,/, unpack(q(%32u*), q(#,3,Q)), qq(\n)), qq(\n)' ); is($y, "0\n", "split /a/, unpack('%32u*'...) didn't crash"); } + +#90160 +is(eval { () = unpack "C0 U*", ""; "ok" }, "ok", + 'medial U* on empty string'); -- 1.8.3.1