]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Save and check Autom4te version in cache
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 29 Jun 2020 23:51:08 +0000 (16:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jun 2020 00:08:26 +0000 (17:08 -0700)
Problem reported in <https://bugs.debian.org/219621>.
* bin/autom4te.in: Save and check autom4te version number into cache index.
* lib/Autom4te/C4che.pm (save): New arg $version.  All callers changed.
(good_version): New sub.

bin/autom4te.in
lib/Autom4te/C4che.pm

index bcf0d498534c87e5a069347d31643a0c04415455..4e2af77e5abbeb4ed5af588d54f0dcbd1aeeb328 100644 (file)
@@ -996,7 +996,8 @@ $icache_file->lock (LOCK_EX)
 # If autom4te is younger, then some structures such as C4che might
 # have changed, which would corrupt its processing.
 Autom4te::C4che->load ($icache_file)
-  if -f $icache && mtime ($icache) > mtime ($0);
+  if (-f $icache && mtime ($icache) > mtime ($0)
+      && Autom4te::C4che->good_version ($icache_file, '@VERSION@'));
 
 # Add the new trace requests.
 my $req = Autom4te::C4che->request ('input' => \@ARGV,
@@ -1061,7 +1062,7 @@ else
 
 # If we ran up to here, the cache is valid.
 $req->valid (1);
-Autom4te::C4che->save ($icache_file);
+Autom4te::C4che->save ($icache_file, '@VERSION@');
 
 exit $exit_code;
 
index b812f5d4a829c8d46570a829b0a3032650a262eb..76486e6acc99454ebd063671d082156a60ed85fb 100644 (file)
@@ -163,17 +163,17 @@ sub marshall ($)
 }
 
 
-=item C<Autom4te::C4che-E<gt>save ($file)>
+=item C<Autom4te::C4che-E<gt>save ($file, $version)>
 
 Save the cache in the C<$file> file object.
 
 =cut
 
-# SAVE ($FILE)
-# ------------
+# SAVE ($FILE, $VERSION)
+# ----------------------
 sub save ($$)
 {
-  my ($self, $file) = @_;
+  my ($self, $file, $version) = @_;
 
   confess "cannot save a single request\n"
     if ref ($self);
@@ -181,7 +181,7 @@ sub save ($$)
   $file->seek (0, 0);
   $file->truncate (0);
   print $file
-    "# This file was generated.\n",
+    "# This file was generated by Autom4te $version.\n",
     "# It contains the lists of macros which have been traced.\n",
     "# It can be safely removed.\n",
     "\n",
@@ -189,6 +189,21 @@ sub save ($$)
 }
 
 
+=item C<Autom4te::C4che-E<gt>good_version ($file, $version)>
+
+Succeed if the cache from the C<$file> file object is of the given version.
+
+=cut
+
+# GOOD_VERSION ($FILE, $VERSION)
+# ------------------------------
+sub good_version ($$)
+{
+  my ($self, $file, $version) = @_;
+  my ($line) = $file->getline;
+  return defined ($line) && $line eq "# This file was generated by Autom4te $version.\n";
+}
+
 =item C<Autom4te::C4che-E<gt>load ($file)>
 
 Load the cache from the C<$file> file object.