Module Name: src
Committed By: rillig
Date: Fri Nov 6 22:39:10 UTC 2020
Modified Files:
src/usr.bin/make: cond.c make.h
Log Message:
make(1): merge duplicate code for skipping horizontal whitespace
To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/cond.c
cvs rdiff -u -r1.195 -r1.196 src/usr.bin/make/make.h
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/cond.c
diff -u src/usr.bin/make/cond.c:1.176 src/usr.bin/make/cond.c:1.177
--- src/usr.bin/make/cond.c:1.176 Fri Nov 6 20:50:48 2020
+++ src/usr.bin/make/cond.c Fri Nov 6 22:39:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.176 2020/11/06 20:50:48 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.177 2020/11/06 22:39:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.176 2020/11/06 20:50:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.177 2020/11/06 22:39:10 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -223,9 +223,7 @@ ParseFuncArg(const char **pp, Boolean do
return 0;
}
- while (*p == ' ' || *p == '\t') {
- p++;
- }
+ cpp_skip_hspace(&p);
Buf_Init(&argBuf, 16);
@@ -264,9 +262,7 @@ ParseFuncArg(const char **pp, Boolean do
*out_arg = Buf_GetAll(&argBuf, &argLen);
Buf_Destroy(&argBuf, FALSE);
- while (*p == ' ' || *p == '\t') {
- p++;
- }
+ cpp_skip_hspace(&p);
if (func != NULL && *p++ != ')') {
Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
@@ -811,9 +807,7 @@ CondParser_Token(CondParser *par, Boolea
return t;
}
- while (par->p[0] == ' ' || par->p[0] == '\t') {
- par->p++;
- }
+ cpp_skip_hspace(&par->p);
switch (par->p[0]) {
@@ -1018,8 +1012,7 @@ CondEvalExpression(const struct If *info
lhsStrict = strictLHS;
- while (*cond == ' ' || *cond == '\t')
- cond++;
+ cpp_skip_hspace(&cond);
if (info == NULL && (info = dflt_info) == NULL) {
/* Scan for the entry for .if - it can't be first */
@@ -1094,9 +1087,8 @@ Cond_EvalLine(const char *line)
cond_state = bmake_malloc(max_if_depth * sizeof *cond_state);
cond_state[0] = IF_ACTIVE;
}
- /* skip leading character (the '.') and any whitespace */
- for (line++; *line == ' ' || *line == '\t'; line++)
- continue;
+ line++; /* skip the leading '.' */
+ cpp_skip_hspace(&line);
/* Find what type of if we're dealing with. */
if (line[0] == 'e') {
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.195 src/usr.bin/make/make.h:1.196
--- src/usr.bin/make/make.h:1.195 Fri Nov 6 22:37:07 2020
+++ src/usr.bin/make/make.h Fri Nov 6 22:39:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.195 2020/11/06 22:37:07 rillig Exp $ */
+/* $NetBSD: make.h,v 1.196 2020/11/06 22:39:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -729,6 +729,13 @@ cpp_skip_whitespace(const char **pp)
}
static inline MAKE_ATTR_UNUSED void
+cpp_skip_hspace(const char **pp)
+{
+ while (**pp == ' ' || **pp == '\t')
+ (*pp)++;
+}
+
+static inline MAKE_ATTR_UNUSED void
pp_skip_whitespace(char **pp)
{
while (ch_isspace(**pp))