]> sourceware.org Git - automake.git/commitdiff
* lib/Automake/VarDef.pm (value): Rename as ...
authorAlexandre Duret-Lutz <adl@gnu.org>
Sat, 29 Nov 2003 18:02:40 +0000 (18:02 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sat, 29 Nov 2003 18:02:40 +0000 (18:02 +0000)
(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.

ChangeLog
lib/Automake/VarDef.pm
lib/Automake/Variable.pm
tests/txinfo22.test

index 112f9ed7ffc14eb3c47a6a6c2df08f9f89265c20..e6c59c6a0798a1f13b7eca10ae7b2d292642214b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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
index dde29c42f92992099dcb5d4db940c844cbf63a24..ea0044408da2e785a35008983df1a279e00a63d3 100644 (file)
@@ -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<new>'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 "{
index 5bdf8e871d2beb6216ee653ec8bc2d23a5e23912..d9d0977039254084fb715e05287267468957a757 100644 (file)
@@ -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<Automake::Variable::traverse_recursively> (the top-level, or it's
+C<Automake::Variable::traverse_recursively> (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;
index 5f62e83f3a26dce70ca40773ea4245e6ccddacc7..a2cf051d263c5a9b92570a06c27c1145bfe954f3 100755 (executable)
@@ -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
This page took 0.034791 seconds and 5 git commands to generate.