summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-06-29 16:51:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-06-29 17:08:26 -0700
commitb3eb40f9c9919e5c40762cab1196715bd8796af1 (patch)
tree109c4fabed3bc5800d05406aa7d1d4101ef03623
parenta1d8293f3bfa2516f9a0424e3a6e63c2f8e93c6e (diff)
downloadautoconf-b3eb40f9c9919e5c40762cab1196715bd8796af1.tar.gz
Save and check Autom4te version in cache
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.
-rw-r--r--bin/autom4te.in5
-rw-r--r--lib/Autom4te/C4che.pm25
2 files changed, 23 insertions, 7 deletions
diff --git a/bin/autom4te.in b/bin/autom4te.in
index bcf0d498..4e2af77e 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -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;
diff --git a/lib/Autom4te/C4che.pm b/lib/Autom4te/C4che.pm
index b812f5d4..76486e6a 100644
--- a/lib/Autom4te/C4che.pm
+++ b/lib/Autom4te/C4che.pm
@@ -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.