# 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,
# 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;
}
-=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);
$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",
}
+=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.