From d37572645496516ed45536ef36684ba890c8f09b Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 27 Feb 2012 18:24:57 +0100 Subject: Merge the code common to feature::import and feature::unimport. --- regen/feature.pl | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'regen/feature.pl') diff --git a/regen/feature.pl b/regen/feature.pl index 6d276ce511..79aa471687 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -606,29 +606,7 @@ sub import { croak("No features specified"); } - if (my $features = current_bundle) { - # Features are enabled implicitly via bundle hints. - normalise_hints $features; - } - while (@_) { - my $name = shift; - if (substr($name, 0, 1) eq ":") { - my $v = substr($name, 1); - if (!exists $feature_bundle{$v}) { - $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/; - if (!exists $feature_bundle{$v}) { - unknown_feature_bundle(substr($name, 1)); - } - } - unshift @_, @{$feature_bundle{$v}}; - next; - } - if (!exists $feature{$name}) { - unknown_feature($name); - } - $^H{$feature{$name}} = 1; - $^H |= $hint_uni8bit if $name eq 'unicode_strings'; - } + __common(1, @_); } sub unimport { @@ -640,6 +618,12 @@ sub unimport { return; } + __common(0, @_); +} + + +sub __common { + my $import = shift; if (my $features = current_bundle) { # Features are enabled implicitly via bundle hints. normalise_hints $features; @@ -660,7 +644,10 @@ sub unimport { if (!exists $feature{$name}) { unknown_feature($name); } - else { + if ($import) { + $^H{$feature{$name}} = 1; + $^H |= $hint_uni8bit if $name eq 'unicode_strings'; + } else { delete $^H{$feature{$name}}; $^H &= ~ $hint_uni8bit if $name eq 'unicode_strings'; } -- cgit v1.2.1