Module Name: src
Committed By: rillig
Date: Thu Dec 31 13:56:56 UTC 2020
Modified Files:
src/usr.bin/make: for.c
Log Message:
make(1): make control flow in SubstVarLong of .for loops more obvious
To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/make/for.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/for.c
diff -u src/usr.bin/make/for.c:1.130 src/usr.bin/make/for.c:1.131
--- src/usr.bin/make/for.c:1.130 Thu Dec 31 13:37:33 2020
+++ src/usr.bin/make/for.c Thu Dec 31 13:56:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.130 2020/12/31 13:37:33 rillig Exp $ */
+/* $NetBSD: for.c,v 1.131 2020/12/31 13:56:56 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
#include "make.h"
/* "@(#)for.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: for.c,v 1.130 2020/12/31 13:37:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.131 2020/12/31 13:56:56 rillig Exp $");
static int forLevel = 0; /* Nesting level */
@@ -352,7 +352,7 @@ Buf_AddEscaped(Buffer *cmds, const char
}
/*
- * While expanding the body of a .for loop, replace the inner part of an
+ * While expanding the body of a .for loop, replace the variable name of an
* expression like ${i} or ${i:...} or $(i) or $(i:...) with ":Uvalue".
*/
static void
@@ -374,7 +374,10 @@ SubstVarLong(For *f, const char **pp, co
p[varnameLen] != '\\')
continue;
- /* Found a variable match. Replace with :U<value> */
+ /*
+ * Found a variable match. Skip over the variable name and
+ * instead add ':U<value>' to the current body.
+ */
Buf_AddBytesBetween(&f->curBody, *inout_mark, p);
Buf_AddStr(&f->curBody, ":U");
Buf_AddEscaped(&f->curBody,
@@ -382,10 +385,9 @@ SubstVarLong(For *f, const char **pp, co
p += varnameLen;
*inout_mark = p;
- break;
+ *pp = p;
+ return;
}
-
- *pp = p;
}
/*