| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $ */ | | 1 | /* $NetBSD: for.c,v 1.57 2020/07/28 16:45:56 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992, The Regents of the University of California. | | 4 | * Copyright (c) 1992, The Regents of the University of California. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -20,34 +20,34 @@ | | | @@ -20,34 +20,34 @@ |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #ifndef MAKE_NATIVE | | 32 | #ifndef MAKE_NATIVE |
33 | static char rcsid[] = "$NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $"; | | 33 | static char rcsid[] = "$NetBSD: for.c,v 1.57 2020/07/28 16:45:56 rillig Exp $"; |
34 | #else | | 34 | #else |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #ifndef lint | | 36 | #ifndef lint |
37 | #if 0 | | 37 | #if 0 |
38 | static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; | | 38 | static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; |
39 | #else | | 39 | #else |
40 | __RCSID("$NetBSD: for.c,v 1.56 2020/07/28 16:42:22 rillig Exp $"); | | 40 | __RCSID("$NetBSD: for.c,v 1.57 2020/07/28 16:45:56 rillig Exp $"); |
41 | #endif | | 41 | #endif |
42 | #endif /* not lint */ | | 42 | #endif /* not lint */ |
43 | #endif | | 43 | #endif |
44 | | | 44 | |
45 | /*- | | 45 | /*- |
46 | * for.c -- | | 46 | * for.c -- |
47 | * Functions to handle loops in a makefile. | | 47 | * Functions to handle loops in a makefile. |
48 | * | | 48 | * |
49 | * Interface: | | 49 | * Interface: |
50 | * For_Eval Evaluate the loop in the passed line. | | 50 | * For_Eval Evaluate the loop in the passed line. |
51 | * For_Run Run accumulated loop | | 51 | * For_Run Run accumulated loop |
52 | * | | 52 | * |
53 | */ | | 53 | */ |
| @@ -78,27 +78,27 @@ __RCSID("$NetBSD: for.c,v 1.56 2020/07/2 | | | @@ -78,27 +78,27 @@ __RCSID("$NetBSD: for.c,v 1.56 2020/07/2 |
78 | * the initial .for loop and the matching .endfor; | | 78 | * the initial .for loop and the matching .endfor; |
79 | * then we evaluate the for loop for each variable in the varlist. | | 79 | * then we evaluate the for loop for each variable in the varlist. |
80 | * | | 80 | * |
81 | * Note that any nested fors are just passed through; they get handled | | 81 | * Note that any nested fors are just passed through; they get handled |
82 | * recursively in For_Eval when we're expanding the enclosing for in | | 82 | * recursively in For_Eval when we're expanding the enclosing for in |
83 | * For_Run. | | 83 | * For_Run. |
84 | */ | | 84 | */ |
85 | | | 85 | |
86 | static int forLevel = 0; /* Nesting level */ | | 86 | static int forLevel = 0; /* Nesting level */ |
87 | | | 87 | |
88 | /* | | 88 | /* |
89 | * State of a for loop. | | 89 | * State of a for loop. |
90 | */ | | 90 | */ |
91 | typedef struct _For { | | 91 | typedef struct { |
92 | Buffer buf; /* Body of loop */ | | 92 | Buffer buf; /* Body of loop */ |
93 | strlist_t vars; /* Iteration variables */ | | 93 | strlist_t vars; /* Iteration variables */ |
94 | strlist_t items; /* Substitution items */ | | 94 | strlist_t items; /* Substitution items */ |
95 | char *parse_buf; | | 95 | char *parse_buf; |
96 | int short_var; | | 96 | int short_var; |
97 | int sub_next; | | 97 | int sub_next; |
98 | } For; | | 98 | } For; |
99 | | | 99 | |
100 | static For *accumFor; /* Loop being accumulated */ | | 100 | static For *accumFor; /* Loop being accumulated */ |
101 | | | 101 | |
102 | | | 102 | |
103 | | | 103 | |
104 | static char * | | 104 | static char * |