From: Paul Eggert Date: Mon, 29 Jun 2020 23:51:08 +0000 (-0700) Subject: Save and check Autom4te version in cache X-Git-Tag: v2.69b~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3eb40f9c9919e5c40762cab1196715bd8796af1;p=thirdparty%2Fautoconf.git Save and check Autom4te version in cache Problem reported in . * 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. --- 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 Csave ($file)> +=item Csave ($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 Cgood_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 Cload ($file)> Load the cache from the C<$file> file object.