Module Name: src Committed By: rillig Date: Sat Dec 19 10:18:46 UTC 2020
Modified Files: src/usr.bin/make: parse.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.490 -r1.491 src/usr.bin/make/parse.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/parse.c diff -u src/usr.bin/make/parse.c:1.490 src/usr.bin/make/parse.c:1.491 --- src/usr.bin/make/parse.c:1.490 Sat Dec 19 00:27:34 2020 +++ src/usr.bin/make/parse.c Sat Dec 19 10:18:46 2020 @@ -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 @@ ParseRawLine(char **out_line, char **out 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; + char *src = start; + char *dst = start; + char *spaceStart = line; - tp = ptr = escaped; - escaped = 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 @@ UnescapeBackslash(char *escaped, char *c * 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 @@ ParseGetLine(GetLineMode mode) return line; /* Remove escapes from '\n' and '#' */ - UnescapeBackslash(escaped, line); + UnescapeBackslash(line, escaped); return line; }