| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig Exp $ */ | | 1 | /* $NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 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. |
| @@ -60,34 +60,34 @@ | | | @@ -60,34 +60,34 @@ |
60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
69 | * SUCH DAMAGE. | | 69 | * SUCH DAMAGE. |
70 | */ | | 70 | */ |
71 | | | 71 | |
72 | #ifndef MAKE_NATIVE | | 72 | #ifndef MAKE_NATIVE |
73 | static char rcsid[] = "$NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig Exp $"; | | 73 | static char rcsid[] = "$NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $"; |
74 | #else | | 74 | #else |
75 | #include <sys/cdefs.h> | | 75 | #include <sys/cdefs.h> |
76 | #ifndef lint | | 76 | #ifndef lint |
77 | #if 0 | | 77 | #if 0 |
78 | static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; | | 78 | static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; |
79 | #else | | 79 | #else |
80 | __RCSID("$NetBSD: dir.c,v 1.134 2020/09/02 04:19:52 rillig Exp $"); | | 80 | __RCSID("$NetBSD: dir.c,v 1.135 2020/09/02 04:32:13 rillig Exp $"); |
81 | #endif | | 81 | #endif |
82 | #endif /* not lint */ | | 82 | #endif /* not lint */ |
83 | #endif | | 83 | #endif |
84 | | | 84 | |
85 | /*- | | 85 | /*- |
86 | * dir.c -- | | 86 | * dir.c -- |
87 | * Directory searching using wildcards and/or normal names... | | 87 | * Directory searching using wildcards and/or normal names... |
88 | * Used both for source wildcarding in the Makefile and for finding | | 88 | * Used both for source wildcarding in the Makefile and for finding |
89 | * implicit sources. | | 89 | * implicit sources. |
90 | * | | 90 | * |
91 | * The interface for this module is: | | 91 | * The interface for this module is: |
92 | * Dir_Init Initialize the module. | | 92 | * Dir_Init Initialize the module. |
93 | * | | 93 | * |
| @@ -305,32 +305,32 @@ cached_stats(Hash_Table *htp, const char | | | @@ -305,32 +305,32 @@ cached_stats(Hash_Table *htp, const char |
305 | if (mst->mst_mtime) { | | 305 | if (mst->mst_mtime) { |
306 | DIR_DEBUG2("Using cached time %s for %s\n", | | 306 | DIR_DEBUG2("Using cached time %s for %s\n", |
307 | Targ_FmtTime(mst->mst_mtime), pathname); | | 307 | Targ_FmtTime(mst->mst_mtime), pathname); |
308 | return 0; | | 308 | return 0; |
309 | } | | 309 | } |
310 | } | | 310 | } |
311 | | | 311 | |
312 | rc = (flags & CST_LSTAT) | | 312 | rc = (flags & CST_LSTAT) |
313 | ? lstat(pathname, &sys_st) | | 313 | ? lstat(pathname, &sys_st) |
314 | : stat(pathname, &sys_st); | | 314 | : stat(pathname, &sys_st); |
315 | if (rc == -1) | | 315 | if (rc == -1) |
316 | return -1; | | 316 | return -1; |
317 | | | 317 | |
318 | mst->mst_mode = sys_st.st_mode; | | | |
319 | mst->mst_mtime = sys_st.st_mtime; | | | |
320 | | | | |
321 | if (sys_st.st_mtime == 0) | | 318 | if (sys_st.st_mtime == 0) |
322 | sys_st.st_mtime = 1; /* avoid confusion with missing file */ | | 319 | sys_st.st_mtime = 1; /* avoid confusion with missing file */ |
323 | | | 320 | |
| | | 321 | mst->mst_mode = sys_st.st_mode; |
| | | 322 | mst->mst_mtime = sys_st.st_mtime; |
| | | 323 | |
324 | if (entry == NULL) | | 324 | if (entry == NULL) |
325 | entry = Hash_CreateEntry(htp, pathname, NULL); | | 325 | entry = Hash_CreateEntry(htp, pathname, NULL); |
326 | if (Hash_GetValue(entry) == NULL) { | | 326 | if (Hash_GetValue(entry) == NULL) { |
327 | Hash_SetValue(entry, bmake_malloc(sizeof(*cst))); | | 327 | Hash_SetValue(entry, bmake_malloc(sizeof(*cst))); |
328 | memset(Hash_GetValue(entry), 0, sizeof(*cst)); | | 328 | memset(Hash_GetValue(entry), 0, sizeof(*cst)); |
329 | } | | 329 | } |
330 | cst = Hash_GetValue(entry); | | 330 | cst = Hash_GetValue(entry); |
331 | if (flags & CST_LSTAT) { | | 331 | if (flags & CST_LSTAT) { |
332 | cst->lmtime = sys_st.st_mtime; | | 332 | cst->lmtime = sys_st.st_mtime; |
333 | } else { | | 333 | } else { |
334 | cst->mtime = sys_st.st_mtime; | | 334 | cst->mtime = sys_st.st_mtime; |
335 | } | | 335 | } |
336 | cst->mode = sys_st.st_mode; | | 336 | cst->mode = sys_st.st_mode; |