bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `autoconf -' does not work twice


From: Noah Misch
Subject: Re: `autoconf -' does not work twice
Date: Fri, 11 May 2007 21:22:32 -0700
User-agent: Mutt/1.5.9i

On Fri, May 11, 2007 at 05:37:22PM +0200, Ralf Wildenhues wrote:
> echo AC_INIT | autoconf - >/dev/null; autoconf -
> 
> does not wait for input from stdin as it should.  Rather, it reuses the
> output from cache.  I think this is a bug, stdin should not be cached.

I agree.  The following patch fixes it; comments, anyone?

This does not actually exclude `-' from caching, but never treats a cache
thereof as current.  Also, `autoconf -' was ignoring stdin in the presence of
additional input files like `acsite.m4' and `aclocal.m4'.

I mitigated an additional limitation resident in some of the lines I changed.
Autom4te was only searching the last input file for forbidden tokens; it now
searches most input files, beginning with the last one.  I exclude frozen files
(high potential for false positives) and stdin (we would need to save it to a
temporary file to begin with).  Perhaps this really belongs in a separate
change; I can split it out if someone prefers to review this in two parts.

The test suite now exercises all of these fixed behaviors.

2007-05-11  Noah Misch  <address@hidden>

        * bin/autoconf.as: Handle `-' just like other input files.
        * bin/autom4te.in (parse_args): Pass `-' through.
        (handle_output): Search most input files for forbidden tokens, excluding
        `-' and `*.m4f'.
        (up_to_date): Always treat stdin as out of date.
        * tests/tools.at (autoconf: input from stdin): New test.
        (autoconf: forbidden tokens, basic): Test an additional input file.

diff -Nurp -X dontdiff ac-clean/bin/autoconf.as ac-cachestdin/bin/autoconf.as
--- ac-clean/bin/autoconf.as    2007-05-05 00:39:13.000000000 -0400
+++ ac-cachestdin/bin/autoconf.as       2007-05-11 18:44:51.000000000 -0400
@@ -164,8 +164,8 @@ case $# in
       exit 1
     fi
     test -z "$traces" && test -z "$outfile" && outfile=configure;;
-  1) # autom4te doesn't like `-'.
-     test "x$1" != "x-" && infile=$1 ;;
+  1)
+    infile=$1 ;;
   *) exec >&2
      AS_ECHO(["$as_me: invalid number of arguments."])
      AS_ECHO(["$help"])
diff -Nurp -X dontdiff ac-clean/bin/autom4te.in ac-cachestdin/bin/autom4te.in
--- ac-clean/bin/autom4te.in    2007-05-05 00:39:13.000000000 -0400
+++ ac-cachestdin/bin/autom4te.in       2007-05-11 23:04:42.000000000 -0400
@@ -418,7 +418,11 @@ Try `$me --help' for more information."
   my @argv;
   foreach (@ARGV)
     {
-      if (/\.m4f$/)
+      if ($_ eq '-')
+       {
+         push @argv, $_;
+       }
+      elsif (/\.m4f$/)
        {
          # Frozen files are optional => pass a `?' to `find_file'.
          my $file = find_file ("$_?", @include);
@@ -584,29 +588,34 @@ sub handle_output ($$)
   return
     if ! %prohibited;
 
-  # Locate the forbidden words in the last input file.
-  # This is unsatisfying but...
   my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
-  my $file = new Autom4te::XFile ($ARGV[$#ARGV]);
   $exit_code = 1;
-
-  while ($_ = $file->getline)
-    {
-      # Don't complain in comments.  Well, until we have something
-      # better, don't consider `#include' etc. are comments.
-      s/\#.*//
-       unless /^\#(if|include|endif|ifdef|ifndef|define)\b/;
-
-      # Complain once per word, but possibly several times per line.
-      while (/$prohibited/)
+  # Search non-frozen input files for forbidden words, starting from the last
+  # (most-user-influenced) input.
+  foreach (reverse @ARGV)
+    {
+      next if $_ eq '-' || /\.m4f$/;
+
+      my $input = $_;
+      my $file = new Autom4te::XFile ($input);
+      while ($_ = $file->getline)
        {
-         my $word = $1;
-         warn_forbidden ("$ARGV[$#ARGV]:$.", $word, %forbidden);
-         delete $prohibited{$word};
-         # If we're done, exit.
-         return
-           if ! %prohibited;
-         $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
+         # Don't complain in comments.  Well, until we have something
+         # better, don't consider `#include' etc. are comments.
+         s/\#.*//
+           unless /^\#(if|include|endif|ifdef|ifndef|define)\b/;
+
+         # Complain once per word, but possibly several times per line.
+         while (/$prohibited/)
+           {
+             my $word = $1;
+             warn_forbidden ("$input:$.", $word, %forbidden);
+             delete $prohibited{$word};
+             # If we're done, exit.
+             return
+               if ! %prohibited;
+             $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
+           }
        }
     }
   warn_forbidden ("$output:$prohibited{$_}", $_, %forbidden)
@@ -876,6 +885,10 @@ sub up_to_date ($)
   # We depend at least upon the arguments.
   my @dep = @ARGV;
 
+  # stdin is always out of date.
+  if (grep { $_ eq '-' } @dep)
+    { return 0 }
+
   # Files may include others.  We can use traces since we just checked
   # if they are available.
   handle_traces ($req, "$tmp/dependencies",
diff -Nurp -X dontdiff ac-clean/tests/tools.at ac-cachestdin/tests/tools.at
--- ac-clean/tests/tools.at     2007-05-05 00:39:14.000000000 -0400
+++ ac-cachestdin/tests/tools.at        2007-05-11 22:58:50.000000000 -0400
@@ -274,6 +274,11 @@ _m4_bar
 AS_FOO
 _AS_BAR
 [dnl]
+breakme
+]])
+
+AT_DATA_M4SH([aclocal.m4],
+[[m4_define([breakme], [AS_BAZ])
 ]])
 
 AT_CHECK_AUTOCONF([], 1, [],
@@ -284,6 +289,7 @@ configure.ac:3: error: possibly undefine
 configure.ac:4: error: possibly undefined macro: AS@&address@hidden
 configure.ac:5: error: possibly undefined macro: _AS@&address@hidden
 configure.ac:6: error: possibly undefined macro: d@&address@hidden
+aclocal.m4:1: error: possibly undefined macro: AS@&address@hidden
 ]])
 
 AT_CLEANUP
@@ -386,6 +392,23 @@ AT_CHECK([[grep '^[^/].*/mkdir -p' sub/f
 AT_CLEANUP
 
 
+# autoconf: input from stdin
+# --------------------------
+AT_SETUP([autoconf: input from stdin])
+
+# Past Autoconf versions failed to read from stdin when other, non-frozen input
+# files were present.
+AT_DATA([aclocal.m4])
+
+AT_CHECK([echo 'AC_INIT(X, 1.0, address@hidden)' | autoconf -t AC_INIT -],
+        0, [stdin:1:AC_INIT:X:1.0:address@hidden
+])
+AT_CHECK([echo 'AC_INIT(X, 2.0, address@hidden)' | autoconf -t AC_INIT -],
+        0, [stdin:1:AC_INIT:X:2.0:address@hidden
+])
+
+AT_CLEANUP
+
 
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]