| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cond.c,v 1.345 2023/06/01 07:44:10 rillig Exp $ */ | | 1 | /* $NetBSD: cond.c,v 1.346 2023/06/16 07:12:46 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
5 | * All rights reserved. | | 5 | * 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. |
| @@ -82,27 +82,27 @@ | | | @@ -82,27 +82,27 @@ |
82 | * ':?then:else' variable modifier. | | 82 | * ':?then:else' variable modifier. |
83 | * | | 83 | * |
84 | * Cond_EndFile | | 84 | * Cond_EndFile |
85 | * At the end of reading a makefile, ensure that the | | 85 | * At the end of reading a makefile, ensure that the |
86 | * conditional directives are well-balanced. | | 86 | * conditional directives are well-balanced. |
87 | */ | | 87 | */ |
88 | | | 88 | |
89 | #include <errno.h> | | 89 | #include <errno.h> |
90 | | | 90 | |
91 | #include "make.h" | | 91 | #include "make.h" |
92 | #include "dir.h" | | 92 | #include "dir.h" |
93 | | | 93 | |
94 | /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ | | 94 | /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ |
95 | MAKE_RCSID("$NetBSD: cond.c,v 1.345 2023/06/01 07:44:10 rillig Exp $"); | | 95 | MAKE_RCSID("$NetBSD: cond.c,v 1.346 2023/06/16 07:12:46 rillig Exp $"); |
96 | | | 96 | |
97 | /* | | 97 | /* |
98 | * Conditional expressions conform to this grammar: | | 98 | * Conditional expressions conform to this grammar: |
99 | * Or -> And ('||' And)* | | 99 | * Or -> And ('||' And)* |
100 | * And -> Term ('&&' Term)* | | 100 | * And -> Term ('&&' Term)* |
101 | * Term -> Function '(' Argument ')' | | 101 | * Term -> Function '(' Argument ')' |
102 | * Term -> Leaf Operator Leaf | | 102 | * Term -> Leaf Operator Leaf |
103 | * Term -> Leaf | | 103 | * Term -> Leaf |
104 | * Term -> '(' Or ')' | | 104 | * Term -> '(' Or ')' |
105 | * Term -> '!' Term | | 105 | * Term -> '!' Term |
106 | * Leaf -> "string" | | 106 | * Leaf -> "string" |
107 | * Leaf -> Number | | 107 | * Leaf -> Number |
108 | * Leaf -> VariableExpression | | 108 | * Leaf -> VariableExpression |
| @@ -163,27 +163,27 @@ typedef struct CondParser { | | | @@ -163,27 +163,27 @@ typedef struct CondParser { |
163 | | | 163 | |
164 | const char *p; /* The remaining condition to parse */ | | 164 | const char *p; /* The remaining condition to parse */ |
165 | Token curr; /* Single push-back token used in parsing */ | | 165 | Token curr; /* Single push-back token used in parsing */ |
166 | | | 166 | |
167 | /* | | 167 | /* |
168 | * Whether an error message has already been printed for this | | 168 | * Whether an error message has already been printed for this |
169 | * condition. The first available error message is usually the most | | 169 | * condition. The first available error message is usually the most |
170 | * specific one, therefore it makes sense to suppress the standard | | 170 | * specific one, therefore it makes sense to suppress the standard |
171 | * "Malformed conditional" message. | | 171 | * "Malformed conditional" message. |
172 | */ | | 172 | */ |
173 | bool printedError; | | 173 | bool printedError; |
174 | } CondParser; | | 174 | } CondParser; |
175 | | | 175 | |
176 | static CondResult CondParser_Or(CondParser *par, bool); | | 176 | static CondResult CondParser_Or(CondParser *, bool); |
177 | | | 177 | |
178 | unsigned int cond_depth = 0; /* current .if nesting level */ | | 178 | unsigned int cond_depth = 0; /* current .if nesting level */ |
179 | | | 179 | |
180 | /* Names for ComparisonOp. */ | | 180 | /* Names for ComparisonOp. */ |
181 | static const char opname[][3] = { "<", "<=", ">", ">=", "==", "!=" }; | | 181 | static const char opname[][3] = { "<", "<=", ">", ">=", "==", "!=" }; |
182 | | | 182 | |
183 | MAKE_INLINE bool | | 183 | MAKE_INLINE bool |
184 | skip_string(const char **pp, const char *str) | | 184 | skip_string(const char **pp, const char *str) |
185 | { | | 185 | { |
186 | size_t len = strlen(str); | | 186 | size_t len = strlen(str); |
187 | bool ok = strncmp(*pp, str, len) == 0; | | 187 | bool ok = strncmp(*pp, str, len) == 0; |
188 | if (ok) | | 188 | if (ok) |
189 | *pp += len; | | 189 | *pp += len; |