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: extract low-level character operations in...
details: https://anonhg.NetBSD.org/src/rev/df92d0df7d53
branches: trunk
changeset: 359563:df92d0df7d53
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 09 18:59:27 2022 +0000
description:
make: extract low-level character operations into utility function
Suggested by nia.
https://mail-index.netbsd.org/source-changes-d/2022/01/09/msg013564.html
No functional change.
diffstat:
usr.bin/make/for.c | 9 +++------
usr.bin/make/make.h | 13 ++++++++++++-
2 files changed, 15 insertions(+), 7 deletions(-)
diffs (58 lines):
diff -r a66c349880e6 -r df92d0df7d53 usr.bin/make/for.c
--- a/usr.bin/make/for.c Sun Jan 09 18:49:28 2022 +0000
+++ b/usr.bin/make/for.c Sun Jan 09 18:59:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.164 2022/01/09 14:06:00 rillig Exp $ */
+/* $NetBSD: for.c,v 1.165 2022/01/09 18:59:27 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.164 2022/01/09 14:06:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.165 2022/01/09 18:59:27 rillig Exp $");
typedef struct ForLoop {
@@ -376,11 +376,8 @@
for (i = 0; i < f->vars.len; i++) {
const char *p = start;
- const char *varname = vars[i];
- while (*varname != '\0' && *p == *varname)
- p++, varname++;
- if (*varname != '\0')
+ if (!cpp_skip_string(&p, vars[i]))
continue;
/* XXX: why test for backslash here? */
if (*p != ':' && *p != endc && *p != '\\')
diff -r a66c349880e6 -r df92d0df7d53 usr.bin/make/make.h
--- a/usr.bin/make/make.h Sun Jan 09 18:49:28 2022 +0000
+++ b/usr.bin/make/make.h Sun Jan 09 18:59:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.287 2022/01/07 20:50:35 rillig Exp $ */
+/* $NetBSD: make.h,v 1.288 2022/01/09 18:59:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -896,6 +896,17 @@
(*pp)++;
}
+MAKE_INLINE bool
+cpp_skip_string(const char **pp, const char *s)
+{
+ const char *p = *pp;
+ while (*p == *s && *s != '\0')
+ p++, s++;
+ if (*s == '\0')
+ *pp = p;
+ return *s == '\0';
+}
+
MAKE_INLINE void
pp_skip_whitespace(char **pp)
{
Home |
Main Index |
Thread Index |
Old Index