| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $ */ | | 1 | /* $NetBSD: var.c,v 1.865 2021/03/14 16:03:04 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. |
| @@ -130,27 +130,27 @@ | | | @@ -130,27 +130,27 @@ |
130 | #include <regex.h> | | 130 | #include <regex.h> |
131 | #endif | | 131 | #endif |
132 | #include <errno.h> | | 132 | #include <errno.h> |
133 | #include <inttypes.h> | | 133 | #include <inttypes.h> |
134 | #include <limits.h> | | 134 | #include <limits.h> |
135 | #include <time.h> | | 135 | #include <time.h> |
136 | | | 136 | |
137 | #include "make.h" | | 137 | #include "make.h" |
138 | #include "dir.h" | | 138 | #include "dir.h" |
139 | #include "job.h" | | 139 | #include "job.h" |
140 | #include "metachar.h" | | 140 | #include "metachar.h" |
141 | | | 141 | |
142 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ | | 142 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ |
143 | MAKE_RCSID("$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $"); | | 143 | MAKE_RCSID("$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $"); |
144 | | | 144 | |
145 | typedef enum VarFlags { | | 145 | typedef enum VarFlags { |
146 | VFL_NONE = 0, | | 146 | VFL_NONE = 0, |
147 | | | 147 | |
148 | /* | | 148 | /* |
149 | * The variable's value is currently being used by Var_Parse or | | 149 | * The variable's value is currently being used by Var_Parse or |
150 | * Var_Subst. This marker is used to avoid endless recursion. | | 150 | * Var_Subst. This marker is used to avoid endless recursion. |
151 | */ | | 151 | */ |
152 | VFL_IN_USE = 1 << 0, | | 152 | VFL_IN_USE = 1 << 0, |
153 | | | 153 | |
154 | /* | | 154 | /* |
155 | * The variable comes from the environment. | | 155 | * The variable comes from the environment. |
156 | * These variables are not registered in any GNode, therefore they | | 156 | * These variables are not registered in any GNode, therefore they |
| @@ -2298,26 +2298,29 @@ ModMatchEq(const char *mod, const char * | | | @@ -2298,26 +2298,29 @@ ModMatchEq(const char *mod, const char * |
2298 | size_t n = strlen(modname); | | 2298 | size_t n = strlen(modname); |
2299 | return strncmp(mod, modname, n) == 0 && | | 2299 | return strncmp(mod, modname, n) == 0 && |
2300 | (IsDelimiter(mod[n], st) || mod[n] == '='); | | 2300 | (IsDelimiter(mod[n], st) || mod[n] == '='); |
2301 | } | | 2301 | } |
2302 | | | 2302 | |
2303 | static Boolean | | 2303 | static Boolean |
2304 | TryParseIntBase0(const char **pp, int *out_num) | | 2304 | TryParseIntBase0(const char **pp, int *out_num) |
2305 | { | | 2305 | { |
2306 | char *end; | | 2306 | char *end; |
2307 | long n; | | 2307 | long n; |
2308 | | | 2308 | |
2309 | errno = 0; | | 2309 | errno = 0; |
2310 | n = strtol(*pp, &end, 0); | | 2310 | n = strtol(*pp, &end, 0); |
| | | 2311 | |
| | | 2312 | if (end == *pp) |
| | | 2313 | return FALSE; |
2311 | if ((n == LONG_MIN || n == LONG_MAX) && errno == ERANGE) | | 2314 | if ((n == LONG_MIN || n == LONG_MAX) && errno == ERANGE) |
2312 | return FALSE; | | 2315 | return FALSE; |
2313 | if (n < INT_MIN || n > INT_MAX) | | 2316 | if (n < INT_MIN || n > INT_MAX) |
2314 | return FALSE; | | 2317 | return FALSE; |
2315 | | | 2318 | |
2316 | *pp = end; | | 2319 | *pp = end; |
2317 | *out_num = (int)n; | | 2320 | *out_num = (int)n; |
2318 | return TRUE; | | 2321 | return TRUE; |
2319 | } | | 2322 | } |
2320 | | | 2323 | |
2321 | static Boolean | | 2324 | static Boolean |
2322 | TryParseSize(const char **pp, size_t *out_num) | | 2325 | TryParseSize(const char **pp, size_t *out_num) |
2323 | { | | 2326 | { |