diff options
| author | rillig <rillig@NetBSD.org> | 2022-01-27 11:16:44 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2022-01-27 11:16:44 +0000 |
| commit | 25f769b6121cb4e3d41b314aecef9ef3ed3419a6 (patch) | |
| tree | fc5976849c79e8a23328a0fd853312e1e4c905fd /usr.bin/make | |
| parent | e029c5fdb340bba397c6c0baa1c9ea10949b27be (diff) | |
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 (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/for.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index 6bf710ca39f..f9d6850a8d8 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -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 @@ NeedsEscapes(Substring value, char endc) /* * 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 @@ AddEscaped(Buffer *cmds, Substring item, char endc) 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 @@ AddEscaped(Buffer *cmds, Substring item, char endc) * 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 @@ AddEscaped(Buffer *cmds, Substring item, char endc) ch = ' '; /* prevent newline injection */ } Buf_AddByte(cmds, ch); + p++; } } |
