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): fix variable names in UnescapeBackslash
details: https://anonhg.NetBSD.org/src/rev/d26fadf01bc7
branches: trunk
changeset: 947594:d26fadf01bc7
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 19 10:18:46 2020 +0000
description:
make(1): fix variable names in UnescapeBackslash
The previous variable names had been chosen at a time when compilers
didn't merge variables into the same registers. Luckily, these times
are gone, and it's no longer necessary to use a variable for 2 or more
completely unrelated purposes.
diffstat:
usr.bin/make/parse.c | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diffs (110 lines):
diff -r 926ed01827e3 -r d26fadf01bc7 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sat Dec 19 09:02:32 2020 +0000
+++ b/usr.bin/make/parse.c Sat Dec 19 10:18:46 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.490 2020/12/19 00:27:34 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.491 2020/12/19 10:18:46 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.490 2020/12/19 00:27:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.491 2020/12/19 10:18:46 rillig Exp $");
/* types and constants */
@@ -2731,44 +2731,48 @@
return TRUE;
}
+/*
+ * Beginning at start, unescape '\#' to '#' and replace backslash-newline
+ * with a single space.
+ */
static void
-UnescapeBackslash(char *escaped, char *const line)
+UnescapeBackslash(char *const line, char *start)
{
- char *tp, *ptr;
-
- tp = ptr = escaped;
- escaped = line;
+ char *src = start;
+ char *dst = start;
+ char *spaceStart = line;
+
for (;;) {
- char ch = *ptr++;
+ char ch = *src++;
if (ch != '\\') {
if (ch == '\0')
break;
- *tp++ = ch;
+ *dst++ = ch;
continue;
}
- ch = *ptr++;
+ ch = *src++;
if (ch == '\0') {
/* Delete '\\' at end of buffer */
- tp--;
+ dst--;
break;
}
/* Delete '\\' from before '#' on non-command lines */
if (ch == '#' && line[0] != '\t') {
- *tp++ = ch;
+ *dst++ = ch;
continue;
}
if (ch != '\n') {
/* Leave '\\' in buffer for later */
- *tp++ = '\\';
+ *dst++ = '\\';
/*
* Make sure we don't delete an escaped ' ' from the
* line end.
*/
- escaped = tp + 1;
- *tp++ = ch;
+ spaceStart = dst + 1;
+ *dst++ = ch;
continue;
}
@@ -2776,15 +2780,14 @@
* Escaped '\n' -- replace following whitespace with a single
* ' '.
*/
- pp_skip_hspace(&ptr);
- ch = ' ';
- *tp++ = ch;
+ pp_skip_hspace(&src);
+ *dst++ = ' ';
}
/* Delete any trailing spaces - eg from empty continuations */
- while (tp > escaped && ch_isspace(tp[-1]))
- tp--;
- *tp = '\0';
+ while (dst > spaceStart && ch_isspace(dst[-1]))
+ dst--;
+ *dst = '\0';
}
typedef enum GetLineMode {
@@ -2848,7 +2851,7 @@
return line;
/* Remove escapes from '\n' and '#' */
- UnescapeBackslash(escaped, line);
+ UnescapeBackslash(line, escaped);
return line;
}
Home |
Main Index |
Thread Index |
Old Index