From 01787caa82193584763826ee45b4a558ee49594e Mon Sep 17 00:00:00 2001 From: psmith Date: Fri, 2 Sep 2011 05:37:54 +0000 Subject: [PATCH] Ensure that -n takes precedence over -t. Patch from Michael Witten --- ChangeLog | 5 +++++ remake.c | 4 ++++ tests/ChangeLog | 5 +++++ tests/scripts/options/dash-n | 17 ++++++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 09f657a..34411cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-09-02 Paul Smith + + * remake.c (touch_file): If we have both -n and -t, -n takes + precedence. Patch from Michael Witten + 2011-08-29 Paul Smith * expand.c (variable_expand_string): Always allocate a new buffer diff --git a/remake.c b/remake.c index 97e3854..669eadc 100644 --- a/remake.c +++ b/remake.c @@ -1113,6 +1113,10 @@ touch_file (struct file *file) if (!silent_flag) message (0, "touch %s", file->name); + /* Print-only (-n) takes precedence over touch (-t). */ + if (just_print_flag) + return 0; + #ifndef NO_ARCHIVES if (ar_name (file->name)) return ar_touch (file->name); diff --git a/tests/ChangeLog b/tests/ChangeLog index 32213bb..03983ec 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2011-09-02 Paul Smith + + * scripts/options/dash-n: Verify that in "-n -t", the -n takes + priority. Patch from Michael Witten . + 2011-08-29 Paul Smith * scripts/features/varnesting: Test resetting of variables while diff --git a/tests/scripts/options/dash-n b/tests/scripts/options/dash-n index de19f42..248e0c8 100644 --- a/tests/scripts/options/dash-n +++ b/tests/scripts/options/dash-n @@ -65,6 +65,21 @@ $answer = "$make_name: `a' is up to date.\n"; $answer = "$make_name: `a' is up to date.\n"; &compare_output($answer, &get_logfile(1)); -unlink('a', 'b', 'c'); +# TEST 4 + +unlink(qw(a b)); + +&run_make_with_options($makefile2, "-t -n", &get_logfile); + +open(DASH_N_LOG, ">>" . &get_logfile(1)); +print DASH_N_LOG "a exists but should not!\n" if -e 'a'; +print DASH_N_LOG "b exists but should not!\n" if -e 'b'; +close(DASH_N_LOG); + +&compare_output("touch b\ntouch a\n", &get_logfile(1)); + +# CLEANUP + +unlink(qw(a b c)); 1; -- 2.11.4.GIT