Module Name:    src
Committed By:   rillig
Date:           Sat Nov 21 12:01:17 UTC 2020

Modified Files:
        src/usr.bin/make: suff.c
        src/usr.bin/make/unit-tests: suff-rebuild.exp suff-rebuild.mk

Log Message:
make(1): add explanation for test suff-rebuild


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/suff.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/suff-rebuild.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/suff-rebuild.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.257 src/usr.bin/make/suff.c:1.258
--- src/usr.bin/make/suff.c:1.257	Sat Nov 21 10:36:01 2020
+++ src/usr.bin/make/suff.c	Sat Nov 21 12:01:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.257 2020/11/21 10:36:01 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.258 2020/11/21 12:01:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.257 2020/11/21 10:36:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.258 2020/11/21 12:01:16 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -642,6 +642,16 @@ SuffUpdateTarget(GNode *target, GNode **
     if (target->type == OP_TRANSFORM)
 	return FALSE;
 
+    /*
+     * XXX: What is the purpose of the 'ptr == target->name' condition here?
+     * In suff-rebuild.mk in the line '.SUFFIXES: .c .b .a', it prevents the
+     * rule '.b.c' from being added again during Suff_AddSuffix(".b").
+     */
+    /*
+     * XXX: What about a transformation ".cpp.c"?  If ".c" is added as a new
+     * suffix, it seems wrong that this transformation would be skipped just
+     * because ".c" happens to be a prefix of ".cpp".
+     */
     if ((ptr = strstr(target->name, suff->name)) == NULL ||
 	ptr == target->name)
 	return FALSE;

Index: src/usr.bin/make/unit-tests/suff-rebuild.exp
diff -u src/usr.bin/make/unit-tests/suff-rebuild.exp:1.4 src/usr.bin/make/unit-tests/suff-rebuild.exp:1.5
--- src/usr.bin/make/unit-tests/suff-rebuild.exp:1.4	Sat Nov 21 11:59:22 2020
+++ src/usr.bin/make/unit-tests/suff-rebuild.exp	Sat Nov 21 12:01:16 2020
@@ -30,7 +30,7 @@ defining transformation from `.c' to `'
 inserting ".c" (3) at end of list
 inserting "" (0) at end of list
 ParseReadLine (22): '	: Making ${.TARGET} from ${.IMPSRC}.'
-ParseReadLine (35): '.SUFFIXES: .c .b .a'
+ParseReadLine (44): '.SUFFIXES: .c .b .a'
 transformation .c complete
 ParseDoDependency(.SUFFIXES: .c .b .a)
 Adding ".END" to all targets.

Index: src/usr.bin/make/unit-tests/suff-rebuild.mk
diff -u src/usr.bin/make/unit-tests/suff-rebuild.mk:1.5 src/usr.bin/make/unit-tests/suff-rebuild.mk:1.6
--- src/usr.bin/make/unit-tests/suff-rebuild.mk:1.5	Sat Nov 21 11:55:57 2020
+++ src/usr.bin/make/unit-tests/suff-rebuild.mk	Sat Nov 21 12:01:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: suff-rebuild.mk,v 1.5 2020/11/21 11:55:57 rillig Exp $
+# $NetBSD: suff-rebuild.mk,v 1.6 2020/11/21 12:01:16 rillig Exp $
 #
 # Demonstrates what happens to transformation rules (called inference rules
 # by POSIX) when all suffixes are deleted.
@@ -28,6 +28,15 @@ suff-rebuild-example.a:
 # As of 2020-09-25, uncommenting the following line results in the error
 # message "don't know how to make suff-rebuild-example" though.
 #
+# If this is a bug, the actual cause is probably that when a suffix
+# transformation rule is defined, it is not added to the global list of
+# targets, see Suff_EndTransform.  Later, UpdateTargets iterates over exactly
+# this global list of targets though.
+#
+# If UpdateTargets were to iterate over 'transforms' as well, it still
+# wouldn't work because the condition 'ptr == target->name' skips these
+# transformation rules.
+
 #.SUFFIXES:
 
 # Add the suffixes back.  It should not matter that the order of the suffixes

Reply via email to