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 duplicate code for parsing ':S' a...
details: https://anonhg.NetBSD.org/src/rev/702e4e933692
branches: trunk
changeset: 953619:702e4e933692
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 14 15:15:28 2021 +0000
description:
make: extract duplicate code for parsing ':S' and ':C'
No functional change.
diffstat:
usr.bin/make/var.c | 41 +++++++++++++++++++----------------------
1 files changed, 19 insertions(+), 22 deletions(-)
diffs (76 lines):
diff -r c69bae507b3d -r 702e4e933692 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Mar 14 15:06:19 2021 +0000
+++ b/usr.bin/make/var.c Sun Mar 14 15:15:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $ */
+/* $NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $");
typedef enum VarFlags {
VFL_NONE = 0,
@@ -2794,6 +2794,21 @@
return AMR_OK;
}
+static void
+ParsePatternFlags(const char **pp, VarPatternFlags *pflags, Boolean *oneBigWord)
+{
+ for (;; (*pp)++) {
+ if (**pp == 'g')
+ pflags->subGlobal = TRUE;
+ else if (**pp == '1')
+ pflags->subOnce = TRUE;
+ else if (**pp == 'W')
+ *oneBigWord = TRUE;
+ else
+ break;
+ }
+}
+
/* :S,from,to, */
static ApplyModifierResult
ApplyModifier_Subst(const char **pp, ApplyModifiersState *st)
@@ -2833,16 +2848,7 @@
args.rhs = rhs;
oneBigWord = st->oneBigWord;
- for (;; (*pp)++) {
- if (**pp == 'g')
- args.pflags.subGlobal = TRUE;
- else if (**pp == '1')
- args.pflags.subOnce = TRUE;
- else if (**pp == 'W')
- oneBigWord = TRUE;
- else
- break;
- }
+ ParsePatternFlags(pp, &args.pflags, &oneBigWord);
ModifyWords(st, ModifyWord_Subst, &args, oneBigWord);
@@ -2885,16 +2891,7 @@
args.pflags = (VarPatternFlags){ FALSE, FALSE, FALSE, FALSE };
args.matched = FALSE;
oneBigWord = st->oneBigWord;
- for (;; (*pp)++) {
- if (**pp == 'g')
- args.pflags.subGlobal = TRUE;
- else if (**pp == '1')
- args.pflags.subOnce = TRUE;
- else if (**pp == 'W')
- oneBigWord = TRUE;
- else
- break;
- }
+ ParsePatternFlags(pp, &args.pflags, &oneBigWord);
if (!(st->expr->eflags & VARE_WANTRES)) {
free(args.replace);
Home |
Main Index |
Thread Index |
Old Index