Module Name: src Committed By: rillig Date: Thu Sep 3 18:19:15 UTC 2020
Modified Files: src/usr.bin/make: nonints.h var.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/nonints.h cvs rdiff -u -r1.484 -r1.485 src/usr.bin/make/var.c 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/nonints.h diff -u src/usr.bin/make/nonints.h:1.103 src/usr.bin/make/nonints.h:1.104 --- src/usr.bin/make/nonints.h:1.103 Thu Sep 3 16:02:02 2020 +++ src/usr.bin/make/nonints.h Thu Sep 3 18:19:15 2020 @@ -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 @@ void Var_Append(const char *, const char 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); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.484 src/usr.bin/make/var.c:1.485 --- src/usr.bin/make/var.c:1.484 Wed Sep 2 06:25:48 2020 +++ src/usr.bin/make/var.c Thu Sep 3 18:19:15 2020 @@ -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 @@ ParseModifierPart( } 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 @@ Var_Parse(const char * const str, GNode 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