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.
This commit is contained in:
parent
d150208ab6
commit
fb272eaa4b
|
@ -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 @@ ForLoop_SubstVarLong(ForLoop *f, unsigned int firstItem, Buffer *body,
|
|||
|
||||
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 != '\\')
|
||||
|
|
|
@ -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 @@ cpp_skip_hspace(const char **pp)
|
|||
(*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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue