From: Father Chrysostomos Date: Wed, 7 Dec 2011 06:58:31 +0000 (-0800) Subject: Fix deparsing of undefined hint hash values X-Git-Tag: accepted/trunk/20130322.191538~1842 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04be0204ef928fb968a23b10c5c3bc555389ad14;p=platform%2Fupstream%2Fperl.git Fix deparsing of undefined hint hash values Undefined values in the hint hash were being deparsed as empty strings. Whenever the hint hash changed, all undefined values, even those unmodified, were being printed. --- diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index f203a53..24d17af 100644 --- a/dist/B-Deparse/Deparse.pm +++ b/dist/B-Deparse/Deparse.pm @@ -1510,8 +1510,10 @@ sub declare_hinthash { my @decls; for my $key (keys %$to) { next if $ignored_hints{$key}; - if (!defined $from->{$key} or $from->{$key} ne $to->{$key}) { - push @decls, qq(\$^H{'$key'} = q($to->{$key});); + if (!exists $from->{$key} or $from->{$key} ne $to->{$key}) { + push @decls, qq(\$^H{'$key'} = ) + . (defined $to->{$key} ? qq(q($to->{$key})) : 'undef') + . qq(;); } } for my $key (keys %$from) { diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index 84b9925..7b11ccf 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -793,3 +793,17 @@ print sort(foo('bar')); # substr assignment substr(my $a, 0, 0) = (foo(), bar()); $a++; +#### +# hint hash +BEGIN { $^H{'foo'} = undef; } +{ + BEGIN { $^H{'bar'} = undef; } + { + BEGIN { $^H{'baz'} = undef; } + { + print $_; + } + print $_; + } + print $_; +}