(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-29 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * 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 <adl@gnu.org>
* doc/automake.texi: More target vs. rule editing. Back out some
# 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;
=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'};
my $where = $self->location->dump;
my $comment = $self->comment;
- my $value = $self->value;
+ my $value = $self->raw_value;
my $type = $self->type;
return "{
$res .= $def->comment;
- my $val = $def->value;
+ my $val = $def->raw_value;
my $equals = $def->type eq ':' ? ':=' : '=';
my $str = $cond->subst_string;
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
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;
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<Automake::Variable::traverse_recursively> (the top-level, or it's
+C<Automake::Variable::traverse_recursively> (the top-level, or its
recursive calls).
=cut
{
# 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;
# 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
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'
./configure
$MAKE sure_it_exists
$MAKE distcheck
+grep 'TEXINFO_TEX = .* # some comment w/ a slash' Makefile