- Fix bug #7144 (infinite loop sometimes with -q and double-colon rules)
authorPaul Smith <psmith@gnu.org>
Mon, 28 Feb 2005 09:41:25 +0000 (09:41 +0000)
committerPaul Smith <psmith@gnu.org>
Mon, 28 Feb 2005 09:41:25 +0000 (09:41 +0000)
- Resolve support request #103195 (rationalize wordlist fn arguments)

ChangeLog
function.c
remake.c
tests/ChangeLog
tests/scripts/options/dash-B
tests/scripts/options/dash-q

index 46964204675009a3241c7bffaae64dc0f37ebb20..b9f4ad7464e92afb86d4926fa5b48736bfb57f24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-02-28  Paul D. Smith  <psmith@gnu.org>
+
+       * doc/make.texi (Text Functions): Update docs to allow the end
+       ordinal for $(wordlist ...) to be 0.
+       * function.c (func_wordlist): Fail if the start ordinal for
+       $(wordlist ...) is <1.  Matches documentation.
+       Resolves Savannah support request #103195.
+
+       * remake.c (update_goal_chain): Fix logic for stopping in -q:
+       previously we were stopping when !-q, exactly the opposite.  This
+       has been wrong since version 1.34, in 1994!
+       (update_file): If we got an error don't break out to run more
+       double-colon rules: just return immediately.
+       Fixes Savannah bug #7144.
+
 2005-02-27  Paul D. Smith  <psmith@gnu.org>
 
        * misc.c (end_of_token): Make argument const.
index 66d23fd5d1d3c8cf2169787f94491033d1039c2a..c2bd16fc3399840993912fa5bf63beaa550b2dbd 100644 (file)
@@ -771,6 +771,10 @@ func_wordlist (char *o, char **argv, const char *funcname UNUSED)
                 _("non-numeric second argument to `wordlist' function"));
 
   start = atoi (argv[0]);
+  if (start < 1)
+    fatal (reading_file, "invalid first argument to `wordlist' function: '%d'",
+           message, start);
+
   count = atoi (argv[1]) - start + 1;
 
   if (count > 0)
index e1def6480a389fe96ddb30973e64fe90674c617d..eb34c924d7d6b85add045139747d3ab844f4c26f 100644 (file)
--- a/remake.c
+++ b/remake.c
@@ -176,7 +176,7 @@ update_goal_chain (struct dep *goals)
                       /* If -q just triggered, stop immediately.  It doesn't
                          matter how much more we run, since we already know
                          the answer to return.  */
-                      stop = (!keep_going_flag && !question_flag
+                      stop = (question_flag && !keep_going_flag
                               && !rebuilding_makefiles);
                     }
                   else
@@ -307,8 +307,9 @@ update_file (struct file *file, unsigned int depth)
       status |= update_file_1 (f, depth);
       check_renamed (f);
 
+      /* If we got an error, don't bother with double_colon etc.  */
       if (status != 0 && !keep_going_flag)
-       break;
+       return status;
 
       if (f->command_state == cs_running
           || f->command_state == cs_deps_running)
index 41c9b34b8f99adf24e78f539ff965dbc7d6eb39f..1979324361bbe2279a7ba78af9253d039a8838ac 100644 (file)
@@ -1,5 +1,7 @@
 2005-02-28  Paul D. Smith  <psmith@gnu.org>
 
+       * scripts/options/dash-q: Add a test for Savannah bug # 7144.
+
        * scripts/options/symlinks: New file to test checking of symlink
        timestamps.  Can't use filename dash-L because it conflicts with
        dash-l on case-insensitive filesystems.
index 32992b3c6c1b0c875eab0f64029a8fd92c93b9bb..4ac377f9be718574de1a9c6710e911571595cfbc 100644 (file)
@@ -8,9 +8,9 @@ Invoke make once, so it builds everything.  Invoke it again and verify
 that nothing is built.  Then invoke it with -B and verify that everything
 is built again.";
 
-open(MAKEFILE,"> $makefile");
+&touch('bar.x');
 
-print MAKEFILE <<'EOF';
+run_make_test('
 .SUFFIXES:
 
 .PHONY: all
@@ -19,25 +19,21 @@ all: foo
 foo: bar.x
        @echo cp $< $@
        @echo "" > $@
-EOF
-
-close(MAKEFILE);
+',
+              '', 'cp bar.x foo');
 
+run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
+run_make_test(undef, '-B', 'cp bar.x foo');
 
-&touch('bar.x');
+# Put the timestamp for foo into the future; it should still be remade.
 
-&run_make_with_options($makefile, '', &get_logfile);
-$answer = "cp bar.x foo\n";
-&compare_output($answer, &get_logfile(1));
+utouch(1000, 'foo');
+run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
+run_make_test(undef, '-B', 'cp bar.x foo');
 
-&run_make_with_options($makefile, '', &get_logfile);
-$answer = "$make_name: Nothing to be done for `all'.\n";
-&compare_output($answer, &get_logfile(1));
 
-&run_make_with_options($makefile, '-B', &get_logfile);
-$answer = "cp bar.x foo\n";
-&compare_output($answer, &get_logfile(1));
+# Clean up
 
-unlink('bar.x', 'foo') unless $keep;
+rmfiles('bar.x', 'foo');
 
 1;
index 923e4c4b207b53bbcff3be8a51c70f49f2928b6e..56f04a1f8275570d0df6d6fb46e9894bb959c3f9 100644 (file)
@@ -3,11 +3,9 @@ $description = "Test the -q option.\n";
 
 $details = "Try various uses of -q and ensure they all give the correct results.\n";
 
-open(MAKEFILE, "> $makefile");
-
-# The Contents of the MAKEFILE ...
+# TEST 0
 
-print MAKEFILE <<'EOMAKE';
+run_make_test('
 one:
 two: ;
 three: ; :
@@ -21,50 +19,39 @@ seven: ; \
  $(.XY)
        : foo
        $(.XY)
-EOMAKE
-
-close(MAKEFILE);
-
-# TEST 0
-
-&run_make_with_options($makefile, "-q one", &get_logfile);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+',
+              '-q one', '');
 
 # TEST 1
 
-&run_make_with_options($makefile, "-q two", &get_logfile);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q two', '');
 
 # TEST 2
 
-&run_make_with_options($makefile, "-q three", &get_logfile, 256);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q three', '', 256);
 
 # TEST 3
 
-&run_make_with_options($makefile, "-q four", &get_logfile);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q four', '');
 
 # TEST 4
 
-&run_make_with_options($makefile, "-q five", &get_logfile);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q five', '');
 
 # TEST 5
 
-&run_make_with_options($makefile, "-q six", &get_logfile);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q six', '');
 
 # TEST 6
 
-&run_make_with_options($makefile, "-q seven", &get_logfile, 256);
-$answer = "";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, '-q seven', '', 256);
+
+# TEST 7 : Savannah bug # 7144
+
+run_make_test('
+one:: ; @echo one
+one:: ; @echo two
+',
+              '-q', '', 256);
 
 1;