| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $ */ | | 1 | /* $NetBSD: var.c,v 1.486 2020/09/03 18:53:46 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. |
| @@ -59,34 +59,34 @@ | | | @@ -59,34 +59,34 @@ |
59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
64 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 64 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
65 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 65 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
68 | * SUCH DAMAGE. | | 68 | * SUCH DAMAGE. |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #ifndef MAKE_NATIVE | | 71 | #ifndef MAKE_NATIVE |
72 | static char rcsid[] = "$NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $"; | | 72 | static char rcsid[] = "$NetBSD: var.c,v 1.486 2020/09/03 18:53:46 rillig Exp $"; |
73 | #else | | 73 | #else |
74 | #include <sys/cdefs.h> | | 74 | #include <sys/cdefs.h> |
75 | #ifndef lint | | 75 | #ifndef lint |
76 | #if 0 | | 76 | #if 0 |
77 | static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; | | 77 | static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; |
78 | #else | | 78 | #else |
79 | __RCSID("$NetBSD: var.c,v 1.485 2020/09/03 18:19:15 rillig Exp $"); | | 79 | __RCSID("$NetBSD: var.c,v 1.486 2020/09/03 18:53:46 rillig Exp $"); |
80 | #endif | | 80 | #endif |
81 | #endif /* not lint */ | | 81 | #endif /* not lint */ |
82 | #endif | | 82 | #endif |
83 | | | 83 | |
84 | /*- | | 84 | /*- |
85 | * var.c -- | | 85 | * var.c -- |
86 | * Variable-handling functions | | 86 | * Variable-handling functions |
87 | * | | 87 | * |
88 | * Interface: | | 88 | * Interface: |
89 | * Var_Set Set the value of a variable in the given | | 89 | * Var_Set Set the value of a variable in the given |
90 | * context. The variable is created if it doesn't | | 90 | * context. The variable is created if it doesn't |
91 | * yet exist. | | 91 | * yet exist. |
92 | * | | 92 | * |
| @@ -2019,34 +2019,32 @@ ApplyModifier_Defined(const char **pp, A | | | @@ -2019,34 +2019,32 @@ ApplyModifier_Defined(const char **pp, A |
2019 | | | 2019 | |
2020 | /* Escaped delimiter or other special character */ | | 2020 | /* Escaped delimiter or other special character */ |
2021 | if (*p == '\\') { | | 2021 | if (*p == '\\') { |
2022 | char c = p[1]; | | 2022 | char c = p[1]; |
2023 | if (c == st->endc || c == ':' || c == '$' || c == '\\') { | | 2023 | if (c == st->endc || c == ':' || c == '$' || c == '\\') { |
2024 | Buf_AddByte(&buf, c); | | 2024 | Buf_AddByte(&buf, c); |
2025 | p += 2; | | 2025 | p += 2; |
2026 | continue; | | 2026 | continue; |
2027 | } | | 2027 | } |
2028 | } | | 2028 | } |
2029 | | | 2029 | |
2030 | /* Nested variable expression */ | | 2030 | /* Nested variable expression */ |
2031 | if (*p == '$') { | | 2031 | if (*p == '$') { |
2032 | const char *cp2; | | 2032 | const char *nested_val; |
2033 | int len; | | 2033 | void *nested_val_freeIt; |
2034 | void *freeIt; | | | |
2035 | | | 2034 | |
2036 | cp2 = Var_Parse(p, st->ctxt, eflags, &len, &freeIt); | | 2035 | nested_val = Var_ParsePP(&p, st->ctxt, eflags, &nested_val_freeIt); |
2037 | Buf_AddStr(&buf, cp2); | | 2036 | Buf_AddStr(&buf, nested_val); |
2038 | free(freeIt); | | 2037 | free(nested_val_freeIt); |
2039 | p += len; | | | |
2040 | continue; | | 2038 | continue; |
2041 | } | | 2039 | } |
2042 | | | 2040 | |
2043 | /* Ordinary text */ | | 2041 | /* Ordinary text */ |
2044 | Buf_AddByte(&buf, *p); | | 2042 | Buf_AddByte(&buf, *p); |
2045 | p++; | | 2043 | p++; |
2046 | } | | 2044 | } |
2047 | *pp = p; | | 2045 | *pp = p; |
2048 | | | 2046 | |
2049 | if (st->v->flags & VAR_JUNK) | | 2047 | if (st->v->flags & VAR_JUNK) |
2050 | st->v->flags |= VAR_KEEP; | | 2048 | st->v->flags |= VAR_KEEP; |
2051 | if (eflags & VARE_WANTRES) { | | 2049 | if (eflags & VARE_WANTRES) { |
2052 | st->newVal = Buf_Destroy(&buf, FALSE); | | 2050 | st->newVal = Buf_Destroy(&buf, FALSE); |