Module Name:    src
Committed By:   rillig
Date:           Fri Sep 25 06:06:15 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): document expansion of undefined variables in Var_Subst

>From reading the code alone, it is not obvious what effects this
innocent-looking code has.


To generate a diff of this commit:
cvs rdiff -u -r1.537 -r1.538 src/usr.bin/make/var.c

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/var.c
diff -u src/usr.bin/make/var.c:1.537 src/usr.bin/make/var.c:1.538
--- src/usr.bin/make/var.c:1.537	Fri Sep 25 05:04:51 2020
+++ src/usr.bin/make/var.c	Fri Sep 25 06:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.537 2020/09/25 05:04:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.537 2020/09/25 05:04:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.538 2020/09/25 06:06:15 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)	\
     if (!(DEBUG(VAR) && (cond)))	\
@@ -3780,6 +3780,10 @@ Var_Subst(const char *str, GNode *ctxt, 
 		    p = nested_p;
 		    errorReported = TRUE;
 		} else {
+		    /* Copy the initial '$' of the undefined expression,
+		     * thereby deferring expansion of the expression, but
+		     * expand nested expressions if already possible.
+		     * See unit-tests/varparse-undef-partial.mk. */
 		    Buf_AddByte(&buf, *p);
 		    p++;
 		}

Reply via email to