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: update line numbers in expected test output



details:   https://anonhg.NetBSD.org/src/rev/e8a6a219db42
branches:  trunk
changeset: 1018704:e8a6a219db42
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 14 17:24:47 2021 +0000

description:
make: update line numbers in expected test output

The documentation from the previous commit added a few lines.

diffstat:

 usr.bin/make/unit-tests/varmod-indirect.exp |   36 +-
 usr.bin/make/var.c                          |  308 +++++++++++++++------------
 2 files changed, 190 insertions(+), 154 deletions(-)

diffs (truncated from 1091 to 300 lines):

diff -r 961bbc11d4f9 -r e8a6a219db42 usr.bin/make/unit-tests/varmod-indirect.exp
--- a/usr.bin/make/unit-tests/varmod-indirect.exp       Sun Feb 14 17:22:37 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-indirect.exp       Sun Feb 14 17:24:47 2021 +0000
@@ -1,20 +1,20 @@
-make: "varmod-indirect.mk" line 17: Unknown modifier '$'
-make: "varmod-indirect.mk" line 50: Unknown modifier '$'
-make: "varmod-indirect.mk" line 53: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
-make: "varmod-indirect.mk" line 138: before
-make: "varmod-indirect.mk" line 138: after
-make: "varmod-indirect.mk" line 144: before
-make: "varmod-indirect.mk" line 144: after
-make: "varmod-indirect.mk" line 150: before
-make: "varmod-indirect.mk" line 150: after
-make: "varmod-indirect.mk" line 154: Unknown modifier 'Z'
-make: "varmod-indirect.mk" line 155: before
-make: "varmod-indirect.mk" line 155: after
-ParseReadLine (164): '_:=      before ${UNDEF} after'
+make: "varmod-indirect.mk" line 19: Unknown modifier '$'
+make: "varmod-indirect.mk" line 52: Unknown modifier '$'
+make: "varmod-indirect.mk" line 55: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
+make: "varmod-indirect.mk" line 140: before
+make: "varmod-indirect.mk" line 140: after
+make: "varmod-indirect.mk" line 146: before
+make: "varmod-indirect.mk" line 146: after
+make: "varmod-indirect.mk" line 152: before
+make: "varmod-indirect.mk" line 152: after
+make: "varmod-indirect.mk" line 156: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 157: before
+make: "varmod-indirect.mk" line 157: after
+ParseReadLine (166): '_:=      before ${UNDEF} after'
 Global:_ = 
 Var_Parse: ${UNDEF} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Global:_ = before ${UNDEF} after
-ParseReadLine (167): '_:=      before ${UNDEF:${:US,a,a,}} after'
+ParseReadLine (169): '_:=      before ${UNDEF:${:US,a,a,}} after'
 Var_Parse: ${UNDEF:${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:US,a,a,}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
@@ -29,7 +29,7 @@
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:US,a,a,} is "S,a,a," (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Global:_ = before ${UNDEF:S,a,a,} after
-ParseReadLine (177): '_:=      before ${UNDEF:${:U}} after'
+ParseReadLine (179): '_:=      before ${UNDEF:${:U}} after'
 Var_Parse: ${UNDEF:${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:U}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
@@ -39,20 +39,20 @@
 Applying ${:U} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:U} is "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Global:_ = before ${UNDEF:} after
-ParseReadLine (182): '_:=      before ${UNDEF:${:UZ}} after'
+ParseReadLine (184): '_:=      before ${UNDEF:${:UZ}} after'
 Var_Parse: ${UNDEF:${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Indirect modifier "Z" from "${:UZ}"
 Applying ${UNDEF:Z} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
-make: "varmod-indirect.mk" line 182: Unknown modifier 'Z'
+make: "varmod-indirect.mk" line 184: Unknown modifier 'Z'
 Result of ${UNDEF:Z} is error (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Var_Parse: ${:UZ}} after with VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF
 Applying ${:U...} to "" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_UNDEF)
 Result of ${:UZ} is "Z" (VARE_WANTRES|VARE_KEEP_DOLLAR|VARE_KEEP_UNDEF, none, VES_DEF)
 Global:_ = before ${UNDEF:Z} after
-ParseReadLine (184): '.MAKEFLAGS: -d0'
+ParseReadLine (186): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
 Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global:.MAKEFLAGS =  -r -k -d 0 -d pv -d 0
diff -r 961bbc11d4f9 -r e8a6a219db42 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Feb 14 17:22:37 2021 +0000
+++ b/usr.bin/make/var.c        Sun Feb 14 17:24:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.813 2021/02/14 13:53:28 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.814 2021/02/14 17:24:47 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.813 2021/02/14 13:53:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.814 2021/02/14 17:24:47 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -2087,25 +2087,30 @@
        VarExprStatus exprStatus;
 } ApplyModifiersState;
 
-typedef ApplyModifiersState Expr;
+/*
+ * A variable expression such as $@ or ${VAR:Mpattern:Q}.
+ */
+typedef struct Expr {
+       ApplyModifiersState *st;        /* only during ApplyModifiers */
+} Expr;
 
 static void
 Expr_Define(Expr *expr)
 {
-       if (expr->exprStatus == VES_UNDEF)
-               expr->exprStatus = VES_DEF;
+       if (expr->st->exprStatus == VES_UNDEF)
+               expr->st->exprStatus = VES_DEF;
 }
 
 static void
 Expr_SetValueOwn(Expr *expr, char *value)
 {
-       expr->newValue = FStr_InitOwn(value);
+       expr->st->newValue = FStr_InitOwn(value);
 }
 
 static void
 Expr_SetValueRefer(Expr *expr, const char *value)
 {
-       expr->newValue = FStr_InitRefer(value);
+       expr->st->newValue = FStr_InitRefer(value);
 }
 
 typedef enum ApplyModifierResult {
@@ -2140,7 +2145,7 @@
     const char **pp,
     char delim,
     VarEvalFlags eflags,
-    ApplyModifiersState *st,
+    Expr *expr,
     char **out_part,
     /* Optionally stores the length of the returned string, just to save
      * another strlen call. */
@@ -2153,6 +2158,7 @@
     struct ModifyWord_SubstArgs *subst
 )
 {
+       ApplyModifiersState *st = expr->st;
        Buffer buf;
        const char *p;
 
@@ -2281,11 +2287,11 @@
     /* Flags for evaluating nested variables; if VARE_WANTRES is not set,
      * the text is only parsed. */
     VarEvalFlags eflags,
-    ApplyModifiersState *st,
+    Expr *expr,
     char **out_part
 )
 {
-       return ParseModifierPartSubst(pp, delim, eflags, st, out_part,
+       return ParseModifierPartSubst(pp, delim, eflags, expr, out_part,
            NULL, NULL, NULL);
 }
 
@@ -2369,8 +2375,9 @@
 
 /* :@var@...${var}...@ */
 static ApplyModifierResult
-ApplyModifier_Loop(const char **pp, const char *val, ApplyModifiersState *st)
+ApplyModifier_Loop(const char **pp, const char *val, Expr *expr)
 {
+       ApplyModifiersState *st = expr->st;
        struct ModifyWord_LoopArgs args;
        char prev_sep;
        VarParseResult res;
@@ -2378,7 +2385,7 @@
        args.scope = st->scope;
 
        (*pp)++;                /* Skip the first '@' */
-       res = ParseModifierPart(pp, '@', VARE_NONE, st, &args.tvar);
+       res = ParseModifierPart(pp, '@', VARE_NONE, expr, &args.tvar);
        if (res != VPR_OK)
                return AMR_CLEANUP;
        if (opts.strict && strchr(args.tvar, '$') != NULL) {
@@ -2389,14 +2396,14 @@
                return AMR_CLEANUP;
        }
 
-       res = ParseModifierPart(pp, '@', VARE_NONE, st, &args.str);
+       res = ParseModifierPart(pp, '@', VARE_NONE, expr, &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(st,
+       Expr_SetValueOwn(expr,
            ModifyWords(val, ModifyWord_Loop, &args, st->oneBigWord, st->sep));
        st->sep = prev_sep;
        /* XXX: Consider restoring the previous variable instead of deleting. */
@@ -2412,8 +2419,9 @@
 
 /* :Ddefined or :Uundefined */
 static ApplyModifierResult
-ApplyModifier_Defined(const char **pp, const char *val, ApplyModifiersState *st)
+ApplyModifier_Defined(const char **pp, const char *val, Expr *expr)
 {
+       ApplyModifiersState *st = expr->st;
        Buffer buf;
        const char *p;
 
@@ -2458,12 +2466,12 @@
        }
        *pp = p;
 
-       Expr_Define(st);
+       Expr_Define(expr);
 
        if (eflags & VARE_WANTRES) {
-               Expr_SetValueOwn(st, Buf_DoneData(&buf));
+               Expr_SetValueOwn(expr, Buf_DoneData(&buf));
        } else {
-               Expr_SetValueRefer(st, val);
+               Expr_SetValueRefer(expr, val);
                Buf_Done(&buf);
        }
        return AMR_OK;
@@ -2471,10 +2479,10 @@
 
 /* :L */
 static ApplyModifierResult
-ApplyModifier_Literal(const char **pp, ApplyModifiersState *st)
+ApplyModifier_Literal(const char **pp, Expr *expr)
 {
-       Expr_Define(st);
-       Expr_SetValueOwn(st, bmake_strdup(st->var->name.str));
+       Expr_Define(expr);
+       Expr_SetValueOwn(expr, bmake_strdup(expr->st->var->name.str));
        (*pp)++;
        return AMR_OK;
 }
@@ -2500,12 +2508,12 @@
 
 /* :gmtime */
 static ApplyModifierResult
-ApplyModifier_Gmtime(const char **pp, const char *val, ApplyModifiersState *st)
+ApplyModifier_Gmtime(const char **pp, const char *val, Expr *expr)
 {
        time_t utc;
 
        const char *mod = *pp;
-       if (!ModMatchEq(mod, "gmtime", st->endc))
+       if (!ModMatchEq(mod, "gmtime", expr->st->endc))
                return AMR_UNKNOWN;
 
        if (mod[6] == '=') {
@@ -2520,19 +2528,19 @@
                utc = 0;
                *pp = mod + 6;
        }
-       Expr_SetValueOwn(st, VarStrftime(val, TRUE, utc));
+       Expr_SetValueOwn(expr, VarStrftime(val, TRUE, utc));
        return AMR_OK;
 }
 
 /* :localtime */
 static ApplyModifierResult
 ApplyModifier_Localtime(const char **pp, const char *val,
-                       ApplyModifiersState *st)
+                       Expr *expr)
 {
        time_t utc;
 
        const char *mod = *pp;
-       if (!ModMatchEq(mod, "localtime", st->endc))
+       if (!ModMatchEq(mod, "localtime", expr->st->endc))
                return AMR_UNKNOWN;
 
        if (mod[9] == '=') {
@@ -2547,30 +2555,31 @@
                utc = 0;
                *pp = mod + 9;
        }
-       Expr_SetValueOwn(st, VarStrftime(val, FALSE, utc));
+       Expr_SetValueOwn(expr, VarStrftime(val, FALSE, utc));
        return AMR_OK;
 }
 
 /* :hash */
 static ApplyModifierResult
-ApplyModifier_Hash(const char **pp, const char *val, ApplyModifiersState *st)
+ApplyModifier_Hash(const char **pp, const char *val, Expr *expr)
 {
-       if (!ModMatch(*pp, "hash", st->endc))
+       if (!ModMatch(*pp, "hash", expr->st->endc))
                return AMR_UNKNOWN;
 
-       Expr_SetValueOwn(st, VarHash(val));
+       Expr_SetValueOwn(expr, VarHash(val));
        *pp += 4;
        return AMR_OK;
 }
 
 /* :P */
 static ApplyModifierResult
-ApplyModifier_Path(const char **pp, ApplyModifiersState *st)
+ApplyModifier_Path(const char **pp, Expr *expr)



Home | Main Index | Thread Index | Old Index