From: Akim Demaille Date: Wed, 16 Oct 2002 17:06:57 +0000 (+0000) Subject: Because of caching, some files that no longer exist and are no X-Git-Tag: AUTOCONF-2.54a~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aef93a0d753adee14ecaf43052f1d58a65d05b2c;p=thirdparty%2Fautoconf.git 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. --- diff --git a/ChangeLog b/ChangeLog index 840f4aedd..b95990e79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2002-10-16 Akim Demaille + + 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 * bin/autoconf.as: Kill dead options. diff --git a/bin/autom4te.in b/bin/autom4te.in index 507bd20be..7a50ac6fc 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -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) . ' $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) . ' 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. diff --git a/tests/tools.at b/tests/tools.at index b854d9771..f1de9599d 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -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. ##