From 9cd72d5b32e371b085afc740e8b4c4f2cac152fa Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 4 Nov 2022 11:58:41 +0000 Subject: make: fix typo in inference rule handling A typo in the previous commit caused dyndep() to process inference rules incorrectly. This didn't affect the results of the test suite when extensions were allowed but it caused the test 'Inference rule with explicit rule for prerequisite' to fail in POSIX mode. --- miscutils/make.c | 2 +- testsuite/make.tests | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/miscutils/make.c b/miscutils/make.c index 86d06e970..1414f869c 100644 --- a/miscutils/make.c +++ b/miscutils/make.c @@ -722,7 +722,7 @@ dyndep(struct name *np, struct rule *imprule) continue; if (!ip->n_tim.tv_sec) modtime(ip); - if (chain ? ip->n_tim.tv_sec || (ip->n_flag & N_TARGET) : + if (!chain ? ip->n_tim.tv_sec || (ip->n_flag & N_TARGET) : dyndep(ip, NULL) != NULL) { // Prerequisite exists or we know how to make it if (imprule) { diff --git a/testsuite/make.tests b/testsuite/make.tests index 7bb736ade..70c1231b9 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests @@ -59,6 +59,25 @@ x.p: ' cd .. || exit 1; rm -rf make.tempdir 2>/dev/null +# Austin Group defect report 875 clarifies certain aspects of the +# behaviour of inference rules. Study of this resulted in a number +# of changes to pdpmake, though this test passed anyway. +mkdir make.tempdir && cd make.tempdir || exit 1 +touch test.j test.k +testing "make proper handling of inference rules 1" \ + "make -f -" \ + ".j.l\n" "" ' +.SUFFIXES: .j .k .l +.j.l: + @echo .j.l +.k.l: + @echo .k.l +test.l: test.k +test.j: +test.k: +' +cd .. || exit 1; rm -rf make.tempdir 2>/dev/null + # A macro created using ::= remembers it's of type immediate-expansion. # Immediate expansion also occurs when += is used to append to such a macro. testing "make appending to immediate-expansion macro" \ @@ -397,29 +416,11 @@ target: : hash # hash ' -# Austin Group defect report 875 clarifies certain aspects of the -# behaviour of inference rules. Study of this resulted in a number -# of changes to pdpmake. Since the issue at hand involves the use -# of chained inference rules it doesn't affect POSIX mode. -mkdir make.tempdir && cd make.tempdir || exit 1 -touch test.j test.k -testing "make proper handling of inference rules 1" \ - "make -f -" \ - ".j.l\n" "" ' -.SUFFIXES: .j .k .l -.j.l: - @echo .j.l -.k.l: - @echo .k.l -test.l: test.k -test.j: -test.k: -' -cd .. || exit 1; rm -rf make.tempdir 2>/dev/null - -# The actual test in the above-mentioned defect report was actually -# more demanding. It used the suffixes '.a .b .c'. This results in -# the built-in '.c.a' inference rule being introduced into the mix. +# Austin Group defect report 875 (mentioned above) actually used +# suffixes '.a .b .c'. This doesn't matter in POSIX mode but it +# caused a failure (now fixed) when chained inference rules were +# allowed. The '.a.c' and the built-in '.c.a' inference rules +# resulted in a loop. mkdir make.tempdir && cd make.tempdir || exit 1 touch test.a test.b testing "make proper handling of inference rules 2" \ -- cgit v1.2.3-55-g6feb