Module Name: src Committed By: rillig Date: Sun Jan 9 18:59:27 UTC 2022
Modified Files: src/usr.bin/make: for.c make.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/usr.bin/make/for.c cvs rdiff -u -r1.287 -r1.288 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/for.c diff -u src/usr.bin/make/for.c:1.164 src/usr.bin/make/for.c:1.165 --- src/usr.bin/make/for.c:1.164 Sun Jan 9 14:06:00 2022 +++ src/usr.bin/make/for.c Sun Jan 9 18:59:27 2022 @@ -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, unsigne 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 != '\\') Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.287 src/usr.bin/make/make.h:1.288 --- src/usr.bin/make/make.h:1.287 Fri Jan 7 20:50:35 2022 +++ src/usr.bin/make/make.h Sun Jan 9 18:59:27 2022 @@ -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) {