| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: var.c,v 1.646 2020/11/02 17:55:26 rillig Exp $ */ | | 1 | /* $NetBSD: var.c,v 1.647 2020/11/02 18:15:12 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | | 4 | * Copyright (c) 1988, 1989, 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Adam de Boor. | | 8 | * Adam de Boor. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -120,27 +120,27 @@ | | | @@ -120,27 +120,27 @@ |
120 | #include <regex.h> | | 120 | #include <regex.h> |
121 | #endif | | 121 | #endif |
122 | #include <errno.h> | | 122 | #include <errno.h> |
123 | #include <inttypes.h> | | 123 | #include <inttypes.h> |
124 | #include <limits.h> | | 124 | #include <limits.h> |
125 | #include <time.h> | | 125 | #include <time.h> |
126 | | | 126 | |
127 | #include "make.h" | | 127 | #include "make.h" |
128 | #include "dir.h" | | 128 | #include "dir.h" |
129 | #include "job.h" | | 129 | #include "job.h" |
130 | #include "metachar.h" | | 130 | #include "metachar.h" |
131 | | | 131 | |
132 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ | | 132 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ |
133 | MAKE_RCSID("$NetBSD: var.c,v 1.646 2020/11/02 17:55:26 rillig Exp $"); | | 133 | MAKE_RCSID("$NetBSD: var.c,v 1.647 2020/11/02 18:15:12 rillig Exp $"); |
134 | | | 134 | |
135 | #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) | | 135 | #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) |
136 | #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) | | 136 | #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) |
137 | #define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) | | 137 | #define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) |
138 | #define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) | | 138 | #define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) |
139 | | | 139 | |
140 | ENUM_FLAGS_RTTI_3(VarEvalFlags, | | 140 | ENUM_FLAGS_RTTI_3(VarEvalFlags, |
141 | VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); | | 141 | VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN); |
142 | | | 142 | |
143 | /* | | 143 | /* |
144 | * This lets us tell if we have replaced the original environ | | 144 | * This lets us tell if we have replaced the original environ |
145 | * (which we cannot free). | | 145 | * (which we cannot free). |
146 | */ | | 146 | */ |
| @@ -3281,27 +3281,27 @@ ApplyModifiersIndirect( | | | @@ -3281,27 +3281,27 @@ ApplyModifiersIndirect( |
3281 | /* | | 3281 | /* |
3282 | * If we have not parsed up to st->endc or ':', we are not | | 3282 | * If we have not parsed up to st->endc or ':', we are not |
3283 | * interested. This means the expression ${VAR:${M_1}${M_2}} | | 3283 | * interested. This means the expression ${VAR:${M_1}${M_2}} |
3284 | * is not accepted, but ${VAR:${M_1}:${M_2}} is. | | 3284 | * is not accepted, but ${VAR:${M_1}:${M_2}} is. |
3285 | */ | | 3285 | */ |
3286 | if (mods[0] != '\0' && *p != '\0' && *p != ':' && *p != st->endc) { | | 3286 | if (mods[0] != '\0' && *p != '\0' && *p != ':' && *p != st->endc) { |
3287 | if (DEBUG(LINT)) | | 3287 | if (DEBUG(LINT)) |
3288 | Parse_Error(PARSE_FATAL, | | 3288 | Parse_Error(PARSE_FATAL, |
3289 | "Missing delimiter ':' after indirect modifier \"%.*s\"", | | 3289 | "Missing delimiter ':' after indirect modifier \"%.*s\"", |
3290 | (int)(p - *inout_p), *inout_p); | | 3290 | (int)(p - *inout_p), *inout_p); |
3291 | | | 3291 | |
3292 | free(mods_freeIt); | | 3292 | free(mods_freeIt); |
3293 | /* XXX: apply_mods doesn't sound like "not interested". */ | | 3293 | /* XXX: apply_mods doesn't sound like "not interested". */ |
3294 | /* XXX: Why is the indirect modifier parsed again by | | 3294 | /* XXX: Why is the indirect modifier parsed once more by |
3295 | * apply_mods? If any, p should be advanced to nested_p. */ | | 3295 | * apply_mods? If any, p should be advanced to nested_p. */ |
3296 | return AMIR_APPLY_MODS; | | 3296 | return AMIR_APPLY_MODS; |
3297 | } | | 3297 | } |
3298 | | | 3298 | |
3299 | VAR_DEBUG3("Indirect modifier \"%s\" from \"%.*s\"\n", | | 3299 | VAR_DEBUG3("Indirect modifier \"%s\" from \"%.*s\"\n", |
3300 | mods, (int)(p - *inout_p), *inout_p); | | 3300 | mods, (int)(p - *inout_p), *inout_p); |
3301 | | | 3301 | |
3302 | if (mods[0] != '\0') { | | 3302 | if (mods[0] != '\0') { |
3303 | const char *rval_pp = mods; | | 3303 | const char *rval_pp = mods; |
3304 | st->val = ApplyModifiers(&rval_pp, st->val, '\0', '\0', st->v, | | 3304 | st->val = ApplyModifiers(&rval_pp, st->val, '\0', '\0', st->v, |
3305 | &st->exprFlags, st->ctxt, st->eflags, | | 3305 | &st->exprFlags, st->ctxt, st->eflags, |
3306 | out_freeIt); | | 3306 | out_freeIt); |
3307 | if (st->val == var_Error | | 3307 | if (st->val == var_Error |