Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): make control flow in SubstVarLong of ....



details:   https://anonhg.NetBSD.org/src/rev/488217ae9854
branches:  trunk
changeset: 979527:488217ae9854
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 31 13:56:56 2020 +0000

description:
make(1): make control flow in SubstVarLong of .for loops more obvious

diffstat:

 usr.bin/make/for.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r 418c3075406b -r 488217ae9854 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Thu Dec 31 13:37:33 2020 +0000
+++ b/usr.bin/make/for.c        Thu Dec 31 13:56:56 2020 +0000
@@ -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 @@
 }
 
 /*
- * 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 @@
                    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 @@
 
                p += varnameLen;
                *inout_mark = p;
-               break;
+               *pp = p;
+               return;
        }
-
-       *pp = p;
 }
 
 /*



Home | Main Index | Thread Index | Old Index