From: Alexandre Duret-Lutz Date: Thu, 29 May 2003 17:34:52 +0000 (+0000) Subject: * lib/Automake/Variable.pm (output): Declare as a method, since it X-Git-Tag: Release-1-7b~172 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=94b1f64085a8659ef687267a6e9555877e61db52;p=automake.git * lib/Automake/Variable.pm (output): Declare as a method, since it is only used this way. (define): Fix documentation of $cond. Suggested by Raja R. Harinath. --- diff --git a/ChangeLog b/ChangeLog index 941b10d3..b6e54ca4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-05-29 Alexandre Duret-Lutz + + * lib/Automake/Variable.pm (output): Declare as a method, since it + is only used this way. + (define): Fix documentation of $cond. + Suggested by Raja R. Harinath. + 2003-05-25 Alexandre Duret-Lutz * lib/Automake/Variable.pm, lib/Automake/VarDef.pm: New files. diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index c7a57bf0..e5dffb54 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -552,6 +552,56 @@ sub check_defined_unconditionally ($;$) } } +=item C<$str = $var->output ([@conds])> + +Format all the definitions of C<$var> if C<@cond> is not specified, +else only that corresponding to C<@cond>. + +=cut + +sub output ($@) +{ + my ($var, @conds) = @_; + + @conds = $var->conditions->conds + unless @conds; + + my $res = ''; + my $name = $var->name; + + foreach my $cond (@conds) + { + my $def = $var->def ($cond); + prog_error ("unknown condition `" . $cond->human . "' for `$var'") + unless $def; + + next + if $def->pretty == VAR_SILENT; + + $res .= $def->comment; + + my $val = $def->value; + my $equals = $def->type eq ':' ? ':=' : '='; + my $str = $cond->subst_string; + + if ($def->pretty == VAR_PRETTY) + { + # Suppress escaped new lines. &makefile_wrap will + # add them back, maybe at other places. + $val =~ s/\\$//mg; + $res .= makefile_wrap ("$str$name $equals", "$str\t", + split (' ' , $val)); + } + else # VAR_ASIS + { + my $output_var = "$name $equals $val"; + $output_var =~ s/^/$str/meg; + $res .= "$output_var\n"; + } + } + return $res; +} + =back =head2 Utility functions @@ -680,7 +730,7 @@ Variables can be overriden, provided the new owner is not weaker C<$type>: the type of the assignment (C<''> for C, C<':'> for C, and C<'+'> for C<'FOO += bar'>). -C<$cond>: the DisjConditions in which C<$var> is being defined. +C<$cond>: the C in which C<$var> is being defined. C<$value>: the value assigned to C<$var> in condition C<$cond>. @@ -1247,58 +1297,6 @@ sub variable_value_as_list($$;$) return @result; } -=item C<$str = output ($var, [@conds])> - -Format all the definitions of C<$var> if C<@cond> is not specified, -else only that corresponding to C<@cond>. - -=cut - -sub output ($@) -{ - my ($var, @conds) = @_; - - $var = ref ($var) ? $var : rvar ($var); - - @conds = $var->conditions->conds - unless @conds; - - my $res = ''; - my $name = $var->name; - - foreach my $cond (@conds) - { - my $def = $var->def ($cond); - prog_error ("unknown condition `" . $cond->human . "' for `$var'") - unless $def; - - next - if $def->pretty == VAR_SILENT; - - $res .= $def->comment; - - my $val = $def->value; - my $equals = $def->type eq ':' ? ':=' : '='; - my $str = $cond->subst_string; - - if ($def->pretty == VAR_PRETTY) - { - # Suppress escaped new lines. &makefile_wrap will - # add them back, maybe at other places. - $val =~ s/\\$//mg; - $res .= makefile_wrap ("$str$name $equals", "$str\t", - split (' ' , $val)); - } - else # VAR_ASIS - { - my $output_var = "$name $equals $val"; - $output_var =~ s/^/$str/meg; - $res .= "$output_var\n"; - } - } - return $res; -} - =item C<$str = output_variables>