| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: var.c,v 1.636 2020/11/01 18:45:49 rillig Exp $ */ | | 1 | /* $NetBSD: var.c,v 1.637 2020/11/01 18:48:13 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.636 2020/11/01 18:45:49 rillig Exp $"); | | 133 | MAKE_RCSID("$NetBSD: var.c,v 1.637 2020/11/01 18:48:13 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 | */ |
| @@ -2363,27 +2363,28 @@ ApplyModifier_Match(const char **pp, App | | | @@ -2363,27 +2363,28 @@ ApplyModifier_Match(const char **pp, App |
2363 | char *pattern; | | 2363 | char *pattern; |
2364 | ModifyWordsCallback callback; | | 2364 | ModifyWordsCallback callback; |
2365 | | | 2365 | |
2366 | /* | | 2366 | /* |
2367 | * In the loop below, ignore ':' unless we are at (or back to) the | | 2367 | * In the loop below, ignore ':' unless we are at (or back to) the |
2368 | * original brace level. | | 2368 | * original brace level. |
2369 | * XXX This will likely not work right if $() and ${} are intermixed. | | 2369 | * XXX This will likely not work right if $() and ${} are intermixed. |
2370 | */ | | 2370 | */ |
2371 | int nest = 0; | | 2371 | int nest = 0; |
2372 | const char *p; | | 2372 | const char *p; |
2373 | for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) { | | 2373 | for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) { |
2374 | if (*p == '\\' && | | 2374 | if (*p == '\\' && |
2375 | (p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) { | | 2375 | (p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) { |
2376 | copy = TRUE; | | 2376 | if (!needSubst) |
| | | 2377 | copy = TRUE; |
2377 | p++; | | 2378 | p++; |
2378 | continue; | | 2379 | continue; |
2379 | } | | 2380 | } |
2380 | if (*p == '$') | | 2381 | if (*p == '$') |
2381 | needSubst = TRUE; | | 2382 | needSubst = TRUE; |
2382 | if (*p == '(' || *p == '{') | | 2383 | if (*p == '(' || *p == '{') |
2383 | nest++; | | 2384 | nest++; |
2384 | if (*p == ')' || *p == '}') { | | 2385 | if (*p == ')' || *p == '}') { |
2385 | nest--; | | 2386 | nest--; |
2386 | if (nest < 0) | | 2387 | if (nest < 0) |
2387 | break; | | 2388 | break; |
2388 | } | | 2389 | } |
2389 | } | | 2390 | } |