From 93704dd565e12a81f44ad4e98abfbef82227f63e Mon Sep 17 00:00:00 2001 From: Dmitry Goncharov Date: Tue, 1 Oct 2024 22:14:31 -0400 Subject: [PATCH] [SV 66268] Include newlines in file removal error message * src/file.c (remove_intermediates): Fix an error message about a failure to remove an intermediate file. * tests/scripts/features/patternrules: Add tests. --- src/file.c | 5 ++++- tests/scripts/features/patternrules | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/file.c b/src/file.c index 3b1a8d31..6056bb56 100644 --- a/src/file.c +++ b/src/file.c @@ -432,7 +432,10 @@ remove_intermediates (int sig) } if (status < 0) { - perror_with_name ("\nunlink: ", f->name); + if (doneany) + fputs ("\n", stdout); + fflush (stdout); + perror_with_name ("unlink: ", f->name); /* Start printing over. */ doneany = 0; } diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules index aab4c3d0..24d9cfc0 100644 --- a/tests/scripts/features/patternrules +++ b/tests/scripts/features/patternrules @@ -672,5 +672,26 @@ $r%.x: $dollar\$(wordlist 1, 99, ${prefix}%${suffix}.1 ${prefix}%${suffix}.2); \ } } +# SV 66268. An error message about a failure to remove an intermediate file. +run_make_test(q! +all: hello.x +%.x: b/%.q; $(info $@ from $<) +b/%.q:; @mkdir b; touch $@; chmod -w b +!, '', "hello.x from b/hello.q\nrm b/hello.q\n#MAKE#: unlink: b/hello.q: $ERR_unreadable_file\n"); + +chmod(0754, 'b'); +unlink('b/hello.q'); +rmdir('b'); + +run_make_test(q! +all: hello.x +%.x: b/%.q; $(info $@ from $<) +b/%.q:; @mkdir b; touch $@; chmod -w b +!, '-s', "hello.x from b/hello.q\n#MAKE#: unlink: b/hello.q: $ERR_unreadable_file\n"); + +chmod(0754, 'b'); +unlink('b/hello.q'); +rmdir('b'); + # This tells the test driver that the perl test script executed properly. 1; -- 2.47.3