make(1): migrate Lst_First to Lst_FirstSdiff -r1.115 -r1.116 src/usr.bin/make/dir.c
(rillig)
--- src/usr.bin/make/dir.c 2020/08/27 19:15:35 1.115
+++ src/usr.bin/make/dir.c 2020/08/28 04:14:31 1.116
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dir.c,v 1.115 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: dir.c,v 1.116 2020/08/28 04:14:31 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.115 2020/08/27 19:15:35 rillig Exp $"; | 73 | static char rcsid[] = "$NetBSD: dir.c,v 1.116 2020/08/28 04:14:31 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.115 2020/08/27 19:15:35 rillig Exp $"); | 80 | __RCSID("$NetBSD: dir.c,v 1.116 2020/08/28 04:14:31 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 | * | |
@@ -473,27 +473,27 @@ Dir_End(void) | @@ -473,27 +473,27 @@ Dir_End(void) | |||
473 | * search, so we rebuild it after any .PATH: target. | 473 | * search, so we rebuild it after any .PATH: target. | |
474 | * This is the simplest way to deal with the effect of .DOTLAST. | 474 | * This is the simplest way to deal with the effect of .DOTLAST. | |
475 | */ | 475 | */ | |
476 | void | 476 | void | |
477 | Dir_SetPATH(void) | 477 | Dir_SetPATH(void) | |
478 | { | 478 | { | |
479 | LstNode ln; /* a list element */ | 479 | LstNode ln; /* a list element */ | |
480 | Path *p; | 480 | Path *p; | |
481 | Boolean hasLastDot = FALSE; /* true if we should search dot last */ | 481 | Boolean hasLastDot = FALSE; /* true if we should search dot last */ | |
482 | 482 | |||
483 | Var_Delete(".PATH", VAR_GLOBAL); | 483 | Var_Delete(".PATH", VAR_GLOBAL); | |
484 | 484 | |||
485 | Lst_OpenS(dirSearchPath); | 485 | Lst_OpenS(dirSearchPath); | |
486 | if ((ln = Lst_First(dirSearchPath)) != NULL) { | 486 | if ((ln = Lst_FirstS(dirSearchPath)) != NULL) { | |
487 | p = Lst_DatumS(ln); | 487 | p = Lst_DatumS(ln); | |
488 | if (p == dotLast) { | 488 | if (p == dotLast) { | |
489 | hasLastDot = TRUE; | 489 | hasLastDot = TRUE; | |
490 | Var_Append(".PATH", dotLast->name, VAR_GLOBAL); | 490 | Var_Append(".PATH", dotLast->name, VAR_GLOBAL); | |
491 | } | 491 | } | |
492 | } | 492 | } | |
493 | 493 | |||
494 | if (!hasLastDot) { | 494 | if (!hasLastDot) { | |
495 | if (dot) | 495 | if (dot) | |
496 | Var_Append(".PATH", dot->name, VAR_GLOBAL); | 496 | Var_Append(".PATH", dot->name, VAR_GLOBAL); | |
497 | if (cur) | 497 | if (cur) | |
498 | Var_Append(".PATH", cur->name, VAR_GLOBAL); | 498 | Var_Append(".PATH", cur->name, VAR_GLOBAL); | |
499 | } | 499 | } | |
@@ -1127,27 +1127,27 @@ Dir_FindFile(const char *name, Lst path) | @@ -1127,27 +1127,27 @@ Dir_FindFile(const char *name, Lst path) | |||
1127 | hasSlash = FALSE; | 1127 | hasSlash = FALSE; | |
1128 | cp = name; | 1128 | cp = name; | |
1129 | } | 1129 | } | |
1130 | 1130 | |||
1131 | DIR_DEBUG1("Searching for %s ...", name); | 1131 | DIR_DEBUG1("Searching for %s ...", name); | |
1132 | 1132 | |||
1133 | if (path == NULL) { | 1133 | if (path == NULL) { | |
1134 | DIR_DEBUG0("couldn't open path, file not found\n"); | 1134 | DIR_DEBUG0("couldn't open path, file not found\n"); | |
1135 | misses += 1; | 1135 | misses += 1; | |
1136 | return NULL; | 1136 | return NULL; | |
1137 | } | 1137 | } | |
1138 | 1138 | |||
1139 | Lst_OpenS(path); | 1139 | Lst_OpenS(path); | |
1140 | if ((ln = Lst_First(path)) != NULL) { | 1140 | if ((ln = Lst_FirstS(path)) != NULL) { | |
1141 | p = Lst_DatumS(ln); | 1141 | p = Lst_DatumS(ln); | |
1142 | if (p == dotLast) { | 1142 | if (p == dotLast) { | |
1143 | hasLastDot = TRUE; | 1143 | hasLastDot = TRUE; | |
1144 | DIR_DEBUG0("[dot last]..."); | 1144 | DIR_DEBUG0("[dot last]..."); | |
1145 | } | 1145 | } | |
1146 | } | 1146 | } | |
1147 | DIR_DEBUG0("\n"); | 1147 | DIR_DEBUG0("\n"); | |
1148 | 1148 | |||
1149 | /* | 1149 | /* | |
1150 | * If there's no leading directory components or if the leading | 1150 | * If there's no leading directory components or if the leading | |
1151 | * directory component is exactly `./', consult the cached contents | 1151 | * directory component is exactly `./', consult the cached contents | |
1152 | * of each of the directories on the search path. | 1152 | * of each of the directories on the search path. | |
1153 | */ | 1153 | */ | |
@@ -1754,27 +1754,27 @@ Dir_ClearPath(Lst path) | @@ -1754,27 +1754,27 @@ Dir_ClearPath(Lst path) | |||
1754 | * None | 1754 | * None | |
1755 | * | 1755 | * | |
1756 | * Side Effects: | 1756 | * Side Effects: | |
1757 | * Reference counts for added dirs are upped. | 1757 | * Reference counts for added dirs are upped. | |
1758 | * | 1758 | * | |
1759 | *----------------------------------------------------------------------- | 1759 | *----------------------------------------------------------------------- | |
1760 | */ | 1760 | */ | |
1761 | void | 1761 | void | |
1762 | Dir_Concat(Lst path1, Lst path2) | 1762 | Dir_Concat(Lst path1, Lst path2) | |
1763 | { | 1763 | { | |
1764 | LstNode ln; | 1764 | LstNode ln; | |
1765 | Path *p; | 1765 | Path *p; | |
1766 | 1766 | |||
1767 | for (ln = Lst_First(path2); ln != NULL; ln = Lst_SuccS(ln)) { | 1767 | for (ln = Lst_FirstS(path2); ln != NULL; ln = Lst_SuccS(ln)) { | |
1768 | p = Lst_DatumS(ln); | 1768 | p = Lst_DatumS(ln); | |
1769 | if (Lst_MemberS(path1, p) == NULL) { | 1769 | if (Lst_MemberS(path1, p) == NULL) { | |
1770 | p->refCount += 1; | 1770 | p->refCount += 1; | |
1771 | Lst_AppendS(path1, p); | 1771 | Lst_AppendS(path1, p); | |
1772 | } | 1772 | } | |
1773 | } | 1773 | } | |
1774 | } | 1774 | } | |
1775 | 1775 | |||
1776 | static int | 1776 | static int | |
1777 | percentage(int num, int den) | 1777 | percentage(int num, int den) | |
1778 | { | 1778 | { | |
1779 | return den != 0 ? num * 100 / den : 0; | 1779 | return den != 0 ? num * 100 / den : 0; | |
1780 | } | 1780 | } |
--- src/usr.bin/make/lst.c 2020/08/27 19:15:35 1.47
+++ src/usr.bin/make/lst.c 2020/08/28 04:14:31 1.48
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lst.c,v 1.47 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 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. | |
@@ -27,31 +27,31 @@ | @@ -27,31 +27,31 @@ | |||
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <stdint.h> | 35 | #include <stdint.h> | |
36 | 36 | |||
37 | #include "make.h" | 37 | #include "make.h" | |
38 | 38 | |||
39 | #ifndef MAKE_NATIVE | 39 | #ifndef MAKE_NATIVE | |
40 | static char rcsid[] = "$NetBSD: lst.c,v 1.47 2020/08/27 19:15:35 rillig Exp $"; | 40 | static char rcsid[] = "$NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 rillig Exp $"; | |
41 | #else | 41 | #else | |
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | #ifndef lint | 43 | #ifndef lint | |
44 | __RCSID("$NetBSD: lst.c,v 1.47 2020/08/27 19:15:35 rillig Exp $"); | 44 | __RCSID("$NetBSD: lst.c,v 1.48 2020/08/28 04:14:31 rillig Exp $"); | |
45 | #endif /* not lint */ | 45 | #endif /* not lint */ | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
48 | struct ListNode { | 48 | struct ListNode { | |
49 | struct ListNode *prev; /* previous element in list */ | 49 | struct ListNode *prev; /* previous element in list */ | |
50 | struct ListNode *next; /* next in list */ | 50 | struct ListNode *next; /* next in list */ | |
51 | uint8_t useCount; /* Count of functions using the node. | 51 | uint8_t useCount; /* Count of functions using the node. | |
52 | * node may not be deleted until count | 52 | * node may not be deleted until count | |
53 | * goes to 0 */ | 53 | * goes to 0 */ | |
54 | Boolean deleted; /* List node should be removed when done */ | 54 | Boolean deleted; /* List node should be removed when done */ | |
55 | union { | 55 | union { | |
56 | void *datum; /* datum associated with this element */ | 56 | void *datum; /* datum associated with this element */ | |
57 | const GNode *gnode; /* alias, just for debugging */ | 57 | const GNode *gnode; /* alias, just for debugging */ | |
@@ -322,27 +322,27 @@ LstNode_SetNullS(LstNode node) | @@ -322,27 +322,27 @@ LstNode_SetNullS(LstNode node) | |||
322 | { | 322 | { | |
323 | assert(LstNodeIsValid(node)); | 323 | assert(LstNodeIsValid(node)); | |
324 | 324 | |||
325 | node->datum = NULL; | 325 | node->datum = NULL; | |
326 | } | 326 | } | |
327 | 327 | |||
328 | 328 | |||
329 | /* | 329 | /* | |
330 | * Node-specific functions | 330 | * Node-specific functions | |
331 | */ | 331 | */ | |
332 | 332 | |||
333 | /* Return the first node from the given list, or NULL if the list is empty or | 333 | /* Return the first node from the given list, or NULL if the list is empty or | |
334 | * invalid. */ | 334 | * invalid. */ | |
335 | LstNode | 335 | static LstNode | |
336 | Lst_First(Lst list) | 336 | Lst_First(Lst list) | |
337 | { | 337 | { | |
338 | if (!LstIsValid(list) || LstIsEmpty(list)) { | 338 | if (!LstIsValid(list) || LstIsEmpty(list)) { | |
339 | return NULL; | 339 | return NULL; | |
340 | } else { | 340 | } else { | |
341 | return list->first; | 341 | return list->first; | |
342 | } | 342 | } | |
343 | } | 343 | } | |
344 | 344 | |||
345 | /* Return the first node from the given list, or NULL if the list is empty. */ | 345 | /* Return the first node from the given list, or NULL if the list is empty. */ | |
346 | LstNode | 346 | LstNode | |
347 | Lst_FirstS(Lst list) | 347 | Lst_FirstS(Lst list) | |
348 | { | 348 | { | |
@@ -466,27 +466,27 @@ Lst_MemberS(Lst list, void *datum) | @@ -466,27 +466,27 @@ Lst_MemberS(Lst list, void *datum) | |||
466 | } | 466 | } | |
467 | 467 | |||
468 | return NULL; | 468 | return NULL; | |
469 | } | 469 | } | |
470 | 470 | |||
471 | /* Apply the given function to each element of the given list. The function | 471 | /* Apply the given function to each element of the given list. The function | |
472 | * should return 0 if traversal should continue and non-zero if it should | 472 | * should return 0 if traversal should continue and non-zero if it should | |
473 | * abort. */ | 473 | * abort. */ | |
474 | int | 474 | int | |
475 | Lst_ForEachS(Lst list, LstActionProc proc, void *procData) | 475 | Lst_ForEachS(Lst list, LstActionProc proc, void *procData) | |
476 | { | 476 | { | |
477 | if (LstIsEmpty(list)) | 477 | if (LstIsEmpty(list)) | |
478 | return 0; /* XXX: Document what this value means. */ | 478 | return 0; /* XXX: Document what this value means. */ | |
479 | return Lst_ForEachFromS(list, Lst_First(list), proc, procData); | 479 | return Lst_ForEachFromS(list, Lst_FirstS(list), proc, procData); | |
480 | } | 480 | } | |
481 | 481 | |||
482 | /* Apply the given function to each element of the given list, starting from | 482 | /* Apply the given function to each element of the given list, starting from | |
483 | * the given node. The function should return 0 if traversal should continue, | 483 | * the given node. The function should return 0 if traversal should continue, | |
484 | * and non-zero if it should abort. */ | 484 | * and non-zero if it should abort. */ | |
485 | int | 485 | int | |
486 | Lst_ForEachFromS(Lst list, LstNode node, | 486 | Lst_ForEachFromS(Lst list, LstNode node, | |
487 | LstActionProc proc, void *procData) | 487 | LstActionProc proc, void *procData) | |
488 | { | 488 | { | |
489 | LstNode tln = node; | 489 | LstNode tln = node; | |
490 | LstNode next; | 490 | LstNode next; | |
491 | Boolean done; | 491 | Boolean done; | |
492 | int result; | 492 | int result; |
--- src/usr.bin/make/lst.h 2020/08/27 19:15:35 1.49
+++ src/usr.bin/make/lst.h 2020/08/28 04:14:31 1.50
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lst.h,v 1.49 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: lst.h,v 1.50 2020/08/28 04:14:31 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. | |
@@ -121,27 +121,26 @@ void Lst_AppendS(Lst, void *); | @@ -121,27 +121,26 @@ void Lst_AppendS(Lst, void *); | |||
121 | void Lst_RemoveS(Lst, LstNode); | 121 | void Lst_RemoveS(Lst, LstNode); | |
122 | /* Replace a node with a new value */ | 122 | /* Replace a node with a new value */ | |
123 | void LstNode_SetS(LstNode, void *); | 123 | void LstNode_SetS(LstNode, void *); | |
124 | void LstNode_SetNullS(LstNode); | 124 | void LstNode_SetNullS(LstNode); | |
125 | 125 | |||
126 | void Lst_PrependAllS(Lst, Lst); | 126 | void Lst_PrependAllS(Lst, Lst); | |
127 | void Lst_AppendAllS(Lst, Lst); | 127 | void Lst_AppendAllS(Lst, Lst); | |
128 | void Lst_MoveAllS(Lst, Lst); | 128 | void Lst_MoveAllS(Lst, Lst); | |
129 | 129 | |||
130 | /* | 130 | /* | |
131 | * Node-specific functions | 131 | * Node-specific functions | |
132 | */ | 132 | */ | |
133 | /* Return first element in list */ | 133 | /* Return first element in list */ | |
134 | LstNode Lst_First(Lst); | |||
135 | LstNode Lst_FirstS(Lst); | 134 | LstNode Lst_FirstS(Lst); | |
136 | /* Return last element in list */ | 135 | /* Return last element in list */ | |
137 | LstNode Lst_Last(Lst); | 136 | LstNode Lst_Last(Lst); | |
138 | LstNode Lst_LastS(Lst); | 137 | LstNode Lst_LastS(Lst); | |
139 | /* Return successor to given element */ | 138 | /* Return successor to given element */ | |
140 | LstNode Lst_SuccS(LstNode); | 139 | LstNode Lst_SuccS(LstNode); | |
141 | /* Return predecessor to given element */ | 140 | /* Return predecessor to given element */ | |
142 | LstNode Lst_PrevS(LstNode); | 141 | LstNode Lst_PrevS(LstNode); | |
143 | /* Get datum from LstNode */ | 142 | /* Get datum from LstNode */ | |
144 | void *Lst_DatumS(LstNode); | 143 | void *Lst_DatumS(LstNode); | |
145 | 144 | |||
146 | /* | 145 | /* | |
147 | * Functions for entire lists | 146 | * Functions for entire lists |
--- src/usr.bin/make/main.c 2020/08/27 19:15:35 1.317
+++ src/usr.bin/make/main.c 2020/08/28 04:14:31 1.318
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.317 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: main.c,v 1.318 2020/08/28 04:14:31 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,39 +59,39 @@ | @@ -59,39 +59,39 @@ | |||
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: main.c,v 1.317 2020/08/27 19:15:35 rillig Exp $"; | 72 | static char rcsid[] = "$NetBSD: main.c,v 1.318 2020/08/28 04:14:31 rillig Exp $"; | |
73 | #else | 73 | #else | |
74 | #include <sys/cdefs.h> | 74 | #include <sys/cdefs.h> | |
75 | #ifndef lint | 75 | #ifndef lint | |
76 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ | 76 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ | |
77 | The Regents of the University of California. All rights reserved."); | 77 | The Regents of the University of California. All rights reserved."); | |
78 | #endif /* not lint */ | 78 | #endif /* not lint */ | |
79 | 79 | |||
80 | #ifndef lint | 80 | #ifndef lint | |
81 | #if 0 | 81 | #if 0 | |
82 | static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; | 82 | static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; | |
83 | #else | 83 | #else | |
84 | __RCSID("$NetBSD: main.c,v 1.317 2020/08/27 19:15:35 rillig Exp $"); | 84 | __RCSID("$NetBSD: main.c,v 1.318 2020/08/28 04:14:31 rillig Exp $"); | |
85 | #endif | 85 | #endif | |
86 | #endif /* not lint */ | 86 | #endif /* not lint */ | |
87 | #endif | 87 | #endif | |
88 | 88 | |||
89 | /*- | 89 | /*- | |
90 | * main.c -- | 90 | * main.c -- | |
91 | * The main file for this entire program. Exit routines etc | 91 | * The main file for this entire program. Exit routines etc | |
92 | * reside here. | 92 | * reside here. | |
93 | * | 93 | * | |
94 | * Utility functions defined in this file: | 94 | * Utility functions defined in this file: | |
95 | * Main_ParseArgLine Takes a line of arguments, breaks them and | 95 | * Main_ParseArgLine Takes a line of arguments, breaks them and | |
96 | * treats them as if they were given when first | 96 | * treats them as if they were given when first | |
97 | * invoked. Used by the parse module to implement | 97 | * invoked. Used by the parse module to implement | |
@@ -859,27 +859,27 @@ MakeMode(const char *mode) | @@ -859,27 +859,27 @@ MakeMode(const char *mode) | |||
859 | static void | 859 | static void | |
860 | doPrintVars(void) | 860 | doPrintVars(void) | |
861 | { | 861 | { | |
862 | LstNode ln; | 862 | LstNode ln; | |
863 | Boolean expandVars; | 863 | Boolean expandVars; | |
864 | 864 | |||
865 | if (printVars == EXPAND_VARS) | 865 | if (printVars == EXPAND_VARS) | |
866 | expandVars = TRUE; | 866 | expandVars = TRUE; | |
867 | else if (debugVflag) | 867 | else if (debugVflag) | |
868 | expandVars = FALSE; | 868 | expandVars = FALSE; | |
869 | else | 869 | else | |
870 | expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE); | 870 | expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE); | |
871 | 871 | |||
872 | for (ln = Lst_First(variables); ln != NULL; ln = Lst_SuccS(ln)) { | 872 | for (ln = Lst_FirstS(variables); ln != NULL; ln = Lst_SuccS(ln)) { | |
873 | char *var = Lst_DatumS(ln); | 873 | char *var = Lst_DatumS(ln); | |
874 | const char *value; | 874 | const char *value; | |
875 | char *p1; | 875 | char *p1; | |
876 | 876 | |||
877 | if (strchr(var, '$')) { | 877 | if (strchr(var, '$')) { | |
878 | value = p1 = Var_Subst(var, VAR_GLOBAL, VARE_WANTRES); | 878 | value = p1 = Var_Subst(var, VAR_GLOBAL, VARE_WANTRES); | |
879 | } else if (expandVars) { | 879 | } else if (expandVars) { | |
880 | char tmp[128]; | 880 | char tmp[128]; | |
881 | int len = snprintf(tmp, sizeof(tmp), "${%s}", var); | 881 | int len = snprintf(tmp, sizeof(tmp), "${%s}", var); | |
882 | 882 | |||
883 | if (len >= (int)sizeof(tmp)) | 883 | if (len >= (int)sizeof(tmp)) | |
884 | Fatal("%s: variable name too big: %s", | 884 | Fatal("%s: variable name too big: %s", | |
885 | progname, var); | 885 | progname, var); | |
@@ -1268,27 +1268,27 @@ main(int argc, char **argv) | @@ -1268,27 +1268,27 @@ main(int argc, char **argv) | |||
1268 | DEFAULT = NULL; | 1268 | DEFAULT = NULL; | |
1269 | (void)time(&now); | 1269 | (void)time(&now); | |
1270 | 1270 | |||
1271 | Trace_Log(MAKESTART, NULL); | 1271 | Trace_Log(MAKESTART, NULL); | |
1272 | 1272 | |||
1273 | /* | 1273 | /* | |
1274 | * Set up the .TARGETS variable to contain the list of targets to be | 1274 | * Set up the .TARGETS variable to contain the list of targets to be | |
1275 | * created. If none specified, make the variable empty -- the parser | 1275 | * created. If none specified, make the variable empty -- the parser | |
1276 | * will fill the thing in with the default or .MAIN target. | 1276 | * will fill the thing in with the default or .MAIN target. | |
1277 | */ | 1277 | */ | |
1278 | if (!Lst_IsEmptyS(create)) { | 1278 | if (!Lst_IsEmptyS(create)) { | |
1279 | LstNode ln; | 1279 | LstNode ln; | |
1280 | 1280 | |||
1281 | for (ln = Lst_First(create); ln != NULL; ln = Lst_SuccS(ln)) { | 1281 | for (ln = Lst_FirstS(create); ln != NULL; ln = Lst_SuccS(ln)) { | |
1282 | char *name = Lst_DatumS(ln); | 1282 | char *name = Lst_DatumS(ln); | |
1283 | Var_Append(".TARGETS", name, VAR_GLOBAL); | 1283 | Var_Append(".TARGETS", name, VAR_GLOBAL); | |
1284 | } | 1284 | } | |
1285 | } else | 1285 | } else | |
1286 | Var_Set(".TARGETS", "", VAR_GLOBAL); | 1286 | Var_Set(".TARGETS", "", VAR_GLOBAL); | |
1287 | 1287 | |||
1288 | 1288 | |||
1289 | /* | 1289 | /* | |
1290 | * If no user-supplied system path was given (through the -m option) | 1290 | * If no user-supplied system path was given (through the -m option) | |
1291 | * add the directories from the DEFSYSPATH (more than one may be given | 1291 | * add the directories from the DEFSYSPATH (more than one may be given | |
1292 | * as dir1:...:dirn) to the system include path. | 1292 | * as dir1:...:dirn) to the system include path. | |
1293 | */ | 1293 | */ | |
1294 | if (syspath == NULL || *syspath == '\0') | 1294 | if (syspath == NULL || *syspath == '\0') |
--- src/usr.bin/make/make.c 2020/08/27 19:15:35 1.127
+++ src/usr.bin/make/make.c 2020/08/28 04:14:31 1.128
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: make.c,v 1.127 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: make.c,v 1.128 2020/08/28 04:14:31 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: make.c,v 1.127 2020/08/27 19:15:35 rillig Exp $"; | 72 | static char rcsid[] = "$NetBSD: make.c,v 1.128 2020/08/28 04:14:31 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[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; | 77 | static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; | |
78 | #else | 78 | #else | |
79 | __RCSID("$NetBSD: make.c,v 1.127 2020/08/27 19:15:35 rillig Exp $"); | 79 | __RCSID("$NetBSD: make.c,v 1.128 2020/08/28 04:14:31 rillig Exp $"); | |
80 | #endif | 80 | #endif | |
81 | #endif /* not lint */ | 81 | #endif /* not lint */ | |
82 | #endif | 82 | #endif | |
83 | 83 | |||
84 | /*- | 84 | /*- | |
85 | * make.c -- | 85 | * make.c -- | |
86 | * The functions which perform the examination of targets and | 86 | * The functions which perform the examination of targets and | |
87 | * their suitability for creation | 87 | * their suitability for creation | |
88 | * | 88 | * | |
89 | * Interface: | 89 | * Interface: | |
90 | * Make_Run Initialize things for the module and recreate | 90 | * Make_Run Initialize things for the module and recreate | |
91 | * whatever needs recreating. Returns TRUE if | 91 | * whatever needs recreating. Returns TRUE if | |
92 | * work was (or would have been) done and FALSE | 92 | * work was (or would have been) done and FALSE | |
@@ -725,27 +725,27 @@ Make_Update(GNode *cgn) | @@ -725,27 +725,27 @@ Make_Update(GNode *cgn) | |||
725 | */ | 725 | */ | |
726 | if ((centurion = cgn->centurion) != NULL) { | 726 | if ((centurion = cgn->centurion) != NULL) { | |
727 | if (!Lst_IsEmptyS(cgn->parents)) | 727 | if (!Lst_IsEmptyS(cgn->parents)) | |
728 | Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num); | 728 | Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num); | |
729 | centurion->unmade_cohorts -= 1; | 729 | centurion->unmade_cohorts -= 1; | |
730 | if (centurion->unmade_cohorts < 0) | 730 | if (centurion->unmade_cohorts < 0) | |
731 | Error("Graph cycles through centurion %s", centurion->name); | 731 | Error("Graph cycles through centurion %s", centurion->name); | |
732 | } else { | 732 | } else { | |
733 | centurion = cgn; | 733 | centurion = cgn; | |
734 | } | 734 | } | |
735 | parents = centurion->parents; | 735 | parents = centurion->parents; | |
736 | 736 | |||
737 | /* If this was a .ORDER node, schedule the RHS */ | 737 | /* If this was a .ORDER node, schedule the RHS */ | |
738 | Lst_ForEachS(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade)); | 738 | Lst_ForEachS(centurion->order_succ, MakeBuildParent, Lst_FirstS(toBeMade)); | |
739 | 739 | |||
740 | /* Now mark all the parents as having one less unmade child */ | 740 | /* Now mark all the parents as having one less unmade child */ | |
741 | Lst_OpenS(parents); | 741 | Lst_OpenS(parents); | |
742 | while ((ln = Lst_NextS(parents)) != NULL) { | 742 | while ((ln = Lst_NextS(parents)) != NULL) { | |
743 | pgn = Lst_DatumS(ln); | 743 | pgn = Lst_DatumS(ln); | |
744 | if (DEBUG(MAKE)) | 744 | if (DEBUG(MAKE)) | |
745 | fprintf(debug_file, "inspect parent %s%s: flags %x, " | 745 | fprintf(debug_file, "inspect parent %s%s: flags %x, " | |
746 | "type %x, made %d, unmade %d ", | 746 | "type %x, made %d, unmade %d ", | |
747 | pgn->name, pgn->cohort_num, pgn->flags, | 747 | pgn->name, pgn->cohort_num, pgn->flags, | |
748 | pgn->type, pgn->made, pgn->unmade-1); | 748 | pgn->type, pgn->made, pgn->unmade-1); | |
749 | 749 | |||
750 | if (!(pgn->flags & REMAKE)) { | 750 | if (!(pgn->flags & REMAKE)) { | |
751 | /* This parent isn't needed */ | 751 | /* This parent isn't needed */ | |
@@ -1111,27 +1111,27 @@ MakeStartJobs(void) | @@ -1111,27 +1111,27 @@ MakeStartJobs(void) | |||
1111 | fprintf(debug_file, "already checked %s%s\n", | 1111 | fprintf(debug_file, "already checked %s%s\n", | |
1112 | gn->name, gn->cohort_num); | 1112 | gn->name, gn->cohort_num); | |
1113 | gn->made = DEFERRED; | 1113 | gn->made = DEFERRED; | |
1114 | continue; | 1114 | continue; | |
1115 | } | 1115 | } | |
1116 | gn->checked = checked; | 1116 | gn->checked = checked; | |
1117 | 1117 | |||
1118 | if (gn->unmade != 0) { | 1118 | if (gn->unmade != 0) { | |
1119 | /* | 1119 | /* | |
1120 | * We can't build this yet, add all unmade children to toBeMade, | 1120 | * We can't build this yet, add all unmade children to toBeMade, | |
1121 | * just before the current first element. | 1121 | * just before the current first element. | |
1122 | */ | 1122 | */ | |
1123 | gn->made = DEFERRED; | 1123 | gn->made = DEFERRED; | |
1124 | Lst_ForEachS(gn->children, MakeBuildChild, Lst_First(toBeMade)); | 1124 | Lst_ForEachS(gn->children, MakeBuildChild, Lst_FirstS(toBeMade)); | |
1125 | /* and drop this node on the floor */ | 1125 | /* and drop this node on the floor */ | |
1126 | if (DEBUG(MAKE)) | 1126 | if (DEBUG(MAKE)) | |
1127 | fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num); | 1127 | fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num); | |
1128 | continue; | 1128 | continue; | |
1129 | } | 1129 | } | |
1130 | 1130 | |||
1131 | gn->made = BEINGMADE; | 1131 | gn->made = BEINGMADE; | |
1132 | if (Make_OODate(gn)) { | 1132 | if (Make_OODate(gn)) { | |
1133 | if (DEBUG(MAKE)) { | 1133 | if (DEBUG(MAKE)) { | |
1134 | fprintf(debug_file, "out-of-date\n"); | 1134 | fprintf(debug_file, "out-of-date\n"); | |
1135 | } | 1135 | } | |
1136 | if (queryFlag) { | 1136 | if (queryFlag) { | |
1137 | return TRUE; | 1137 | return TRUE; | |
@@ -1441,27 +1441,27 @@ Make_ProcessWait(Lst targs) | @@ -1441,27 +1441,27 @@ Make_ProcessWait(Lst targs) | |||
1441 | while (!Lst_IsEmptyS(examine)) { | 1441 | while (!Lst_IsEmptyS(examine)) { | |
1442 | pgn = Lst_DequeueS(examine); | 1442 | pgn = Lst_DequeueS(examine); | |
1443 | 1443 | |||
1444 | /* We only want to process each child-list once */ | 1444 | /* We only want to process each child-list once */ | |
1445 | if (pgn->flags & DONE_WAIT) | 1445 | if (pgn->flags & DONE_WAIT) | |
1446 | continue; | 1446 | continue; | |
1447 | pgn->flags |= DONE_WAIT; | 1447 | pgn->flags |= DONE_WAIT; | |
1448 | if (DEBUG(MAKE)) | 1448 | if (DEBUG(MAKE)) | |
1449 | fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name); | 1449 | fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name); | |
1450 | 1450 | |||
1451 | if (pgn->type & OP_DOUBLEDEP) | 1451 | if (pgn->type & OP_DOUBLEDEP) | |
1452 | Lst_PrependAllS(examine, pgn->cohorts); | 1452 | Lst_PrependAllS(examine, pgn->cohorts); | |
1453 | 1453 | |||
1454 | owln = Lst_First(pgn->children); | 1454 | owln = Lst_FirstS(pgn->children); | |
1455 | Lst_OpenS(pgn->children); | 1455 | Lst_OpenS(pgn->children); | |
1456 | for (; (ln = Lst_NextS(pgn->children)) != NULL; ) { | 1456 | for (; (ln = Lst_NextS(pgn->children)) != NULL; ) { | |
1457 | cgn = Lst_DatumS(ln); | 1457 | cgn = Lst_DatumS(ln); | |
1458 | if (cgn->type & OP_WAIT) { | 1458 | if (cgn->type & OP_WAIT) { | |
1459 | /* Make the .WAIT node depend on the previous children */ | 1459 | /* Make the .WAIT node depend on the previous children */ | |
1460 | Lst_ForEachFromS(pgn->children, owln, add_wait_dep, cgn); | 1460 | Lst_ForEachFromS(pgn->children, owln, add_wait_dep, cgn); | |
1461 | owln = ln; | 1461 | owln = ln; | |
1462 | } else { | 1462 | } else { | |
1463 | Lst_AppendS(examine, cgn); | 1463 | Lst_AppendS(examine, cgn); | |
1464 | } | 1464 | } | |
1465 | } | 1465 | } | |
1466 | Lst_CloseS(pgn->children); | 1466 | Lst_CloseS(pgn->children); | |
1467 | } | 1467 | } |
--- src/usr.bin/make/meta.c 2020/08/27 19:15:35 1.103
+++ src/usr.bin/make/meta.c 2020/08/28 04:14:31 1.104
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: meta.c,v 1.103 2020/08/27 19:15:35 rillig Exp $ */ | 1 | /* $NetBSD: meta.c,v 1.104 2020/08/28 04:14:31 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Implement 'meta' mode. | 4 | * Implement 'meta' mode. | |
5 | * Adapted from John Birrell's patches to FreeBSD make. | 5 | * Adapted from John Birrell's patches to FreeBSD make. | |
6 | * --sjg | 6 | * --sjg | |
7 | */ | 7 | */ | |
8 | /* | 8 | /* | |
9 | * Copyright (c) 2009-2016, Juniper Networks, Inc. | 9 | * Copyright (c) 2009-2016, Juniper Networks, Inc. | |
10 | * Portions Copyright (c) 2009, John Birrell. | 10 | * Portions Copyright (c) 2009, John Birrell. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -1157,27 +1157,27 @@ meta_oodate(GNode *gn, Boolean oodate) | @@ -1157,27 +1157,27 @@ meta_oodate(GNode *gn, Boolean oodate) | |||
1157 | cwdlen = strlen(cwd); | 1157 | cwdlen = strlen(cwd); | |
1158 | } | 1158 | } | |
1159 | strlcpy(lcwd, cwd, sizeof(lcwd)); | 1159 | strlcpy(lcwd, cwd, sizeof(lcwd)); | |
1160 | strlcpy(latestdir, cwd, sizeof(latestdir)); | 1160 | strlcpy(latestdir, cwd, sizeof(latestdir)); | |
1161 | 1161 | |||
1162 | if (!tmpdir) { | 1162 | if (!tmpdir) { | |
1163 | tmpdir = getTmpdir(); | 1163 | tmpdir = getTmpdir(); | |
1164 | tmplen = strlen(tmpdir); | 1164 | tmplen = strlen(tmpdir); | |
1165 | } | 1165 | } | |
1166 | 1166 | |||
1167 | /* we want to track all the .meta we read */ | 1167 | /* we want to track all the .meta we read */ | |
1168 | Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL); | 1168 | Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL); | |
1169 | 1169 | |||
1170 | ln = Lst_First(gn->commands); | 1170 | ln = Lst_FirstS(gn->commands); | |
1171 | while (!oodate && (x = fgetLine(&buf, &bufsz, 0, fp)) > 0) { | 1171 | while (!oodate && (x = fgetLine(&buf, &bufsz, 0, fp)) > 0) { | |
1172 | lineno++; | 1172 | lineno++; | |
1173 | if (buf[x - 1] == '\n') | 1173 | if (buf[x - 1] == '\n') | |
1174 | buf[x - 1] = '\0'; | 1174 | buf[x - 1] = '\0'; | |
1175 | else { | 1175 | else { | |
1176 | warnx("%s: %d: line truncated at %u", fname, lineno, x); | 1176 | warnx("%s: %d: line truncated at %u", fname, lineno, x); | |
1177 | oodate = TRUE; | 1177 | oodate = TRUE; | |
1178 | break; | 1178 | break; | |
1179 | } | 1179 | } | |
1180 | link_src = NULL; | 1180 | link_src = NULL; | |
1181 | move_target = NULL; | 1181 | move_target = NULL; | |
1182 | /* Find the start of the build monitor section. */ | 1182 | /* Find the start of the build monitor section. */ | |
1183 | if (!have_filemon) { | 1183 | if (!have_filemon) { | |
@@ -1588,27 +1588,27 @@ meta_oodate(GNode *gn, Boolean oodate) | @@ -1588,27 +1588,27 @@ meta_oodate(GNode *gn, Boolean oodate) | |||
1588 | CHECK_VALID_META(p); | 1588 | CHECK_VALID_META(p); | |
1589 | if (strcmp(p, cwd) != 0) { | 1589 | if (strcmp(p, cwd) != 0) { | |
1590 | if (DEBUG(META)) | 1590 | if (DEBUG(META)) | |
1591 | fprintf(debug_file, "%s: %d: the current working directory has changed from '%s' to '%s'\n", fname, lineno, p, curdir); | 1591 | fprintf(debug_file, "%s: %d: the current working directory has changed from '%s' to '%s'\n", fname, lineno, p, curdir); | |
1592 | oodate = TRUE; | 1592 | oodate = TRUE; | |
1593 | } | 1593 | } | |
1594 | } | 1594 | } | |
1595 | } | 1595 | } | |
1596 | 1596 | |||
1597 | fclose(fp); | 1597 | fclose(fp); | |
1598 | if (!Lst_IsEmptyS(missingFiles)) { | 1598 | if (!Lst_IsEmptyS(missingFiles)) { | |
1599 | if (DEBUG(META)) | 1599 | if (DEBUG(META)) | |
1600 | fprintf(debug_file, "%s: missing files: %s...\n", | 1600 | fprintf(debug_file, "%s: missing files: %s...\n", | |
1601 | fname, (char *)Lst_DatumS(Lst_First(missingFiles))); | 1601 | fname, (char *)Lst_DatumS(Lst_FirstS(missingFiles))); | |
1602 | oodate = TRUE; | 1602 | oodate = TRUE; | |
1603 | } | 1603 | } | |
1604 | if (!oodate && !have_filemon && filemonMissing) { | 1604 | if (!oodate && !have_filemon && filemonMissing) { | |
1605 | if (DEBUG(META)) | 1605 | if (DEBUG(META)) | |
1606 | fprintf(debug_file, "%s: missing filemon data\n", fname); | 1606 | fprintf(debug_file, "%s: missing filemon data\n", fname); | |
1607 | oodate = TRUE; | 1607 | oodate = TRUE; | |
1608 | } | 1608 | } | |
1609 | } else { | 1609 | } else { | |
1610 | if (writeMeta && (metaMissing || (gn->type & OP_META))) { | 1610 | if (writeMeta && (metaMissing || (gn->type & OP_META))) { | |
1611 | cp = NULL; | 1611 | cp = NULL; | |
1612 | 1612 | |||
1613 | /* if target is in .CURDIR we do not need a meta file */ | 1613 | /* if target is in .CURDIR we do not need a meta file */ | |
1614 | if (gn->path && (cp = strrchr(gn->path, '/')) && cp > gn->path) { | 1614 | if (gn->path && (cp = strrchr(gn->path, '/')) && cp > gn->path) { |
--- src/usr.bin/make/suff.c 2020/08/28 03:35:45 1.122
+++ src/usr.bin/make/suff.c 2020/08/28 04:14:31 1.123
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $ */ | 1 | /* $NetBSD: suff.c,v 1.123 2020/08/28 04:14:31 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: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $"; | 72 | static char rcsid[] = "$NetBSD: suff.c,v 1.123 2020/08/28 04:14:31 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[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; | 77 | static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; | |
78 | #else | 78 | #else | |
79 | __RCSID("$NetBSD: suff.c,v 1.122 2020/08/28 03:35:45 rillig Exp $"); | 79 | __RCSID("$NetBSD: suff.c,v 1.123 2020/08/28 04:14:31 rillig Exp $"); | |
80 | #endif | 80 | #endif | |
81 | #endif /* not lint */ | 81 | #endif /* not lint */ | |
82 | #endif | 82 | #endif | |
83 | 83 | |||
84 | /*- | 84 | /*- | |
85 | * suff.c -- | 85 | * suff.c -- | |
86 | * Functions to maintain suffix lists and find implicit dependents | 86 | * Functions to maintain suffix lists and find implicit dependents | |
87 | * using suffix transformation rules | 87 | * using suffix transformation rules | |
88 | * | 88 | * | |
89 | * Interface: | 89 | * Interface: | |
90 | * Suff_Init Initialize all things to do with suffixes. | 90 | * Suff_Init Initialize all things to do with suffixes. | |
91 | * | 91 | * | |
92 | * Suff_End Cleanup the module | 92 | * Suff_End Cleanup the module | |
@@ -2052,27 +2052,27 @@ SuffFindNormalDeps(GNode *gn, Lst slst) | @@ -2052,27 +2052,27 @@ SuffFindNormalDeps(GNode *gn, Lst slst) | |||
2052 | char *pref; /* Prefix to use */ | 2052 | char *pref; /* Prefix to use */ | |
2053 | Src *targ; /* General Src target pointer */ | 2053 | Src *targ; /* General Src target pointer */ | |
2054 | SuffixCmpData sd; /* Search string data */ | 2054 | SuffixCmpData sd; /* Search string data */ | |
2055 | 2055 | |||
2056 | 2056 | |||
2057 | sd.len = strlen(gn->name); | 2057 | sd.len = strlen(gn->name); | |
2058 | sd.ename = eoname = gn->name + sd.len; | 2058 | sd.ename = eoname = gn->name + sd.len; | |
2059 | 2059 | |||
2060 | sopref = gn->name; | 2060 | sopref = gn->name; | |
2061 | 2061 | |||
2062 | /* | 2062 | /* | |
2063 | * Begin at the beginning... | 2063 | * Begin at the beginning... | |
2064 | */ | 2064 | */ | |
2065 | ln = Lst_First(sufflist); | 2065 | ln = Lst_FirstS(sufflist); | |
2066 | srcs = Lst_Init(); | 2066 | srcs = Lst_Init(); | |
2067 | targs = Lst_Init(); | 2067 | targs = Lst_Init(); | |
2068 | 2068 | |||
2069 | /* | 2069 | /* | |
2070 | * We're caught in a catch-22 here. On the one hand, we want to use any | 2070 | * We're caught in a catch-22 here. On the one hand, we want to use any | |
2071 | * transformation implied by the target's sources, but we can't examine | 2071 | * transformation implied by the target's sources, but we can't examine | |
2072 | * the sources until we've expanded any variables/wildcards they may hold, | 2072 | * the sources until we've expanded any variables/wildcards they may hold, | |
2073 | * and we can't do that until we've set up the target's local variables | 2073 | * and we can't do that until we've set up the target's local variables | |
2074 | * and we can't do that until we know what the proper suffix for the | 2074 | * and we can't do that until we know what the proper suffix for the | |
2075 | * target is (in case there are two suffixes one of which is a suffix of | 2075 | * target is (in case there are two suffixes one of which is a suffix of | |
2076 | * the other) and we can't know that until we've found its implied | 2076 | * the other) and we can't know that until we've found its implied | |
2077 | * source, which we may not want to use if there's an existing source | 2077 | * source, which we may not want to use if there's an existing source | |
2078 | * that implies a different transformation. | 2078 | * that implies a different transformation. | |
@@ -2180,50 +2180,50 @@ SuffFindNormalDeps(GNode *gn, Lst slst) | @@ -2180,50 +2180,50 @@ SuffFindNormalDeps(GNode *gn, Lst slst) | |||
2180 | 2180 | |||
2181 | /* | 2181 | /* | |
2182 | * Using the list of possible sources built up from the target | 2182 | * Using the list of possible sources built up from the target | |
2183 | * suffix(es), try and find an existing file/target that matches. | 2183 | * suffix(es), try and find an existing file/target that matches. | |
2184 | */ | 2184 | */ | |
2185 | bottom = SuffFindThem(srcs, slst); | 2185 | bottom = SuffFindThem(srcs, slst); | |
2186 | 2186 | |||
2187 | if (bottom == NULL) { | 2187 | if (bottom == NULL) { | |
2188 | /* | 2188 | /* | |
2189 | * No known transformations -- use the first suffix found | 2189 | * No known transformations -- use the first suffix found | |
2190 | * for setting the local variables. | 2190 | * for setting the local variables. | |
2191 | */ | 2191 | */ | |
2192 | if (!Lst_IsEmptyS(targs)) { | 2192 | if (!Lst_IsEmptyS(targs)) { | |
2193 | targ = Lst_DatumS(Lst_First(targs)); | 2193 | targ = Lst_DatumS(Lst_FirstS(targs)); | |
2194 | } else { | 2194 | } else { | |
2195 | targ = NULL; | 2195 | targ = NULL; | |
2196 | } | 2196 | } | |
2197 | } else { | 2197 | } else { | |
2198 | /* | 2198 | /* | |
2199 | * Work up the transformation path to find the suffix of the | 2199 | * Work up the transformation path to find the suffix of the | |
2200 | * target to which the transformation was made. | 2200 | * target to which the transformation was made. | |
2201 | */ | 2201 | */ | |
2202 | for (targ = bottom; targ->parent != NULL; targ = targ->parent) | 2202 | for (targ = bottom; targ->parent != NULL; targ = targ->parent) | |
2203 | continue; | 2203 | continue; | |
2204 | } | 2204 | } | |
2205 | } | 2205 | } | |
2206 | 2206 | |||
2207 | Var_Set(TARGET, gn->path ? gn->path : gn->name, gn); | 2207 | Var_Set(TARGET, gn->path ? gn->path : gn->name, gn); | |
2208 | 2208 | |||
2209 | pref = (targ != NULL) ? targ->pref : gn->name; | 2209 | pref = (targ != NULL) ? targ->pref : gn->name; | |
2210 | Var_Set(PREFIX, pref, gn); | 2210 | Var_Set(PREFIX, pref, gn); | |
2211 | 2211 | |||
2212 | /* | 2212 | /* | |
2213 | * Now we've got the important local variables set, expand any sources | 2213 | * Now we've got the important local variables set, expand any sources | |
2214 | * that still contain variables or wildcards in their names. | 2214 | * that still contain variables or wildcards in their names. | |
2215 | */ | 2215 | */ | |
2216 | for (ln = Lst_First(gn->children); ln != NULL; ln = nln) { | 2216 | for (ln = Lst_FirstS(gn->children); ln != NULL; ln = nln) { | |
2217 | nln = Lst_SuccS(ln); | 2217 | nln = Lst_SuccS(ln); | |
2218 | SuffExpandChildren(ln, gn); | 2218 | SuffExpandChildren(ln, gn); | |
2219 | } | 2219 | } | |
2220 | 2220 | |||
2221 | if (targ == NULL) { | 2221 | if (targ == NULL) { | |
2222 | if (DEBUG(SUFF)) { | 2222 | if (DEBUG(SUFF)) { | |
2223 | fprintf(debug_file, "\tNo valid suffix on %s\n", gn->name); | 2223 | fprintf(debug_file, "\tNo valid suffix on %s\n", gn->name); | |
2224 | } | 2224 | } | |
2225 | 2225 | |||
2226 | sfnd_abort: | 2226 | sfnd_abort: | |
2227 | /* | 2227 | /* | |
2228 | * Deal with finding the thing on the default search path. We | 2228 | * Deal with finding the thing on the default search path. We | |
2229 | * always do that, not only if the node is only a source (not | 2229 | * always do that, not only if the node is only a source (not |