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(1): migrate Var_Parse API to parsing position
details: https://anonhg.NetBSD.org/src/rev/88a8243b7fc9
branches: trunk
changeset: 938179:88a8243b7fc9
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Sep 03 18:19:15 2020 +0000
description:
make(1): migrate Var_Parse API to parsing position
The ApplyModifier functions already use this pattern. For simplicity
and consistency Var_Parse should do the same. This saves a parameter to
be passed.
The migration takes place step by step, just like for the Lst functions
a few days ago.
diffstat:
usr.bin/make/nonints.h | 3 ++-
usr.bin/make/var.c | 30 ++++++++++++++++++++----------
2 files changed, 22 insertions(+), 11 deletions(-)
diffs (83 lines):
diff -r 08b19e0d9f9e -r 88a8243b7fc9 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Thu Sep 03 17:16:01 2020 +0000
+++ b/usr.bin/make/nonints.h Thu Sep 03 18:19:15 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.103 2020/09/03 16:02:02 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.104 2020/09/03 18:19:15 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -214,6 +214,7 @@
Boolean Var_Exists(const char *, GNode *);
const char *Var_Value(const char *, GNode *, char **);
const char *Var_Parse(const char *, GNode *, VarEvalFlags, int *, void **);
+const char *Var_ParsePP(const char **, GNode *, VarEvalFlags, void **);
char *Var_Subst(const char *, GNode *, VarEvalFlags);
void Var_Init(void);
void Var_End(void);
diff -r 08b19e0d9f9e -r 88a8243b7fc9 usr.bin/make/var.c
--- a/usr.bin/make/var.c Thu Sep 03 17:16:01 2020 +0000
+++ b/usr.bin/make/var.c Thu Sep 03 18:19:15 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.484 2020/09/02 06:25:48 rillig Exp $ */
+/* $NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.484 2020/09/02 06:25:48 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.484 2020/09/02 06:25:48 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1679,15 +1679,16 @@
}
if (eflags & VARE_WANTRES) { /* Nested variable, evaluated */
- const char *cp2;
- int len;
- void *freeIt;
+ const char *nested_p = p;
+ const char *nested_val;
+ void *nested_val_freeIt;
VarEvalFlags nested_eflags = eflags & ~(unsigned)VARE_ASSIGN;
- cp2 = Var_Parse(p, ctxt, nested_eflags, &len, &freeIt);
- Buf_AddStr(&buf, cp2);
- free(freeIt);
- p += len;
+ nested_val = Var_ParsePP(&nested_p, ctxt, nested_eflags,
+ &nested_val_freeIt);
+ Buf_AddStr(&buf, nested_val);
+ free(nested_val_freeIt);
+ p += nested_p - p;
continue;
}
@@ -3624,6 +3625,15 @@
return nstr;
}
+const char *
+Var_ParsePP(const char **pp, GNode *ctxt, VarEvalFlags eflags, void **freePtr)
+{
+ int len;
+ const char *val = Var_Parse(*pp, ctxt, eflags, &len, freePtr);
+ *pp += len;
+ return val;
+}
+
/* Substitute for all variables in the given string in the given context.
*
* If eflags & VARE_UNDEFERR, Parse_Error will be called when an undefined
Home |
Main Index |
Thread Index |
Old Index