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: revert part of previous commit



details:   https://anonhg.NetBSD.org/src/rev/ac7440aa972f
branches:  trunk
changeset: 959446:ac7440aa972f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 14 17:27:25 2021 +0000

description:
make: revert part of previous commit

That code was not ready yet.

diffstat:

 usr.bin/make/var.c |  308 +++++++++++++++++++++++-----------------------------
 1 files changed, 136 insertions(+), 172 deletions(-)

diffs (truncated from 1020 to 300 lines):

diff -r f29fff513d41 -r ac7440aa972f usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Feb 14 17:24:47 2021 +0000
+++ b/usr.bin/make/var.c        Sun Feb 14 17:27:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.814 2021/02/14 17:24:47 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.815 2021/02/14 17:27:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.814 2021/02/14 17:24:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.815 2021/02/14 17:27:25 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -2087,30 +2087,25 @@
        VarExprStatus exprStatus;
 } ApplyModifiersState;
 
-/*
- * A variable expression such as $@ or ${VAR:Mpattern:Q}.
- */
-typedef struct Expr {
-       ApplyModifiersState *st;        /* only during ApplyModifiers */
-} Expr;
+typedef ApplyModifiersState Expr;
 
 static void
 Expr_Define(Expr *expr)
 {
-       if (expr->st->exprStatus == VES_UNDEF)
-               expr->st->exprStatus = VES_DEF;
+       if (expr->exprStatus == VES_UNDEF)
+               expr->exprStatus = VES_DEF;
 }
 
 static void
 Expr_SetValueOwn(Expr *expr, char *value)
 {
-       expr->st->newValue = FStr_InitOwn(value);
+       expr->newValue = FStr_InitOwn(value);
 }
 
 static void
 Expr_SetValueRefer(Expr *expr, const char *value)
 {
-       expr->st->newValue = FStr_InitRefer(value);
+       expr->newValue = FStr_InitRefer(value);
 }
 
 typedef enum ApplyModifierResult {
@@ -2145,7 +2140,7 @@
     const char **pp,
     char delim,
     VarEvalFlags eflags,
-    Expr *expr,
+    ApplyModifiersState *st,
     char **out_part,
     /* Optionally stores the length of the returned string, just to save
      * another strlen call. */
@@ -2158,7 +2153,6 @@
     struct ModifyWord_SubstArgs *subst
 )
 {
-       ApplyModifiersState *st = expr->st;
        Buffer buf;
        const char *p;
 
@@ -2287,11 +2281,11 @@
     /* Flags for evaluating nested variables; if VARE_WANTRES is not set,
      * the text is only parsed. */
     VarEvalFlags eflags,
-    Expr *expr,
+    ApplyModifiersState *st,
     char **out_part
 )
 {
-       return ParseModifierPartSubst(pp, delim, eflags, expr, out_part,
+       return ParseModifierPartSubst(pp, delim, eflags, st, out_part,
            NULL, NULL, NULL);
 }
 
@@ -2375,9 +2369,8 @@
 
 /* :@var@...${var}...@ */
 static ApplyModifierResult
-ApplyModifier_Loop(const char **pp, const char *val, Expr *expr)
+ApplyModifier_Loop(const char **pp, const char *val, ApplyModifiersState *st)
 {
-       ApplyModifiersState *st = expr->st;
        struct ModifyWord_LoopArgs args;
        char prev_sep;
        VarParseResult res;
@@ -2385,7 +2378,7 @@
        args.scope = st->scope;
 
        (*pp)++;                /* Skip the first '@' */
-       res = ParseModifierPart(pp, '@', VARE_NONE, expr, &args.tvar);
+       res = ParseModifierPart(pp, '@', VARE_NONE, st, &args.tvar);
        if (res != VPR_OK)
                return AMR_CLEANUP;
        if (opts.strict && strchr(args.tvar, '$') != NULL) {
@@ -2396,14 +2389,14 @@
                return AMR_CLEANUP;
        }
 
-       res = ParseModifierPart(pp, '@', VARE_NONE, expr, &args.str);
+       res = ParseModifierPart(pp, '@', VARE_NONE, st, &args.str);
        if (res != VPR_OK)
                return AMR_CLEANUP;
 
        args.eflags = st->eflags & ~(unsigned)VARE_KEEP_DOLLAR;
        prev_sep = st->sep;
        st->sep = ' ';          /* XXX: should be st->sep for consistency */
-       Expr_SetValueOwn(expr,
+       Expr_SetValueOwn(st,
            ModifyWords(val, ModifyWord_Loop, &args, st->oneBigWord, st->sep));
        st->sep = prev_sep;
        /* XXX: Consider restoring the previous variable instead of deleting. */
@@ -2419,9 +2412,8 @@
 
 /* :Ddefined or :Uundefined */
 static ApplyModifierResult
-ApplyModifier_Defined(const char **pp, const char *val, Expr *expr)
+ApplyModifier_Defined(const char **pp, const char *val, ApplyModifiersState *st)
 {
-       ApplyModifiersState *st = expr->st;
        Buffer buf;
        const char *p;
 
@@ -2466,12 +2458,12 @@
        }
        *pp = p;
 
-       Expr_Define(expr);
+       Expr_Define(st);
 
        if (eflags & VARE_WANTRES) {
-               Expr_SetValueOwn(expr, Buf_DoneData(&buf));
+               Expr_SetValueOwn(st, Buf_DoneData(&buf));
        } else {
-               Expr_SetValueRefer(expr, val);
+               Expr_SetValueRefer(st, val);
                Buf_Done(&buf);
        }
        return AMR_OK;
@@ -2479,10 +2471,10 @@
 
 /* :L */
 static ApplyModifierResult
-ApplyModifier_Literal(const char **pp, Expr *expr)
+ApplyModifier_Literal(const char **pp, ApplyModifiersState *st)
 {
-       Expr_Define(expr);
-       Expr_SetValueOwn(expr, bmake_strdup(expr->st->var->name.str));
+       Expr_Define(st);
+       Expr_SetValueOwn(st, bmake_strdup(st->var->name.str));
        (*pp)++;
        return AMR_OK;
 }
@@ -2508,12 +2500,12 @@
 
 /* :gmtime */
 static ApplyModifierResult
-ApplyModifier_Gmtime(const char **pp, const char *val, Expr *expr)
+ApplyModifier_Gmtime(const char **pp, const char *val, ApplyModifiersState *st)
 {
        time_t utc;
 
        const char *mod = *pp;
-       if (!ModMatchEq(mod, "gmtime", expr->st->endc))
+       if (!ModMatchEq(mod, "gmtime", st->endc))
                return AMR_UNKNOWN;
 
        if (mod[6] == '=') {
@@ -2528,19 +2520,19 @@
                utc = 0;
                *pp = mod + 6;
        }
-       Expr_SetValueOwn(expr, VarStrftime(val, TRUE, utc));
+       Expr_SetValueOwn(st, VarStrftime(val, TRUE, utc));
        return AMR_OK;
 }
 
 /* :localtime */
 static ApplyModifierResult
 ApplyModifier_Localtime(const char **pp, const char *val,
-                       Expr *expr)
+                       ApplyModifiersState *st)
 {
        time_t utc;
 
        const char *mod = *pp;
-       if (!ModMatchEq(mod, "localtime", expr->st->endc))
+       if (!ModMatchEq(mod, "localtime", st->endc))
                return AMR_UNKNOWN;
 
        if (mod[9] == '=') {
@@ -2555,31 +2547,30 @@
                utc = 0;
                *pp = mod + 9;
        }
-       Expr_SetValueOwn(expr, VarStrftime(val, FALSE, utc));
+       Expr_SetValueOwn(st, VarStrftime(val, FALSE, utc));
        return AMR_OK;
 }
 
 /* :hash */
 static ApplyModifierResult
-ApplyModifier_Hash(const char **pp, const char *val, Expr *expr)
+ApplyModifier_Hash(const char **pp, const char *val, ApplyModifiersState *st)
 {
-       if (!ModMatch(*pp, "hash", expr->st->endc))
+       if (!ModMatch(*pp, "hash", st->endc))
                return AMR_UNKNOWN;
 
-       Expr_SetValueOwn(expr, VarHash(val));
+       Expr_SetValueOwn(st, VarHash(val));
        *pp += 4;
        return AMR_OK;
 }
 
 /* :P */
 static ApplyModifierResult
-ApplyModifier_Path(const char **pp, Expr *expr)
+ApplyModifier_Path(const char **pp, ApplyModifiersState *st)
 {
-       ApplyModifiersState *st = expr->st;
        GNode *gn;
        char *path;
 
-       Expr_Define(expr);
+       Expr_Define(st);
 
        gn = Targ_FindNode(st->var->name.str);
        if (gn == NULL || gn->type & OP_NOPATH) {
@@ -2592,7 +2583,7 @@
        }
        if (path == NULL)
                path = bmake_strdup(st->var->name.str);
-       Expr_SetValueOwn(expr, path);
+       Expr_SetValueOwn(st, path);
 
        (*pp)++;
        return AMR_OK;
@@ -2600,28 +2591,27 @@
 
 /* :!cmd! */
 static ApplyModifierResult
-ApplyModifier_ShellCommand(const char **pp, Expr *expr)
+ApplyModifier_ShellCommand(const char **pp, ApplyModifiersState *st)
 {
-       ApplyModifiersState *st = expr->st;
        char *cmd;
        const char *errfmt;
        VarParseResult res;
 
        (*pp)++;
-       res = ParseModifierPart(pp, '!', st->eflags, expr, &cmd);
+       res = ParseModifierPart(pp, '!', st->eflags, st, &cmd);
        if (res != VPR_OK)
                return AMR_CLEANUP;
 
        errfmt = NULL;
        if (st->eflags & VARE_WANTRES)
-               Expr_SetValueOwn(expr, Cmd_Exec(cmd, &errfmt));
+               Expr_SetValueOwn(st, Cmd_Exec(cmd, &errfmt));
        else
-               Expr_SetValueRefer(expr, "");
+               Expr_SetValueRefer(st, "");
        if (errfmt != NULL)
                Error(errfmt, cmd);     /* XXX: why still return AMR_OK? */
        free(cmd);
 
-       Expr_Define(expr);
+       Expr_Define(st);
        return AMR_OK;
 }
 
@@ -2630,9 +2620,8 @@
  * The :range=7 modifier generates an integer sequence from 1 to 7.
  */
 static ApplyModifierResult
-ApplyModifier_Range(const char **pp, const char *val, Expr *expr)
+ApplyModifier_Range(const char **pp, const char *val, ApplyModifiersState *st)
 {
-       ApplyModifiersState *st = expr->st;
        size_t n;
        Buffer buf;
        size_t i;
@@ -2670,15 +2659,14 @@
                Buf_AddInt(&buf, 1 + (int)i);
        }
 
-       Expr_SetValueOwn(expr, Buf_DoneData(&buf));
+       Expr_SetValueOwn(st, Buf_DoneData(&buf));
        return AMR_OK;



Home | Main Index | Thread Index | Old Index