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): add pp_skip_hspace to skip horizontal ...
details: https://anonhg.NetBSD.org/src/rev/ff81cd0de934
branches: trunk
changeset: 1016007:ff81cd0de934
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 07 10:44:53 2020 +0000
description:
make(1): add pp_skip_hspace to skip horizontal whitespace during parsing
diffstat:
usr.bin/make/job.c | 8 +++-----
usr.bin/make/make.h | 9 ++++++++-
usr.bin/make/parse.c | 16 ++++++----------
usr.bin/make/str.c | 9 ++++-----
usr.bin/make/suff.c | 14 ++++++--------
5 files changed, 27 insertions(+), 29 deletions(-)
diffs (181 lines):
diff -r 7e35cfc0ce88 -r ff81cd0de934 usr.bin/make/job.c
--- a/usr.bin/make/job.c Sat Nov 07 10:43:47 2020 +0000
+++ b/usr.bin/make/job.c Sat Nov 07 10:44:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.306 2020/11/07 10:16:18 rillig Exp $ */
+/* $NetBSD: job.c,v 1.307 2020/11/07 10:44:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.306 2020/11/07 10:16:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.307 2020/11/07 10:44:53 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -1703,9 +1703,7 @@
* command....
*/
cp++;
- while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
- cp++;
- }
+ pp_skip_whitespace(&cp);
} else {
return cp;
}
diff -r 7e35cfc0ce88 -r ff81cd0de934 usr.bin/make/make.h
--- a/usr.bin/make/make.h Sat Nov 07 10:43:47 2020 +0000
+++ b/usr.bin/make/make.h Sat Nov 07 10:44:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.196 2020/11/06 22:39:10 rillig Exp $ */
+/* $NetBSD: make.h,v 1.197 2020/11/07 10:44:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -742,6 +742,13 @@
(*pp)++;
}
+static inline MAKE_ATTR_UNUSED void
+pp_skip_hspace(char **pp)
+{
+ while (**pp == ' ' || **pp == '\t')
+ (*pp)++;
+}
+
#ifdef MAKE_NATIVE
# include <sys/cdefs.h>
# ifndef lint
diff -r 7e35cfc0ce88 -r ff81cd0de934 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sat Nov 07 10:43:47 2020 +0000
+++ b/usr.bin/make/parse.c Sat Nov 07 10:44:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.428 2020/11/07 10:16:19 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.429 2020/11/07 10:44:53 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.428 2020/11/07 10:16:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.429 2020/11/07 10:44:53 rillig Exp $");
/* types and constants */
@@ -1834,9 +1834,7 @@
const char *firstSpace = NULL;
int level = 0;
- /* Skip to variable name */
- while (*p == ' ' || *p == '\t')
- p++;
+ cpp_skip_hspace(&p); /* Skip to variable name */
/* During parsing, the '+' of the '+=' operator is initially parsed
* as part of the variable name. It is later corrected, as is the ':sh'
@@ -2246,8 +2244,7 @@
char *file = line + (silent ? 8 : 7);
/* Skip to delimiter character so we know where to look */
- while (*file == ' ' || *file == '\t')
- file++;
+ pp_skip_hspace(&file);
if (*file != '"' && *file != '<') {
Parse_Error(PARSE_FATAL,
@@ -2783,9 +2780,8 @@
continue;
}
- /* Escaped '\n' replace following whitespace with a single ' ' */
- while (ptr[0] == ' ' || ptr[0] == '\t')
- ptr++;
+ /* Escaped '\n' -- replace following whitespace with a single ' '. */
+ pp_skip_hspace(&ptr);
ch = ' ';
}
diff -r 7e35cfc0ce88 -r ff81cd0de934 usr.bin/make/str.c
--- a/usr.bin/make/str.c Sat Nov 07 10:43:47 2020 +0000
+++ b/usr.bin/make/str.c Sat Nov 07 10:44:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.71 2020/11/07 10:16:19 rillig Exp $ */
+/* $NetBSD: str.c,v 1.72 2020/11/07 10:44:53 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
#include "make.h"
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
-MAKE_RCSID("$NetBSD: str.c,v 1.71 2020/11/07 10:16:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.72 2020/11/07 10:44:53 rillig Exp $");
/* Return the concatenation of s1 and s2, freshly allocated. */
char *
@@ -139,9 +139,8 @@
char *word_end;
const char *str_p;
- /* skip leading space chars. */
- for (; *str == ' ' || *str == '\t'; ++str)
- continue;
+ /* XXX: why only hspace, not whitespace? */
+ cpp_skip_hspace(&str); /* skip leading space chars. */
/* words_buf holds the words, separated by '\0'. */
str_len = strlen(str);
diff -r 7e35cfc0ce88 -r ff81cd0de934 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sat Nov 07 10:43:47 2020 +0000
+++ b/usr.bin/make/suff.c Sat Nov 07 10:44:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.231 2020/11/05 17:27:16 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.232 2020/11/07 10:44:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.231 2020/11/05 17:27:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.232 2020/11/07 10:44:53 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -1166,15 +1166,15 @@
/*
* Break the result into a vector of strings whose nodes
* we can find, then add those nodes to the members list.
- * Unfortunately, we can't use brk_string b/c it
+ * Unfortunately, we can't use brk_string because it
* doesn't understand about variable specifications with
* spaces in them...
*/
char *start;
char *initcp = cp; /* For freeing... */
- for (start = cp; *start == ' ' || *start == '\t'; start++)
- continue;
+ start = cp;
+ pp_skip_hspace(&start);
cp = start;
while (*cp != '\0') {
if (*cp == ' ' || *cp == '\t') {
@@ -1185,9 +1185,7 @@
*cp++ = '\0';
gn = Targ_GetNode(start);
Lst_Append(members, gn);
- while (*cp == ' ' || *cp == '\t') {
- cp++;
- }
+ pp_skip_hspace(&cp);
start = cp; /* Continue at the next non-space. */
} else if (*cp == '$') {
/*
Home |
Main Index |
Thread Index |
Old Index