diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-05-18 14:35:47 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-08 18:10:52 -0700 |
commit | 8810060590224e6a5023e64138f0c038e2c3ba5d (patch) | |
tree | ad67b3e9ac9455b30047845681d030b3810cb72e | |
parent | f821f5e5615c65b86c37ea6d1f40886fde8ef34b (diff) | |
download | perl-8810060590224e6a5023e64138f0c038e2c3ba5d.tar.gz |
[perl #90160] U* gives ‘U0 mode on an empty string’
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.
(cherry picked from commit c5333953a555847ef4f1457905bf0f111a79eb72)
-rw-r--r-- | pp_pack.c | 2 | ||||
-rw-r--r-- | t/op/pack.t | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -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 5775cafb53..7b9912aa94 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'); |