| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: compat.c,v 1.132 2020/08/28 04:48:56 rillig Exp $ */ | | 1 | /* $NetBSD: compat.c,v 1.133 2020/08/29 08:09:07 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: compat.c,v 1.132 2020/08/28 04:48:56 rillig Exp $"; | | 73 | static char rcsid[] = "$NetBSD: compat.c,v 1.133 2020/08/29 08:09:07 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[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; | | 78 | static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; |
79 | #else | | 79 | #else |
80 | __RCSID("$NetBSD: compat.c,v 1.132 2020/08/28 04:48:56 rillig Exp $"); | | 80 | __RCSID("$NetBSD: compat.c,v 1.133 2020/08/29 08:09:07 rillig Exp $"); |
81 | #endif | | 81 | #endif |
82 | #endif /* not lint */ | | 82 | #endif /* not lint */ |
83 | #endif | | 83 | #endif |
84 | | | 84 | |
85 | /*- | | 85 | /*- |
86 | * compat.c -- | | 86 | * compat.c -- |
87 | * The routines in this file implement the full-compatibility | | 87 | * The routines in this file implement the full-compatibility |
88 | * mode of PMake. Most of the special functionality of PMake | | 88 | * mode of PMake. Most of the special functionality of PMake |
89 | * is available in this mode. Things not supported: | | 89 | * is available in this mode. Things not supported: |
90 | * - different shells. | | 90 | * - different shells. |
91 | * - friendly variable substitution. | | 91 | * - friendly variable substitution. |
92 | * | | 92 | * |
93 | * Interface: | | 93 | * Interface: |
| @@ -216,27 +216,27 @@ CompatRunCommand(void *cmdp, void *gnp) | | | @@ -216,27 +216,27 @@ CompatRunCommand(void *cmdp, void *gnp) |
216 | volatile Boolean errCheck; /* Check errors */ | | 216 | volatile Boolean errCheck; /* Check errors */ |
217 | int reason; /* Reason for child's death */ | | 217 | int reason; /* Reason for child's death */ |
218 | int status; /* Description of child's death */ | | 218 | int status; /* Description of child's death */ |
219 | pid_t cpid; /* Child actually found */ | | 219 | pid_t cpid; /* Child actually found */ |
220 | pid_t retstat; /* Result of wait */ | | 220 | pid_t retstat; /* Result of wait */ |
221 | LstNode cmdNode; /* Node where current command is located */ | | 221 | LstNode cmdNode; /* Node where current command is located */ |
222 | const char ** volatile av; /* Argument vector for thing to exec */ | | 222 | const char ** volatile av; /* Argument vector for thing to exec */ |
223 | char ** volatile mav;/* Copy of the argument vector for freeing */ | | 223 | char ** volatile mav;/* Copy of the argument vector for freeing */ |
224 | Boolean useShell; /* TRUE if command should be executed | | 224 | Boolean useShell; /* TRUE if command should be executed |
225 | * using a shell */ | | 225 | * using a shell */ |
226 | char * volatile cmd = (char *)cmdp; | | 226 | char * volatile cmd = (char *)cmdp; |
227 | GNode *gn = (GNode *)gnp; | | 227 | GNode *gn = (GNode *)gnp; |
228 | | | 228 | |
229 | silent = gn->type & OP_SILENT; | | 229 | silent = (gn->type & OP_SILENT) != 0; |
230 | errCheck = !(gn->type & OP_IGNORE); | | 230 | errCheck = !(gn->type & OP_IGNORE); |
231 | doIt = FALSE; | | 231 | doIt = FALSE; |
232 | | | 232 | |
233 | cmdNode = Lst_Member(gn->commands, cmd); | | 233 | cmdNode = Lst_Member(gn->commands, cmd); |
234 | cmdStart = Var_Subst(cmd, gn, VARE_WANTRES); | | 234 | cmdStart = Var_Subst(cmd, gn, VARE_WANTRES); |
235 | | | 235 | |
236 | /* | | 236 | /* |
237 | * brk_string will return an argv with a NULL in av[0], thus causing | | 237 | * brk_string will return an argv with a NULL in av[0], thus causing |
238 | * execvp to choke and die horribly. Besides, how can we execute a null | | 238 | * execvp to choke and die horribly. Besides, how can we execute a null |
239 | * command? In any case, we warn the user that the command expanded to | | 239 | * command? In any case, we warn the user that the command expanded to |
240 | * nothing (is this the right thing to do?). | | 240 | * nothing (is this the right thing to do?). |
241 | */ | | 241 | */ |
242 | | | 242 | |
| @@ -250,27 +250,27 @@ CompatRunCommand(void *cmdp, void *gnp) | | | @@ -250,27 +250,27 @@ CompatRunCommand(void *cmdp, void *gnp) |
250 | if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { | | 250 | if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { |
251 | assert(ENDNode != NULL); | | 251 | assert(ENDNode != NULL); |
252 | Lst_Append(ENDNode->commands, cmdStart); | | 252 | Lst_Append(ENDNode->commands, cmdStart); |
253 | return 0; | | 253 | return 0; |
254 | } | | 254 | } |
255 | if (strcmp(cmdStart, "...") == 0) { | | 255 | if (strcmp(cmdStart, "...") == 0) { |
256 | gn->type |= OP_SAVE_CMDS; | | 256 | gn->type |= OP_SAVE_CMDS; |
257 | return 0; | | 257 | return 0; |
258 | } | | 258 | } |
259 | | | 259 | |
260 | while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) { | | 260 | while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) { |
261 | switch (*cmd) { | | 261 | switch (*cmd) { |
262 | case '@': | | 262 | case '@': |
263 | silent = DEBUG(LOUD) ? FALSE : TRUE; | | 263 | silent = !DEBUG(LOUD); |
264 | break; | | 264 | break; |
265 | case '-': | | 265 | case '-': |
266 | errCheck = FALSE; | | 266 | errCheck = FALSE; |
267 | break; | | 267 | break; |
268 | case '+': | | 268 | case '+': |
269 | doIt = TRUE; | | 269 | doIt = TRUE; |
270 | if (!shellName) /* we came here from jobs */ | | 270 | if (!shellName) /* we came here from jobs */ |
271 | Shell_Init(); | | 271 | Shell_Init(); |
272 | break; | | 272 | break; |
273 | } | | 273 | } |
274 | cmd++; | | 274 | cmd++; |
275 | } | | 275 | } |
276 | | | 276 | |
| @@ -595,27 +595,27 @@ Compat_Make(void *gnp, void *pgnp) | | | @@ -595,27 +595,27 @@ Compat_Make(void *gnp, void *pgnp) |
595 | * Our commands are ok, but we still have to worry about the -t | | 595 | * Our commands are ok, but we still have to worry about the -t |
596 | * flag... | | 596 | * flag... |
597 | */ | | 597 | */ |
598 | if (!touchFlag || (gn->type & OP_MAKE)) { | | 598 | if (!touchFlag || (gn->type & OP_MAKE)) { |
599 | curTarg = gn; | | 599 | curTarg = gn; |
600 | #ifdef USE_META | | 600 | #ifdef USE_META |
601 | if (useMeta && !NoExecute(gn)) { | | 601 | if (useMeta && !NoExecute(gn)) { |
602 | meta_job_start(NULL, gn); | | 602 | meta_job_start(NULL, gn); |
603 | } | | 603 | } |
604 | #endif | | 604 | #endif |
605 | Lst_ForEach(gn->commands, CompatRunCommand, gn); | | 605 | Lst_ForEach(gn->commands, CompatRunCommand, gn); |
606 | curTarg = NULL; | | 606 | curTarg = NULL; |
607 | } else { | | 607 | } else { |
608 | Job_Touch(gn, gn->type & OP_SILENT); | | 608 | Job_Touch(gn, (gn->type & OP_SILENT) != 0); |
609 | } | | 609 | } |
610 | } else { | | 610 | } else { |
611 | gn->made = ERROR; | | 611 | gn->made = ERROR; |
612 | } | | 612 | } |
613 | #ifdef USE_META | | 613 | #ifdef USE_META |
614 | if (useMeta && !NoExecute(gn)) { | | 614 | if (useMeta && !NoExecute(gn)) { |
615 | if (meta_job_finish(NULL) != 0) | | 615 | if (meta_job_finish(NULL) != 0) |
616 | gn->made = ERROR; | | 616 | gn->made = ERROR; |
617 | } | | 617 | } |
618 | #endif | | 618 | #endif |
619 | | | 619 | |
620 | if (gn->made != ERROR) { | | 620 | if (gn->made != ERROR) { |
621 | /* | | 621 | /* |