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: clean up AddEscape for building the body ...



details:   https://anonhg.NetBSD.org/src/rev/ef5145aef749
branches:  trunk
changeset: 359848:ef5145aef749
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 27 11:16:44 2022 +0000

description:
make: clean up AddEscape for building the body of a .for loop

Adding 1 + len bytes but only incrementing the pointer by len bytes
looked suspicious, so use the same expression in both places.

No functional change.

diffstat:

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

diffs (60 lines):

diff -r 5f65310cac01 -r ef5145aef749 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Thu Jan 27 11:00:07 2022 +0000
+++ b/usr.bin/make/for.c        Thu Jan 27 11:16:44 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.165 2022/01/09 18:59:27 rillig Exp $ */
+/*     $NetBSD: for.c,v 1.166 2022/01/27 11:16:44 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.165 2022/01/09 18:59:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.166 2022/01/27 11:16:44 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -319,9 +319,8 @@
 
 /*
  * While expanding the body of a .for loop, write the item in the ${:U...}
- * expression, escaping characters as needed.
- *
- * The result is later unescaped by ApplyModifier_Defined.
+ * expression, escaping characters as needed.  The result is later unescaped
+ * by ApplyModifier_Defined.
  */
 static void
 AddEscaped(Buffer *cmds, Substring item, char endc)
@@ -334,11 +333,7 @@
                return;
        }
 
-       /*
-        * Escape ':', '$', '\\' and 'endc' - these will be removed later by
-        * :U processing, see ApplyModifier_Defined.
-        */
-       for (p = item.start; p != item.end; p++) {
+       for (p = item.start; p != item.end;) {
                ch = *p;
                if (ch == '$') {
                        size_t len = ExprLen(p + 1, item.end);
@@ -348,7 +343,7 @@
                                 * See directive-for-escape.mk, ExprLen.
                                 */
                                Buf_AddBytes(cmds, p, 1 + len);
-                               p += len;
+                               p += 1 + len;
                                continue;
                        }
                        Buf_AddByte(cmds, '\\');
@@ -359,6 +354,7 @@
                        ch = ' ';       /* prevent newline injection */
                }
                Buf_AddByte(cmds, ch);
+               p++;
        }
 }
 



Home | Main Index | Thread Index | Old Index