From: Stefano Lattarini Date: Thu, 3 May 2012 13:08:39 +0000 (+0200) Subject: [ng] vars: keep track of conditionals in appended values and comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3860029104551a6b5a40041b5fd05f176b37d8ba;p=thirdparty%2Fautomake.git [ng] vars: keep track of conditionals in appended values and comments This is a refactoring only needed by later changes. * lib/Automake/VarDef.pm: Updated methods and constructor. * lib/Automake/Variable.pm: Callers adjusted. Signed-off-by: Stefano Lattarini --- diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm index c40dc16cb..be956f281 100644 --- a/lib/Automake/VarDef.pm +++ b/lib/Automake/VarDef.pm @@ -136,9 +136,10 @@ be one of C, C. =cut -sub new ($$$$$$$$) +sub new ($$$$$$$$$) { - my ($class, $var, $value, $comment, $location, $type, $owner, $pretty) = @_; + my ($class, $var, $value, $comment, $cond, $location, $type, + $owner, $pretty) = @_; # A user variable must be set by either '=' or ':=', and later # promoted to '+='. @@ -148,28 +149,28 @@ sub new ($$$$$$$$) } my $self = Automake::ItemDef::new ($class, $location, $owner); - $self->{'value_list'} = [$value]; + $self->{'value_list'} = [ { value => $value, cond => $cond } ]; $self->{'type'} = $type; $self->{'pretty'} = $pretty; $self->{'seen'} = 0; - $self->{'comment_list'} = [$comment]; + $self->{'comment_list'} = [ { text => $comment, cond => $cond } ]; return $self; } -=item C<$def-Eappend ($value, $comment)> +=item C<$def-Eappend ($value, $comment, $cond)> -Append C<$value> and <$comment> to the existing value and comment of -C<$def>. This is normally called on C<+=> definitions. +Append C<$value> and C<$comment> to the existing value and comment of +C<$def> in condition C<$cond>. This is normally called on C<+=> +definitions. =cut sub append ($$$) { - my ($self, $value, $comment) = @_; + my ($self, $value, $comment, $cond) = @_; - push @{$self->{'comment_list'}}, $comment; - - push @{$self->{'value_list'}}, $value; + push @{$self->{'comment_list'}}, { text => $comment, cond => $cond }; + push @{$self->{'value_list'}}, { value => $value, cond => $cond }; # Turn ASIS appended variables into PRETTY variables. This is to # cope with 'make' implementation that cannot read very long lines. $self->{'pretty'} = VAR_PRETTY if $self->{'pretty'} == VAR_ASIS; @@ -204,13 +205,13 @@ sub value ($) sub comment ($) { my ($self) = @_; - return join ("", @{$self->{'comment_list'}}); + return join ("", map { $_->{text} } @{$self->{'comment_list'}}); } sub raw_value ($) { my ($self) = @_; - my @values = @{$self->{'value_list'}}; + my @values = map { $_->{value} } @{$self->{'value_list'}}; # Strip comments from augmented variables. This is so that # VAR = foo # com diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 0c83b6650..9c51c9e74 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -797,7 +797,7 @@ sub define ($$$$$$$$) # 1. append (+=) to a variable defined for current condition if ($type eq '+' && ! $new_var) { - $def->append ($value, $comment); + $def->append ($value, $comment, $cond); # Only increase owners. A VAR_CONFIGURE variable augmented in a # Makefile.am becomes a VAR_MAKEFILE variable. $def->set_owner ($owner, $where->clone) @@ -872,8 +872,8 @@ sub define ($$$$$$$$) # Assignments to a macro set its location. We don't adjust # locations for '+='. Ideally I suppose we would associate # line numbers with random bits of text. - $def = new Automake::VarDef ($var, $value, $comment, $where->clone, - $type, $owner, $pretty); + $def = new Automake::VarDef ($var, $value, $comment, $cond, + $where->clone, $type, $owner, $pretty); $self->set ($cond, $def); push @_var_order, $var; }