]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Because of caching, some files that no longer exist and are no
authorAkim Demaille <akim@epita.fr>
Wed, 16 Oct 2002 17:06:57 +0000 (17:06 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 16 Oct 2002 17:06:57 +0000 (17:06 +0000)
longer required can still cause errors.
Reported by Alexandre Duret-Lutz.
* bin/autom4te.in (&parse_args): Do not prepend `--reload-state'
to frozen files in @ARGV, as @ARGV must remain being a list of
files.  Rather, at M4 call sites, use this...
(&files_to_options): New function.
(&freeze): Use &error.
(&up_to_date): If a file that was included according to the cache
is no longer there, then the output is out dated.
(&main): Don't even check whether a file is up to date is anyway
--force is given.
* tests/tools.at (autom4te cache): New.

ChangeLog
bin/autom4te.in
tests/tools.at

index 840f4aedde82de6014a094b742f4e9fb8ec210d6..b95990e7950cbcc2289fea19a218a9bd66786816 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-10-16  Akim Demaille  <akim@epita.fr>
+
+       Because of caching, some files that no longer exist and are no
+       longer required can still cause errors.
+       Reported by Alexandre Duret-Lutz.
+
+       * bin/autom4te.in (&parse_args): Do not prepend `--reload-state'
+       to frozen files in @ARGV, as @ARGV must remain being a list of
+       files.  Rather, at M4 call sites, use this...
+       (&files_to_options): New function.
+       (&freeze): Use &error.
+       (&up_to_date): If a file that was included according to the cache
+       is no longer there, then the output is out dated.
+       (&main): Don't even check whether a file is up to date is anyway
+       --force is given.
+       * tests/tools.at (autom4te cache): New.
+
 2002-10-16  Akim Demaille  <akim@epita.fr>
 
        * bin/autoconf.as: Kill dead options.
index 507bd20be7da43c213881948b38afd79a2c57523..7a50ac6fc4eac13bd6770a25d0907599ee6c3417 100644 (file)
@@ -419,6 +419,30 @@ EOF
 ## ---------- ##
 
 
+# $OPTION
+# files_to_options (@FILE)
+# ------------------------
+# Transform Autom4te conventions (e.g., using foo.m4f to designate a frozen
+# file) into a suitable command line for M4 (e.g., using --reload-state).
+sub files_to_options (@)
+{
+  my (@file) = @_;
+  my @res;
+  foreach my $file (@file)
+    {
+      if ($file =~ /\.m4f$/)
+       {
+         push @res, "--reload-state=$file";
+       }
+      else
+       {
+         push @res, $file;
+       }
+    }
+  return join ' ', @res;
+}
+
+
 # load_configuration ()
 # ---------------------
 # Load the configuration file.
@@ -562,7 +586,7 @@ Try `$me --help' for more information."
          my $file = find_file ("$_?", @include);
          if (!$melt && $file)
            {
-             @argv = ("--reload-state=$file");
+             @argv = ($file);
            }
          else
            {
@@ -610,7 +634,7 @@ sub handle_m4 ($@)
           . ' --debug=aflq'
           . " --error-output=$tcache" . $req->id . "t"
           . join (' --trace=',   '', sort @macro)
-          . " @ARGV"
+          . " " . files_to_options (@ARGV)
           . ' </dev/null'
           . " >$ocache" . $req->id . "t");
 
@@ -1028,7 +1052,18 @@ sub up_to_date ($)
                 ('include'    => '$1',
                  'm4_include' => '$1'));
   my $deps = new Autom4te::XFile ("$tmp/dependencies");
-  push @dep, map { chomp; find_file ($_, @include) } $deps->getlines;
+  while ($_ = $deps->getline)
+    {
+      chomp;
+      my $file = find_file ("$_?", @include);
+      # If a file which used to be included is no longer there, then
+      # don't say it's missing (it might no longer be included).  But
+      # of course, that cause the output to be outdated (as if the
+      # time stamp of that missing file was newer).
+      return 0
+       if ! $file;
+      push @dep, $file;
+    }
 
   # If $FILE is younger than one of its dependencies, it is outdated.
   return up_to_date_p ($file, @dep);
@@ -1051,15 +1086,13 @@ sub freeze ($)
                    . ' --fatal-warning'
                    . join (' --include=', '', @include)
                    . ' --define=divert'
-                   . " @ARGV"
+                   . " " . files_to_options (@ARGV)
                    . ' </dev/null');
   $result =~ s/#.*\n//g;
   $result =~ s/^\n//mg;
-  if ($result)
-    {
-      print STDERR "$me: freezing produced output:\n$result";
-      exit 1;
-    }
+
+  error "freezing produced output:\n$result"
+    if $result;
 
   # If freezing produces output, something went wrong: a bad `divert',
   # or an improper paren etc.
@@ -1067,7 +1100,7 @@ sub freeze ($)
           . ' --fatal-warning'
           . join (' --include=', '', @include)
           . " --freeze-state=$output"
-          . " @ARGV"
+          . " " . files_to_options (@ARGV)
           . ' </dev/null');
 }
 
@@ -1104,16 +1137,13 @@ my $req = Request->request ('input' => \@ARGV,
                            'path'  => \@include,
                            'macro' => [keys %trace, @preselect]);
 
-# If $REQ's cache files are not up to date, declare it invalid.
+# If $REQ's cache files are not up to date, or simply if the user
+# discarded them (-f), declare it invalid.
 $req->valid (0)
-  if ! up_to_date ($req);
+  if $force || ! up_to_date ($req);
 
 # We now know whether we can trust the Request object.  Say it.
-if ($verbose)
-  {
-    print STDERR "$me: the trace request object is:\n";
-    print STDERR $req->marshall;
-  }
+verbose "$me: the trace request object is:\n" . $req->marshall;
 
 # We need to run M4 if (i) the users wants it (--force), (ii) $REQ is
 # invalid.
index b854d9771e9e38c58552584f448a45df0ac17225..f1de9599d37783b603e8f231ec2da0583025aa9e 100644 (file)
@@ -111,6 +111,39 @@ AT_CLEANUP
 
 
 
+## ------------------ ##
+## autom4te's cache.  ##
+## ------------------ ##
+
+AT_SETUP([autom4te cache])
+
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([foo])
+]])
+
+# Everything is OK.
+touch foo
+AT_CHECK_M4SUGAR
+
+# We moved a file: it should fail
+mkdir sub
+mv foo sub
+AT_CHECK_M4SUGAR([], [], [], [stderr])
+AT_CHECK([[sed 's/^[^:]*m4:/m4:/' stderr]], [],
+[m4: script.4s: 1: Cannot open foo: No such file or directory
+])
+
+# But if we change the main file, then we should no longer complain of
+# missing files.
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([sub/foo])
+]])
+AT_CHECK_M4SUGAR
+
+AT_CLEANUP
+
+
+
 
 ## ------------------ ##
 ## autoconf --trace.  ##