| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: suff.c,v 1.140 2020/08/30 18:26:41 rillig Exp $ */ | | 1 | /* $NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 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.140 2020/08/30 18:26:41 rillig Exp $"; | | 72 | static char rcsid[] = "$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 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.140 2020/08/30 18:26:41 rillig Exp $"); | | 79 | __RCSID("$NetBSD: suff.c,v 1.141 2020/08/31 05:56:02 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 |
| @@ -220,27 +220,26 @@ static Suff *suffNull; /* The NULL | | | @@ -220,27 +220,26 @@ static Suff *suffNull; /* The NULL |
220 | static Suff *emptySuff; /* The empty suffix required for POSIX | | 220 | static Suff *emptySuff; /* The empty suffix required for POSIX |
221 | * single-suffix transformation rules */ | | 221 | * single-suffix transformation rules */ |
222 | | | 222 | |
223 | | | 223 | |
224 | static void SuffUnRef(void *, void *); | | 224 | static void SuffUnRef(void *, void *); |
225 | static void SuffFree(void *); | | 225 | static void SuffFree(void *); |
226 | static void SuffInsert(Lst, Suff *); | | 226 | static void SuffInsert(Lst, Suff *); |
227 | static void SuffRemove(Lst, Suff *); | | 227 | static void SuffRemove(Lst, Suff *); |
228 | static Boolean SuffParseTransform(char *, Suff **, Suff **); | | 228 | static Boolean SuffParseTransform(char *, Suff **, Suff **); |
229 | static int SuffRebuildGraph(void *, void *); | | 229 | static int SuffRebuildGraph(void *, void *); |
230 | static int SuffScanTargets(void *, void *); | | 230 | static int SuffScanTargets(void *, void *); |
231 | static int SuffAddSrc(void *, void *); | | 231 | static int SuffAddSrc(void *, void *); |
232 | static void SuffAddLevel(Lst, Src *); | | 232 | static void SuffAddLevel(Lst, Src *); |
233 | static Src *SuffFindCmds(Src *, Lst); | | | |
234 | static void SuffExpandChildren(LstNode, GNode *); | | 233 | static void SuffExpandChildren(LstNode, GNode *); |
235 | static void SuffExpandWildcards(LstNode, GNode *); | | 234 | static void SuffExpandWildcards(LstNode, GNode *); |
236 | static Boolean SuffApplyTransform(GNode *, GNode *, Suff *, Suff *); | | 235 | static Boolean SuffApplyTransform(GNode *, GNode *, Suff *, Suff *); |
237 | static void SuffFindDeps(GNode *, Lst); | | 236 | static void SuffFindDeps(GNode *, Lst); |
238 | static void SuffFindArchiveDeps(GNode *, Lst); | | 237 | static void SuffFindArchiveDeps(GNode *, Lst); |
239 | static void SuffFindNormalDeps(GNode *, Lst); | | 238 | static void SuffFindNormalDeps(GNode *, Lst); |
240 | static int SuffPrintName(void *, void *); | | 239 | static int SuffPrintName(void *, void *); |
241 | static int SuffPrintSuff(void *, void *); | | 240 | static int SuffPrintSuff(void *, void *); |
242 | static int SuffPrintTrans(void *, void *); | | 241 | static int SuffPrintTrans(void *, void *); |
243 | | | 242 | |
244 | /*************** Lst Predicates ****************/ | | 243 | /*************** Lst Predicates ****************/ |
245 | /*- | | 244 | /*- |
246 | *----------------------------------------------------------------------- | | 245 | *----------------------------------------------------------------------- |
| @@ -1222,26 +1221,27 @@ SuffFindCmds(Src *targ, Lst slst) | | | @@ -1222,26 +1221,27 @@ SuffFindCmds(Src *targ, Lst slst) |
1222 | ret->suff = suff; | | 1221 | ret->suff = suff; |
1223 | suff->refCount++; | | 1222 | suff->refCount++; |
1224 | ret->parent = targ; | | 1223 | ret->parent = targ; |
1225 | ret->node = s; | | 1224 | ret->node = s; |
1226 | ret->children = 0; | | 1225 | ret->children = 0; |
1227 | targ->children += 1; | | 1226 | targ->children += 1; |
1228 | #ifdef DEBUG_SRC | | 1227 | #ifdef DEBUG_SRC |
1229 | ret->cp = Lst_Init(); | | 1228 | ret->cp = Lst_Init(); |
1230 | fprintf(debug_file, "3 add %p %p\n", targ, ret); | | 1229 | fprintf(debug_file, "3 add %p %p\n", targ, ret); |
1231 | Lst_Append(targ->cp, ret); | | 1230 | Lst_Append(targ->cp, ret); |
1232 | #endif | | 1231 | #endif |
1233 | Lst_Append(slst, ret); | | 1232 | Lst_Append(slst, ret); |
1234 | SUFF_DEBUG1("\tusing existing source %s\n", s->name); | | 1233 | SUFF_DEBUG1("\tusing existing source %s\n", s->name); |
| | | 1234 | Lst_Close(t->children); |
1235 | return ret; | | 1235 | return ret; |
1236 | } | | 1236 | } |
1237 | | | 1237 | |
1238 | /* Expand the names of any children of a given node that contain variable | | 1238 | /* Expand the names of any children of a given node that contain variable |
1239 | * invocations or file wildcards into actual targets. | | 1239 | * invocations or file wildcards into actual targets. |
1240 | * | | 1240 | * |
1241 | * The expanded node is removed from the parent's list of children, and the | | 1241 | * The expanded node is removed from the parent's list of children, and the |
1242 | * parent's unmade counter is decremented, but other nodes may be added. | | 1242 | * parent's unmade counter is decremented, but other nodes may be added. |
1243 | * | | 1243 | * |
1244 | * Input: | | 1244 | * Input: |
1245 | * cln Child to examine | | 1245 | * cln Child to examine |
1246 | * pgn Parent node being processed | | 1246 | * pgn Parent node being processed |
1247 | */ | | 1247 | */ |