From: Alexandre Duret-Lutz Date: Sat, 29 Nov 2003 18:02:40 +0000 (+0000) Subject: * lib/Automake/VarDef.pm (value): Rename as ... X-Git-Tag: Release-1-7h~7 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=55acf600484f4ced5e324c6d67b6e89d3188775e;p=automake.git * lib/Automake/VarDef.pm (value): Rename as ... (raw_value): ... this. (value): New method, strip # and \n. (dump): Use raw_value. * lib/Automake/Variable.pm (output): Use raw_value. (value_as_list): Simplify, now that backslash and comments are already removed. * tests/txinfo22.test: Make sure Automake isn't confused by comments in variables. --- diff --git a/ChangeLog b/ChangeLog index 112f9ed7..e6c59c6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-11-29 Alexandre Duret-Lutz + + * lib/Automake/VarDef.pm (value): Rename as ... + (raw_value): ... this. + (value): New method, strip # and \\\n. + (dump): Use raw_value. + * lib/Automake/Variable.pm (output): Use raw_value. + (value_as_list): Simplify, now that backslash and comments + are already removed. + * tests/txinfo22.test: Make sure Automake isn't confused + by comments in variables. + 2003-11-27 Alexandre Duret-Lutz * doc/automake.texi: More target vs. rule editing. Back out some diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm index dde29c42..ea004440 100644 --- a/lib/Automake/VarDef.pm +++ b/lib/Automake/VarDef.pm @@ -38,17 +38,20 @@ Automake::VarDef - a class for variable definitions # Create a VarDef for a definition such as # | # any comment - # | foo = bar + # | foo = bar # more comment # in Makefile.am my $loc = new Automake::Location 'Makefile.am:2'; - my $def = new Automake::VarDef ('foo', 'bar', '# any comment', + my $def = new Automake::VarDef ('foo', 'bar # more comment', + '# any comment', $loc, '', VAR_MAKEFILE, VAR_ASIS); # Appending to a definition. $def->append ('value to append', 'comment to append'); # Accessors. - my $value = $def->value; + my $value = $def->value; # with trailing `#' comments and + # continuation ("\\\n") omitted. + my $value = $def->raw_value; # the real value, as passed to new(). my $comment = $def->comment; my $location = $def->location; my $type = $def->type; @@ -200,6 +203,18 @@ documentation of C's arguments for a description of these. =cut sub value ($) +{ + my ($self) = @_; + my $val = $self->raw_value; + # Strip anything past `#'. `#' characters cannot be escaped + # in Makefiles, so we don't have to be smart. + $val =~ s/#.*$//s; + # Strip backslashes. + $val =~ s/\\$/ /mg; + return $val; +} + +sub raw_value ($) { my ($self) = @_; return $self->{'value'}; @@ -289,7 +304,7 @@ sub dump ($) my $where = $self->location->dump; my $comment = $self->comment; - my $value = $self->value; + my $value = $self->raw_value; my $type = $self->type; return "{ diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 5bdf8e87..d9d09770 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -500,7 +500,7 @@ sub output ($@) $res .= $def->comment; - my $val = $def->value; + my $val = $def->raw_value; my $equals = $def->type eq ':' ? ':=' : '='; my $str = $cond->subst_string; @@ -569,8 +569,6 @@ sub value_as_list ($$;$$) my $onceflag; foreach my $vcond ($self->conditions->conds) { - my $val = $self->rdef ($vcond)->value; - if ($vcond->true_when ($cond)) { # If there is more than one definitions of $var matching @@ -581,16 +579,8 @@ sub value_as_list ($$;$$) if $onceflag; $onceflag = 1; - # Strip backslashes - $val =~ s/\\(\n|$)/ /g; - - foreach (split (' ', $val)) - { - # If a comment seen, just leave. - last if /^#/; - - push (@result, $_); - } + my $val = $self->rdef ($vcond)->value; + push @result, split (' ', $val); } } return @result; @@ -1259,7 +1249,7 @@ arguments: Typically you should do C<$cond->merge ($parent_cond)> to recompute the C<$full_cond> associated to C<@result>. C<&fun_collect> may return a list of items, that will be used as the result of -C (the top-level, or it's +C (the top-level, or its recursive calls). =cut @@ -1314,8 +1304,8 @@ sub _do_recursive_traversal ($$&&$$) { # If $val is a variable (i.e. ${foo} or $(bar), not a filename), # handle the sub variable recursively. - # (Backslashes between bracklets, before `}' and `)' are required - # only of Emacs's indentation.) + # (Backslashes before `}' and `)' within brackets are here to + # please Emacs's indentation.) if ($val =~ /^\$\{([^\}]*)\}$/ || $val =~ /^\$\(([^\)]*)\)$/) { my $subvarname = $1; diff --git a/tests/txinfo22.test b/tests/txinfo22.test index 5f62e83f..a2cf051d 100755 --- a/tests/txinfo22.test +++ b/tests/txinfo22.test @@ -20,6 +20,8 @@ # Make sure the user can override TEXINFO_TEX. # Report from Tom Tromey. +# Also make sure Automake ignores in-line comments when using variables, +# but preserve them in the output. required='makeinfo tex' . ./defs || exit 1 @@ -31,11 +33,14 @@ AC_CONFIG_AUX_DIR(aux) AC_OUTPUT END +# Use a slash in the comment, because automake takes the dirname +# of TEXINFO_TEX to compute $(am__TEXINFO_TEX_DIR)... cat > Makefile.am << 'END' -TEXINFO_TEX = tex/texinfo.tex +TEXINFO_TEX = $(srcdir)/tex/texinfo.tex # some comment w/ a slash info_TEXINFOS = main.texi sure_it_exists: test -f $(TEXINFO_TEX) + test -d "$(am__TEXINFO_TEX_DIR)" END cat > main.texi << 'END' @@ -62,3 +67,4 @@ test -f tex/texinfo.tex ./configure $MAKE sure_it_exists $MAKE distcheck +grep 'TEXINFO_TEX = .* # some comment w/ a slash' Makefile