From 6d4ffd8329ce1cd52d93406be25ff77367e23178 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Mon, 27 May 2013 11:14:22 +0200 Subject: [PATCH] suffix rules: better distinction between builtin and user-derived Fixes automake bug#14441. * lib/Automake/Rule.pm ($_suffix_rules_default): Remove, superseded by ... (%suffix_rules_builtin): ... this lexical variable. ($suffix_rules): Remove, superseded by ... (%suffix_rules): ... this lexical variable. (suffix_rules, suffix_rules_count): Adjust. (register_suffix_rule): Update '%suffix_rules_builtin' rather than '%suffix_rules' if the location (as passed by the '$where' argument) is an "internal" one (doesn't come from user-provided Makefile.am). (reset): Simplify resetting of '%suffix_rules' to the default ones accordingly. * t/list-of-tests.mk (XFAIL_TESTS): Drop test 'suffix-custom-pr14441.sh'. Signed-off-by: Stefano Lattarini --- lib/Automake/Rule.pm | 31 ++++++++++++------------------- t/list-of-tests.mk | 1 - 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm index 5f6f3a239..ed1fa24e6 100644 --- a/lib/Automake/Rule.pm +++ b/lib/Automake/Rule.pm @@ -101,10 +101,6 @@ my $_SUFFIX_RULE_PATTERN = # Suffixes found during a run. use vars '@_suffixes'; -# Same as $suffix_rules (declared below), but records only the -# default rules supplied by the languages Automake supports. -use vars '$_suffix_rules_default'; - =item C<%dependencies> Holds the dependencies of targets which dependencies are factored. @@ -154,7 +150,11 @@ C function. =cut -my $suffix_rules; +my %suffix_rules; + +# Same as $suffix_rules, but records only the default rules +# supplied by the languages Automake supports. +my %suffix_rules_builtin; =item C<$KNOWN_EXTENSIONS_PATTERN> @@ -317,16 +317,7 @@ sub reset() { %_rule_dict = (); @_suffixes = (); - # The first time we initialize the variables, - # we save the value of $suffix_rules. - if (defined $_suffix_rules_default) - { - $suffix_rules = $_suffix_rules_default; - } - else - { - $_suffix_rules_default = $suffix_rules; - } + %suffix_rules = %suffix_rules_builtin; %dependencies = ( @@ -393,9 +384,9 @@ XXX sub suffix_rule ($$) { my ($source_ext, $obj) = @_; - return undef unless (exists $suffix_rules->{$source_ext} and - exists $suffix_rules->{$source_ext}{$obj}); - return $suffix_rules->{$source_ext}{$obj}[0]; + return undef unless (exists $suffix_rules{$source_ext} and + exists $suffix_rules{$source_ext}{$obj}); + return $suffix_rules{$source_ext}{$obj}[0]; } =item C @@ -410,6 +401,8 @@ This upgrades the C<$suffix_rules> variables. sub register_suffix_rule ($$$) { my ($where, $src, $dest) = @_; + my $suffix_rules = $where->{'position'} ? \%suffix_rules + : \%suffix_rules_builtin; verb "Sources ending in $src become $dest"; push @_suffixes, $src, $dest; @@ -487,7 +480,7 @@ F (excluding predefined suffix rules). sub suffix_rules_count () { - return (scalar keys %$suffix_rules) - (scalar keys %$_suffix_rules_default); + return (scalar keys %suffix_rules) - (scalar keys %suffix_rules_builtin); } =item C<@list = suffixes> diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index 8407cf8a1..fb2e44409 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -41,7 +41,6 @@ t/remake-timing-bug-pr8365.sh \ t/lex-subobj-nodep.sh \ t/remake-am-pr10111.sh \ t/remake-m4-pr10111.sh \ -t/suffix-custom-pr14441.sh \ $(perl_fake_XFAIL_TESTS) perl_TESTS = \ -- 2.47.2