make(1): remove ReturnStatus, SUCCESS and FAILURE These are used in so few places now that it is easier to use a simple Boolean for them.diff -r1.104 -r1.105 src/usr.bin/make/arch.c
(rillig)
--- src/usr.bin/make/arch.c 2020/08/29 10:12:06 1.104
+++ src/usr.bin/make/arch.c 2020/08/29 12:20:17 1.105
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $ */ | 1 | /* $NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 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,52 +59,52 @@ | @@ -59,52 +59,52 @@ | |||
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: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $"; | 72 | static char rcsid[] = "$NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 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[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; | 77 | static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; | |
78 | #else | 78 | #else | |
79 | __RCSID("$NetBSD: arch.c,v 1.104 2020/08/29 10:12:06 rillig Exp $"); | 79 | __RCSID("$NetBSD: arch.c,v 1.105 2020/08/29 12:20:17 rillig Exp $"); | |
80 | #endif | 80 | #endif | |
81 | #endif /* not lint */ | 81 | #endif /* not lint */ | |
82 | #endif | 82 | #endif | |
83 | 83 | |||
84 | /*- | 84 | /*- | |
85 | * arch.c -- | 85 | * arch.c -- | |
86 | * Functions to manipulate libraries, archives and their members. | 86 | * Functions to manipulate libraries, archives and their members. | |
87 | * | 87 | * | |
88 | * Once again, cacheing/hashing comes into play in the manipulation | 88 | * Once again, cacheing/hashing comes into play in the manipulation | |
89 | * of archives. The first time an archive is referenced, all of its members' | 89 | * of archives. The first time an archive is referenced, all of its members' | |
90 | * headers are read and hashed and the archive closed again. All hashed | 90 | * headers are read and hashed and the archive closed again. All hashed | |
91 | * archives are kept on a list which is searched each time an archive member | 91 | * archives are kept on a list which is searched each time an archive member | |
92 | * is referenced. | 92 | * is referenced. | |
93 | * | 93 | * | |
94 | * The interface to this module is: | 94 | * The interface to this module is: | |
95 | * Arch_ParseArchive Given an archive specification, return a list | 95 | * Arch_ParseArchive Given an archive specification, return a list | |
96 | * of GNode's, one for each member in the spec. | 96 | * of GNode's, one for each member in the spec. | |
97 | * FAILURE is returned if the specification is | 97 | * FALSE is returned if the specification is | |
98 | * invalid for some reason. | 98 | * invalid for some reason. | |
99 | * | 99 | * | |
100 | * Arch_Touch Alter the modification time of the archive | 100 | * Arch_Touch Alter the modification time of the archive | |
101 | * member described by the given node to be | 101 | * member described by the given node to be | |
102 | * the current time. | 102 | * the current time. | |
103 | * | 103 | * | |
104 | * Arch_TouchLib Update the modification time of the library | 104 | * Arch_TouchLib Update the modification time of the library | |
105 | * described by the given node. This is special | 105 | * described by the given node. This is special | |
106 | * because it also updates the modification time | 106 | * because it also updates the modification time | |
107 | * of the library's table of contents. | 107 | * of the library's table of contents. | |
108 | * | 108 | * | |
109 | * Arch_MTime Find the modification time of a member of | 109 | * Arch_MTime Find the modification time of a member of | |
110 | * an archive *in the archive*. The time is also | 110 | * an archive *in the archive*. The time is also | |
@@ -348,27 +348,27 @@ Arch_ParseArchive(char **linePtr, Lst no | @@ -348,27 +348,27 @@ Arch_ParseArchive(char **linePtr, Lst no | |||
348 | * SuffExpandChildren handle it... | 348 | * SuffExpandChildren handle it... | |
349 | */ | 349 | */ | |
350 | gn = Targ_FindNode(buf, TARG_CREATE); | 350 | gn = Targ_FindNode(buf, TARG_CREATE); | |
351 | 351 | |||
352 | if (gn == NULL) { | 352 | if (gn == NULL) { | |
353 | free(buf); | 353 | free(buf); | |
354 | return FALSE; | 354 | return FALSE; | |
355 | } else { | 355 | } else { | |
356 | gn->type |= OP_ARCHV; | 356 | gn->type |= OP_ARCHV; | |
357 | Lst_Append(nodeLst, gn); | 357 | Lst_Append(nodeLst, gn); | |
358 | } | 358 | } | |
359 | } else if (!Arch_ParseArchive(&sacrifice, nodeLst, ctxt)) { | 359 | } else if (!Arch_ParseArchive(&sacrifice, nodeLst, ctxt)) { | |
360 | /* | 360 | /* | |
361 | * Error in nested call -- free buffer and return FAILURE | 361 | * Error in nested call -- free buffer and return FALSE | |
362 | * ourselves. | 362 | * ourselves. | |
363 | */ | 363 | */ | |
364 | free(buf); | 364 | free(buf); | |
365 | return FALSE; | 365 | return FALSE; | |
366 | } | 366 | } | |
367 | /* | 367 | /* | |
368 | * Free buffer and continue with our work. | 368 | * Free buffer and continue with our work. | |
369 | */ | 369 | */ | |
370 | free(buf); | 370 | free(buf); | |
371 | } else if (Dir_HasWildcards(memName)) { | 371 | } else if (Dir_HasWildcards(memName)) { | |
372 | Lst members = Lst_Init(); | 372 | Lst members = Lst_Init(); | |
373 | Buffer nameBuf; | 373 | Buffer nameBuf; | |
374 | 374 |
--- src/usr.bin/make/job.c 2020/08/29 10:41:12 1.223
+++ src/usr.bin/make/job.c 2020/08/29 12:20:17 1.224
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $ */ | 1 | /* $NetBSD: job.c,v 1.224 2020/08/29 12:20:17 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: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $"; | 73 | static char rcsid[] = "$NetBSD: job.c,v 1.224 2020/08/29 12:20:17 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[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; | 78 | static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; | |
79 | #else | 79 | #else | |
80 | __RCSID("$NetBSD: job.c,v 1.223 2020/08/29 10:41:12 rillig Exp $"); | 80 | __RCSID("$NetBSD: job.c,v 1.224 2020/08/29 12:20:17 rillig Exp $"); | |
81 | #endif | 81 | #endif | |
82 | #endif /* not lint */ | 82 | #endif /* not lint */ | |
83 | #endif | 83 | #endif | |
84 | 84 | |||
85 | /*- | 85 | /*- | |
86 | * job.c -- | 86 | * job.c -- | |
87 | * handle the creation etc. of our child processes. | 87 | * handle the creation etc. of our child processes. | |
88 | * | 88 | * | |
89 | * Interface: | 89 | * Interface: | |
90 | * Job_Make Start the creation of the given target. | 90 | * Job_Make Start the creation of the given target. | |
91 | * | 91 | * | |
92 | * Job_CatchChildren Check for and handle the termination of any | 92 | * Job_CatchChildren Check for and handle the termination of any | |
93 | * children. This must be called reasonably | 93 | * children. This must be called reasonably | |
@@ -102,27 +102,27 @@ __RCSID("$NetBSD: job.c,v 1.223 2020/08/ | @@ -102,27 +102,27 @@ __RCSID("$NetBSD: job.c,v 1.223 2020/08/ | |||
102 | * a time given by the SEL_* constants, below, | 102 | * a time given by the SEL_* constants, below, | |
103 | * or until output is ready. | 103 | * or until output is ready. | |
104 | * | 104 | * | |
105 | * Job_Init Called to initialize this module. in addition, | 105 | * Job_Init Called to initialize this module. in addition, | |
106 | * any commands attached to the .BEGIN target | 106 | * any commands attached to the .BEGIN target | |
107 | * are executed before this function returns. | 107 | * are executed before this function returns. | |
108 | * Hence, the makefile must have been parsed | 108 | * Hence, the makefile must have been parsed | |
109 | * before this function is called. | 109 | * before this function is called. | |
110 | * | 110 | * | |
111 | * Job_End Cleanup any memory used. | 111 | * Job_End Cleanup any memory used. | |
112 | * | 112 | * | |
113 | * Job_ParseShell Given the line following a .SHELL target, parse | 113 | * Job_ParseShell Given the line following a .SHELL target, parse | |
114 | * the line as a shell specification. Returns | 114 | * the line as a shell specification. Returns | |
115 | * FAILURE if the spec was incorrect. | 115 | * FALSE if the spec was incorrect. | |
116 | * | 116 | * | |
117 | * Job_Finish Perform any final processing which needs doing. | 117 | * Job_Finish Perform any final processing which needs doing. | |
118 | * This includes the execution of any commands | 118 | * This includes the execution of any commands | |
119 | * which have been/were attached to the .END | 119 | * which have been/were attached to the .END | |
120 | * target. It should only be called when the | 120 | * target. It should only be called when the | |
121 | * job table is empty. | 121 | * job table is empty. | |
122 | * | 122 | * | |
123 | * Job_AbortAll Abort all currently running jobs. It doesn't | 123 | * Job_AbortAll Abort all currently running jobs. It doesn't | |
124 | * handle output or do anything for the jobs, | 124 | * handle output or do anything for the jobs, | |
125 | * just kills them. It should only be called in | 125 | * just kills them. It should only be called in | |
126 | * an emergency, as it were. | 126 | * an emergency, as it were. | |
127 | * | 127 | * | |
128 | * Job_CheckCommands Verify that the commands for a target are | 128 | * Job_CheckCommands Verify that the commands for a target are | |
@@ -2366,27 +2366,27 @@ JobMatchShell(const char *name) | @@ -2366,27 +2366,27 @@ JobMatchShell(const char *name) | |||
2366 | return NULL; | 2366 | return NULL; | |
2367 | } | 2367 | } | |
2368 | 2368 | |||
2369 | /*- | 2369 | /*- | |
2370 | *----------------------------------------------------------------------- | 2370 | *----------------------------------------------------------------------- | |
2371 | * Job_ParseShell -- | 2371 | * Job_ParseShell -- | |
2372 | * Parse a shell specification and set up commandShell, shellPath | 2372 | * Parse a shell specification and set up commandShell, shellPath | |
2373 | * and shellName appropriately. | 2373 | * and shellName appropriately. | |
2374 | * | 2374 | * | |
2375 | * Input: | 2375 | * Input: | |
2376 | * line The shell spec | 2376 | * line The shell spec | |
2377 | * | 2377 | * | |
2378 | * Results: | 2378 | * Results: | |
2379 | * FAILURE if the specification was incorrect. | 2379 | * FALSE if the specification was incorrect. | |
2380 | * | 2380 | * | |
2381 | * Side Effects: | 2381 | * Side Effects: | |
2382 | * commandShell points to a Shell structure (either predefined or | 2382 | * commandShell points to a Shell structure (either predefined or | |
2383 | * created from the shell spec), shellPath is the full path of the | 2383 | * created from the shell spec), shellPath is the full path of the | |
2384 | * shell described by commandShell, while shellName is just the | 2384 | * shell described by commandShell, while shellName is just the | |
2385 | * final component of shellPath. | 2385 | * final component of shellPath. | |
2386 | * | 2386 | * | |
2387 | * Notes: | 2387 | * Notes: | |
2388 | * A shell specification consists of a .SHELL target, with dependency | 2388 | * A shell specification consists of a .SHELL target, with dependency | |
2389 | * operator, followed by a series of blank-separated words. Double | 2389 | * operator, followed by a series of blank-separated words. Double | |
2390 | * quotes can be used to use blanks in words. A backslash escapes | 2390 | * quotes can be used to use blanks in words. A backslash escapes | |
2391 | * anything (most notably a double-quote and a space) and | 2391 | * anything (most notably a double-quote and a space) and | |
2392 | * provides the functionality it does in C. Each word consists of | 2392 | * provides the functionality it does in C. Each word consists of | |
@@ -2403,52 +2403,52 @@ JobMatchShell(const char *name) | @@ -2403,52 +2403,52 @@ JobMatchShell(const char *name) | |||
2403 | * hasErrCtl True if shell has error checking control | 2403 | * hasErrCtl True if shell has error checking control | |
2404 | * newline String literal to represent a newline char | 2404 | * newline String literal to represent a newline char | |
2405 | * check Command to turn on error checking if hasErrCtl | 2405 | * check Command to turn on error checking if hasErrCtl | |
2406 | * is TRUE or template of command to echo a command | 2406 | * is TRUE or template of command to echo a command | |
2407 | * for which error checking is off if hasErrCtl is | 2407 | * for which error checking is off if hasErrCtl is | |
2408 | * FALSE. | 2408 | * FALSE. | |
2409 | * ignore Command to turn off error checking if hasErrCtl | 2409 | * ignore Command to turn off error checking if hasErrCtl | |
2410 | * is TRUE or template of command to execute a | 2410 | * is TRUE or template of command to execute a | |
2411 | * command so as to ignore any errors it returns if | 2411 | * command so as to ignore any errors it returns if | |
2412 | * hasErrCtl is FALSE. | 2412 | * hasErrCtl is FALSE. | |
2413 | * | 2413 | * | |
2414 | *----------------------------------------------------------------------- | 2414 | *----------------------------------------------------------------------- | |
2415 | */ | 2415 | */ | |
2416 | ReturnStatus | 2416 | Boolean | |
2417 | Job_ParseShell(char *line) | 2417 | Job_ParseShell(char *line) | |
2418 | { | 2418 | { | |
2419 | char **words; | 2419 | char **words; | |
2420 | char **argv; | 2420 | char **argv; | |
2421 | size_t argc; | 2421 | size_t argc; | |
2422 | char *path; | 2422 | char *path; | |
2423 | Shell newShell; | 2423 | Shell newShell; | |
2424 | Boolean fullSpec = FALSE; | 2424 | Boolean fullSpec = FALSE; | |
2425 | Shell *sh; | 2425 | Shell *sh; | |
2426 | 2426 | |||
2427 | while (isspace((unsigned char)*line)) { | 2427 | while (isspace((unsigned char)*line)) { | |
2428 | line++; | 2428 | line++; | |
2429 | } | 2429 | } | |
2430 | 2430 | |||
2431 | free(shellArgv); | 2431 | free(shellArgv); | |
2432 | 2432 | |||
2433 | memset(&newShell, 0, sizeof(newShell)); | 2433 | memset(&newShell, 0, sizeof(newShell)); | |
2434 | 2434 | |||
2435 | /* | 2435 | /* | |
2436 | * Parse the specification by keyword | 2436 | * Parse the specification by keyword | |
2437 | */ | 2437 | */ | |
2438 | words = brk_string(line, TRUE, &argc, &path); | 2438 | words = brk_string(line, TRUE, &argc, &path); | |
2439 | if (words == NULL) { | 2439 | if (words == NULL) { | |
2440 | Error("Unterminated quoted string [%s]", line); | 2440 | Error("Unterminated quoted string [%s]", line); | |
2441 | return FAILURE; | 2441 | return FALSE; | |
2442 | } | 2442 | } | |
2443 | shellArgv = path; | 2443 | shellArgv = path; | |
2444 | 2444 | |||
2445 | for (path = NULL, argv = words; argc != 0; argc--, argv++) { | 2445 | for (path = NULL, argv = words; argc != 0; argc--, argv++) { | |
2446 | if (strncmp(*argv, "path=", 5) == 0) { | 2446 | if (strncmp(*argv, "path=", 5) == 0) { | |
2447 | path = &argv[0][5]; | 2447 | path = &argv[0][5]; | |
2448 | } else if (strncmp(*argv, "name=", 5) == 0) { | 2448 | } else if (strncmp(*argv, "name=", 5) == 0) { | |
2449 | newShell.name = &argv[0][5]; | 2449 | newShell.name = &argv[0][5]; | |
2450 | } else { | 2450 | } else { | |
2451 | if (strncmp(*argv, "quiet=", 6) == 0) { | 2451 | if (strncmp(*argv, "quiet=", 6) == 0) { | |
2452 | newShell.echoOff = &argv[0][6]; | 2452 | newShell.echoOff = &argv[0][6]; | |
2453 | } else if (strncmp(*argv, "echo=", 5) == 0) { | 2453 | } else if (strncmp(*argv, "echo=", 5) == 0) { | |
2454 | newShell.echoOn = &argv[0][5]; | 2454 | newShell.echoOn = &argv[0][5]; | |
@@ -2467,49 +2467,49 @@ Job_ParseShell(char *line) | @@ -2467,49 +2467,49 @@ Job_ParseShell(char *line) | |||
2467 | newShell.newline = &argv[0][8]; | 2467 | newShell.newline = &argv[0][8]; | |
2468 | } else if (strncmp(*argv, "check=", 6) == 0) { | 2468 | } else if (strncmp(*argv, "check=", 6) == 0) { | |
2469 | newShell.errCheck = &argv[0][6]; | 2469 | newShell.errCheck = &argv[0][6]; | |
2470 | } else if (strncmp(*argv, "ignore=", 7) == 0) { | 2470 | } else if (strncmp(*argv, "ignore=", 7) == 0) { | |
2471 | newShell.ignErr = &argv[0][7]; | 2471 | newShell.ignErr = &argv[0][7]; | |
2472 | } else if (strncmp(*argv, "errout=", 7) == 0) { | 2472 | } else if (strncmp(*argv, "errout=", 7) == 0) { | |
2473 | newShell.errOut = &argv[0][7]; | 2473 | newShell.errOut = &argv[0][7]; | |
2474 | } else if (strncmp(*argv, "comment=", 8) == 0) { | 2474 | } else if (strncmp(*argv, "comment=", 8) == 0) { | |
2475 | newShell.commentChar = argv[0][8]; | 2475 | newShell.commentChar = argv[0][8]; | |
2476 | } else { | 2476 | } else { | |
2477 | Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"", | 2477 | Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"", | |
2478 | *argv); | 2478 | *argv); | |
2479 | free(words); | 2479 | free(words); | |
2480 | return FAILURE; | 2480 | return FALSE; | |
2481 | } | 2481 | } | |
2482 | fullSpec = TRUE; | 2482 | fullSpec = TRUE; | |
2483 | } | 2483 | } | |
2484 | } | 2484 | } | |
2485 | 2485 | |||
2486 | if (path == NULL) { | 2486 | if (path == NULL) { | |
2487 | /* | 2487 | /* | |
2488 | * If no path was given, the user wants one of the pre-defined shells, | 2488 | * If no path was given, the user wants one of the pre-defined shells, | |
2489 | * yes? So we find the one s/he wants with the help of JobMatchShell | 2489 | * yes? So we find the one s/he wants with the help of JobMatchShell | |
2490 | * and set things up the right way. shellPath will be set up by | 2490 | * and set things up the right way. shellPath will be set up by | |
2491 | * Shell_Init. | 2491 | * Shell_Init. | |
2492 | */ | 2492 | */ | |
2493 | if (newShell.name == NULL) { | 2493 | if (newShell.name == NULL) { | |
2494 | Parse_Error(PARSE_FATAL, "Neither path nor name specified"); | 2494 | Parse_Error(PARSE_FATAL, "Neither path nor name specified"); | |
2495 | free(words); | 2495 | free(words); | |
2496 | return FAILURE; | 2496 | return FALSE; | |
2497 | } else { | 2497 | } else { | |
2498 | if ((sh = JobMatchShell(newShell.name)) == NULL) { | 2498 | if ((sh = JobMatchShell(newShell.name)) == NULL) { | |
2499 | Parse_Error(PARSE_WARNING, "%s: No matching shell", | 2499 | Parse_Error(PARSE_WARNING, "%s: No matching shell", | |
2500 | newShell.name); | 2500 | newShell.name); | |
2501 | free(words); | 2501 | free(words); | |
2502 | return FAILURE; | 2502 | return FALSE; | |
2503 | } | 2503 | } | |
2504 | commandShell = sh; | 2504 | commandShell = sh; | |
2505 | shellName = newShell.name; | 2505 | shellName = newShell.name; | |
2506 | if (shellPath) { | 2506 | if (shellPath) { | |
2507 | /* Shell_Init has already been called! Do it again. */ | 2507 | /* Shell_Init has already been called! Do it again. */ | |
2508 | free(UNCONST(shellPath)); | 2508 | free(UNCONST(shellPath)); | |
2509 | shellPath = NULL; | 2509 | shellPath = NULL; | |
2510 | Shell_Init(); | 2510 | Shell_Init(); | |
2511 | } | 2511 | } | |
2512 | } | 2512 | } | |
2513 | } else { | 2513 | } else { | |
2514 | /* | 2514 | /* | |
2515 | * The user provided a path. If s/he gave nothing else (fullSpec is | 2515 | * The user provided a path. If s/he gave nothing else (fullSpec is | |
@@ -2525,27 +2525,27 @@ Job_ParseShell(char *line) | @@ -2525,27 +2525,27 @@ Job_ParseShell(char *line) | |||
2525 | } else { | 2525 | } else { | |
2526 | path += 1; | 2526 | path += 1; | |
2527 | } | 2527 | } | |
2528 | if (newShell.name != NULL) { | 2528 | if (newShell.name != NULL) { | |
2529 | shellName = newShell.name; | 2529 | shellName = newShell.name; | |
2530 | } else { | 2530 | } else { | |
2531 | shellName = path; | 2531 | shellName = path; | |
2532 | } | 2532 | } | |
2533 | if (!fullSpec) { | 2533 | if (!fullSpec) { | |
2534 | if ((sh = JobMatchShell(shellName)) == NULL) { | 2534 | if ((sh = JobMatchShell(shellName)) == NULL) { | |
2535 | Parse_Error(PARSE_WARNING, "%s: No matching shell", | 2535 | Parse_Error(PARSE_WARNING, "%s: No matching shell", | |
2536 | shellName); | 2536 | shellName); | |
2537 | free(words); | 2537 | free(words); | |
2538 | return FAILURE; | 2538 | return FALSE; | |
2539 | } | 2539 | } | |
2540 | commandShell = sh; | 2540 | commandShell = sh; | |
2541 | } else { | 2541 | } else { | |
2542 | commandShell = bmake_malloc(sizeof(Shell)); | 2542 | commandShell = bmake_malloc(sizeof(Shell)); | |
2543 | *commandShell = newShell; | 2543 | *commandShell = newShell; | |
2544 | } | 2544 | } | |
2545 | /* this will take care of shellErrFlag */ | 2545 | /* this will take care of shellErrFlag */ | |
2546 | Shell_Init(); | 2546 | Shell_Init(); | |
2547 | } | 2547 | } | |
2548 | 2548 | |||
2549 | if (commandShell->echoOn && commandShell->echoOff) { | 2549 | if (commandShell->echoOn && commandShell->echoOff) { | |
2550 | commandShell->hasEchoCtl = TRUE; | 2550 | commandShell->hasEchoCtl = TRUE; | |
2551 | } | 2551 | } | |
@@ -2554,27 +2554,27 @@ Job_ParseShell(char *line) | @@ -2554,27 +2554,27 @@ Job_ParseShell(char *line) | |||
2554 | if (commandShell->errCheck == NULL) { | 2554 | if (commandShell->errCheck == NULL) { | |
2555 | commandShell->errCheck = ""; | 2555 | commandShell->errCheck = ""; | |
2556 | } | 2556 | } | |
2557 | if (commandShell->ignErr == NULL) { | 2557 | if (commandShell->ignErr == NULL) { | |
2558 | commandShell->ignErr = "%s\n"; | 2558 | commandShell->ignErr = "%s\n"; | |
2559 | } | 2559 | } | |
2560 | } | 2560 | } | |
2561 | 2561 | |||
2562 | /* | 2562 | /* | |
2563 | * Do not free up the words themselves, since they might be in use by the | 2563 | * Do not free up the words themselves, since they might be in use by the | |
2564 | * shell specification. | 2564 | * shell specification. | |
2565 | */ | 2565 | */ | |
2566 | free(words); | 2566 | free(words); | |
2567 | return SUCCESS; | 2567 | return TRUE; | |
2568 | } | 2568 | } | |
2569 | 2569 | |||
2570 | /*- | 2570 | /*- | |
2571 | *----------------------------------------------------------------------- | 2571 | *----------------------------------------------------------------------- | |
2572 | * JobInterrupt -- | 2572 | * JobInterrupt -- | |
2573 | * Handle the receipt of an interrupt. | 2573 | * Handle the receipt of an interrupt. | |
2574 | * | 2574 | * | |
2575 | * Input: | 2575 | * Input: | |
2576 | * runINTERRUPT Non-zero if commands for the .INTERRUPT target | 2576 | * runINTERRUPT Non-zero if commands for the .INTERRUPT target | |
2577 | * should be executed | 2577 | * should be executed | |
2578 | * signo signal received | 2578 | * signo signal received | |
2579 | * | 2579 | * | |
2580 | * Results: | 2580 | * Results: |
--- src/usr.bin/make/job.h 2020/08/27 06:18:22 1.46
+++ src/usr.bin/make/job.h 2020/08/29 12:20:17 1.47
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: job.h,v 1.46 2020/08/27 06:18:22 rillig Exp $ */ | 1 | /* $NetBSD: job.h,v 1.47 2020/08/29 12:20:17 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. | |
@@ -245,25 +245,25 @@ extern char *shellErrFlag; | @@ -245,25 +245,25 @@ extern char *shellErrFlag; | |||
245 | 245 | |||
246 | extern int jobTokensRunning; /* tokens currently "out" */ | 246 | extern int jobTokensRunning; /* tokens currently "out" */ | |
247 | extern int maxJobs; /* Max jobs we can run */ | 247 | extern int maxJobs; /* Max jobs we can run */ | |
248 | 248 | |||
249 | void Shell_Init(void); | 249 | void Shell_Init(void); | |
250 | const char *Shell_GetNewline(void); | 250 | const char *Shell_GetNewline(void); | |
251 | void Job_Touch(GNode *, Boolean); | 251 | void Job_Touch(GNode *, Boolean); | |
252 | Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...)); | 252 | Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...)); | |
253 | void Job_CatchChildren(void); | 253 | void Job_CatchChildren(void); | |
254 | void Job_CatchOutput(void); | 254 | void Job_CatchOutput(void); | |
255 | void Job_Make(GNode *); | 255 | void Job_Make(GNode *); | |
256 | void Job_Init(void); | 256 | void Job_Init(void); | |
257 | Boolean Job_Empty(void); | 257 | Boolean Job_Empty(void); | |
258 | ReturnStatus Job_ParseShell(char *); | 258 | Boolean Job_ParseShell(char *); | |
259 | int Job_Finish(void); | 259 | int Job_Finish(void); | |
260 | void Job_End(void); | 260 | void Job_End(void); | |
261 | void Job_Wait(void); | 261 | void Job_Wait(void); | |
262 | void Job_AbortAll(void); | 262 | void Job_AbortAll(void); | |
263 | void Job_TokenReturn(void); | 263 | void Job_TokenReturn(void); | |
264 | Boolean Job_TokenWithdraw(void); | 264 | Boolean Job_TokenWithdraw(void); | |
265 | void Job_ServerStart(int, int, int); | 265 | void Job_ServerStart(int, int, int); | |
266 | void Job_SetPrefix(void); | 266 | void Job_SetPrefix(void); | |
267 | Boolean Job_RunTarget(const char *, const char *); | 267 | Boolean Job_RunTarget(const char *, const char *); | |
268 | 268 | |||
269 | #endif /* MAKE_JOB_H */ | 269 | #endif /* MAKE_JOB_H */ |
--- src/usr.bin/make/make.h 2020/08/29 08:09:07 1.131
+++ src/usr.bin/make/make.h 2020/08/29 12:20:17 1.132
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: make.h,v 1.131 2020/08/29 08:09:07 rillig Exp $ */ | 1 | /* $NetBSD: make.h,v 1.132 2020/08/29 12:20:17 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. | |
@@ -142,44 +142,26 @@ typedef double Boolean; | @@ -142,44 +142,26 @@ typedef double Boolean; | |||
142 | typedef unsigned char Boolean; | 142 | typedef unsigned char Boolean; | |
143 | #define TRUE ((unsigned char)0xFF) | 143 | #define TRUE ((unsigned char)0xFF) | |
144 | #define FALSE ((unsigned char)0x00) | 144 | #define FALSE ((unsigned char)0x00) | |
145 | #else | 145 | #else | |
146 | typedef int Boolean; | 146 | typedef int Boolean; | |
147 | #endif | 147 | #endif | |
148 | #ifndef TRUE | 148 | #ifndef TRUE | |
149 | #define TRUE 1 | 149 | #define TRUE 1 | |
150 | #endif /* TRUE */ | 150 | #endif /* TRUE */ | |
151 | #ifndef FALSE | 151 | #ifndef FALSE | |
152 | #define FALSE 0 | 152 | #define FALSE 0 | |
153 | #endif /* FALSE */ | 153 | #endif /* FALSE */ | |
154 | 154 | |||
155 | /* | |||
156 | * Functions that must return a status can return a ReturnStatus to | |||
157 | * indicate success or type of failure. | |||
158 | */ | |||
159 | ||||
160 | typedef int ReturnStatus; | |||
161 | ||||
162 | /* | |||
163 | * The following statuses overlap with the first 2 generic statuses | |||
164 | * defined in status.h: | |||
165 | * | |||
166 | * SUCCESS There was no error. | |||
167 | * FAILURE There was a general error. | |||
168 | */ | |||
169 | ||||
170 | #define SUCCESS 0x00000000 | |||
171 | #define FAILURE 0x00000001 | |||
172 | ||||
173 | #include "lst.h" | 155 | #include "lst.h" | |
174 | #include "enum.h" | 156 | #include "enum.h" | |
175 | #include "hash.h" | 157 | #include "hash.h" | |
176 | #include "config.h" | 158 | #include "config.h" | |
177 | #include "buf.h" | 159 | #include "buf.h" | |
178 | #include "make_malloc.h" | 160 | #include "make_malloc.h" | |
179 | 161 | |||
180 | typedef enum { | 162 | typedef enum { | |
181 | UNMADE, /* Not examined yet */ | 163 | UNMADE, /* Not examined yet */ | |
182 | DEFERRED, /* Examined once (building child) */ | 164 | DEFERRED, /* Examined once (building child) */ | |
183 | REQUESTED, /* on toBeMade list */ | 165 | REQUESTED, /* on toBeMade list */ | |
184 | BEINGMADE, /* Target is already being made. | 166 | BEINGMADE, /* Target is already being made. | |
185 | * Indicates a cycle in the graph. */ | 167 | * Indicates a cycle in the graph. */ |
--- src/usr.bin/make/parse.c 2020/08/29 11:24:54 1.271
+++ src/usr.bin/make/parse.c 2020/08/29 12:20:17 1.272
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $ */ | 1 | /* $NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 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: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $"; | 72 | static char rcsid[] = "$NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 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[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; | 77 | static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; | |
78 | #else | 78 | #else | |
79 | __RCSID("$NetBSD: parse.c,v 1.271 2020/08/29 11:24:54 rillig Exp $"); | 79 | __RCSID("$NetBSD: parse.c,v 1.272 2020/08/29 12:20:17 rillig Exp $"); | |
80 | #endif | 80 | #endif | |
81 | #endif /* not lint */ | 81 | #endif /* not lint */ | |
82 | #endif | 82 | #endif | |
83 | 83 | |||
84 | /*- | 84 | /*- | |
85 | * parse.c -- | 85 | * parse.c -- | |
86 | * Functions to parse a makefile. | 86 | * Functions to parse a makefile. | |
87 | * | 87 | * | |
88 | * One function, Parse_Init, must be called before any functions | 88 | * One function, Parse_Init, must be called before any functions | |
89 | * in this module are used. After that, the function Parse_File is the | 89 | * in this module are used. After that, the function Parse_File is the | |
90 | * main entry point and controls most of the other functions in this | 90 | * main entry point and controls most of the other functions in this | |
91 | * module. | 91 | * module. | |
92 | * | 92 | * | |
@@ -415,54 +415,54 @@ loadedfile_nextbuf(void *x, size_t *len) | @@ -415,54 +415,54 @@ loadedfile_nextbuf(void *x, size_t *len) | |||
415 | struct loadedfile *lf = x; | 415 | struct loadedfile *lf = x; | |
416 | 416 | |||
417 | if (lf->used) { | 417 | if (lf->used) { | |
418 | return NULL; | 418 | return NULL; | |
419 | } | 419 | } | |
420 | lf->used = TRUE; | 420 | lf->used = TRUE; | |
421 | *len = lf->len; | 421 | *len = lf->len; | |
422 | return lf->buf; | 422 | return lf->buf; | |
423 | } | 423 | } | |
424 | 424 | |||
425 | /* | 425 | /* | |
426 | * Try to get the size of a file. | 426 | * Try to get the size of a file. | |
427 | */ | 427 | */ | |
428 | static ReturnStatus | 428 | static Boolean | |
429 | load_getsize(int fd, size_t *ret) | 429 | load_getsize(int fd, size_t *ret) | |
430 | { | 430 | { | |
431 | struct stat st; | 431 | struct stat st; | |
432 | 432 | |||
433 | if (fstat(fd, &st) < 0) { | 433 | if (fstat(fd, &st) < 0) { | |
434 | return FAILURE; | 434 | return FALSE; | |
435 | } | 435 | } | |
436 | 436 | |||
437 | if (!S_ISREG(st.st_mode)) { | 437 | if (!S_ISREG(st.st_mode)) { | |
438 | return FAILURE; | 438 | return FALSE; | |
439 | } | 439 | } | |
440 | 440 | |||
441 | /* | 441 | /* | |
442 | * st_size is an off_t, which is 64 bits signed; *ret is | 442 | * st_size is an off_t, which is 64 bits signed; *ret is | |
443 | * size_t, which might be 32 bits unsigned or 64 bits | 443 | * size_t, which might be 32 bits unsigned or 64 bits | |
444 | * unsigned. Rather than being elaborate, just punt on | 444 | * unsigned. Rather than being elaborate, just punt on | |
445 | * files that are more than 2^31 bytes. We should never | 445 | * files that are more than 2^31 bytes. We should never | |
446 | * see a makefile that size in practice... | 446 | * see a makefile that size in practice... | |
447 | * | 447 | * | |
448 | * While we're at it reject negative sizes too, just in case. | 448 | * While we're at it reject negative sizes too, just in case. | |
449 | */ | 449 | */ | |
450 | if (st.st_size < 0 || st.st_size > 0x7fffffff) { | 450 | if (st.st_size < 0 || st.st_size > 0x7fffffff) { | |
451 | return FAILURE; | 451 | return FALSE; | |
452 | } | 452 | } | |
453 | 453 | |||
454 | *ret = (size_t) st.st_size; | 454 | *ret = (size_t) st.st_size; | |
455 | return SUCCESS; | 455 | return TRUE; | |
456 | } | 456 | } | |
457 | 457 | |||
458 | /* | 458 | /* | |
459 | * Read in a file. | 459 | * Read in a file. | |
460 | * | 460 | * | |
461 | * Until the path search logic can be moved under here instead of | 461 | * Until the path search logic can be moved under here instead of | |
462 | * being in the caller in another source file, we need to have the fd | 462 | * being in the caller in another source file, we need to have the fd | |
463 | * passed in already open. Bleh. | 463 | * passed in already open. Bleh. | |
464 | * | 464 | * | |
465 | * If the path is NULL use stdin and (to insure against fd leaks) | 465 | * If the path is NULL use stdin and (to insure against fd leaks) | |
466 | * assert that the caller passed in -1. | 466 | * assert that the caller passed in -1. | |
467 | */ | 467 | */ | |
468 | static struct loadedfile * | 468 | static struct loadedfile * | |
@@ -479,27 +479,27 @@ loadfile(const char *path, int fd) | @@ -479,27 +479,27 @@ loadfile(const char *path, int fd) | |||
479 | assert(fd == -1); | 479 | assert(fd == -1); | |
480 | fd = STDIN_FILENO; | 480 | fd = STDIN_FILENO; | |
481 | } else { | 481 | } else { | |
482 | #if 0 /* notyet */ | 482 | #if 0 /* notyet */ | |
483 | fd = open(path, O_RDONLY); | 483 | fd = open(path, O_RDONLY); | |
484 | if (fd < 0) { | 484 | if (fd < 0) { | |
485 | ... | 485 | ... | |
486 | Error("%s: %s", path, strerror(errno)); | 486 | Error("%s: %s", path, strerror(errno)); | |
487 | exit(1); | 487 | exit(1); | |
488 | } | 488 | } | |
489 | #endif | 489 | #endif | |
490 | } | 490 | } | |
491 | 491 | |||
492 | if (load_getsize(fd, &lf->len) == SUCCESS) { | 492 | if (load_getsize(fd, &lf->len)) { | |
493 | /* found a size, try mmap */ | 493 | /* found a size, try mmap */ | |
494 | if (pagesize == 0) | 494 | if (pagesize == 0) | |
495 | pagesize = sysconf(_SC_PAGESIZE); | 495 | pagesize = sysconf(_SC_PAGESIZE); | |
496 | if (pagesize <= 0) { | 496 | if (pagesize <= 0) { | |
497 | pagesize = 0x1000; | 497 | pagesize = 0x1000; | |
498 | } | 498 | } | |
499 | /* round size up to a page */ | 499 | /* round size up to a page */ | |
500 | lf->maplen = pagesize * ((lf->len + pagesize - 1)/pagesize); | 500 | lf->maplen = pagesize * ((lf->len + pagesize - 1)/pagesize); | |
501 | 501 | |||
502 | /* | 502 | /* | |
503 | * XXX hack for dealing with empty files; remove when | 503 | * XXX hack for dealing with empty files; remove when | |
504 | * we're no longer limited by interfacing to the old | 504 | * we're no longer limited by interfacing to the old | |
505 | * logic elsewhere in this file. | 505 | * logic elsewhere in this file. | |
@@ -1243,28 +1243,28 @@ ParseDoDependency(char *line) | @@ -1243,28 +1243,28 @@ ParseDoDependency(char *line) | |||
1243 | } | 1243 | } | |
1244 | 1244 | |||
1245 | /* | 1245 | /* | |
1246 | * If the word is followed by a left parenthesis, it's the | 1246 | * If the word is followed by a left parenthesis, it's the | |
1247 | * name of an object file inside an archive (ar file). | 1247 | * name of an object file inside an archive (ar file). | |
1248 | */ | 1248 | */ | |
1249 | if (!ParseIsEscaped(lstart, cp) && *cp == LPAREN) { | 1249 | if (!ParseIsEscaped(lstart, cp) && *cp == LPAREN) { | |
1250 | /* | 1250 | /* | |
1251 | * Archives must be handled specially to make sure the OP_ARCHV | 1251 | * Archives must be handled specially to make sure the OP_ARCHV | |
1252 | * flag is set in their 'type' field, for one thing, and because | 1252 | * flag is set in their 'type' field, for one thing, and because | |
1253 | * things like "archive(file1.o file2.o file3.o)" are permissible. | 1253 | * things like "archive(file1.o file2.o file3.o)" are permissible. | |
1254 | * Arch_ParseArchive will set 'line' to be the first non-blank | 1254 | * Arch_ParseArchive will set 'line' to be the first non-blank | |
1255 | * after the archive-spec. It creates/finds nodes for the members | 1255 | * after the archive-spec. It creates/finds nodes for the members | |
1256 | * and places them on the given list, returning SUCCESS if all | 1256 | * and places them on the given list, returning TRUE if all | |
1257 | * went well and FAILURE if there was an error in the | 1257 | * went well and FALSE if there was an error in the | |
1258 | * specification. On error, line should remain untouched. | 1258 | * specification. On error, line should remain untouched. | |
1259 | */ | 1259 | */ | |
1260 | if (!Arch_ParseArchive(&line, targets, VAR_CMD)) { | 1260 | if (!Arch_ParseArchive(&line, targets, VAR_CMD)) { | |
1261 | Parse_Error(PARSE_FATAL, | 1261 | Parse_Error(PARSE_FATAL, | |
1262 | "Error in archive specification: \"%s\"", line); | 1262 | "Error in archive specification: \"%s\"", line); | |
1263 | goto out; | 1263 | goto out; | |
1264 | } else { | 1264 | } else { | |
1265 | /* Done with this word; on to the next. */ | 1265 | /* Done with this word; on to the next. */ | |
1266 | cp = line; | 1266 | cp = line; | |
1267 | continue; | 1267 | continue; | |
1268 | } | 1268 | } | |
1269 | } | 1269 | } | |
1270 | 1270 | |||
@@ -1599,27 +1599,27 @@ ParseDoDependency(char *line) | @@ -1599,27 +1599,27 @@ ParseDoDependency(char *line) | |||
1599 | #endif | 1599 | #endif | |
1600 | default: | 1600 | default: | |
1601 | break; | 1601 | break; | |
1602 | } | 1602 | } | |
1603 | } else if (specType == MFlags) { | 1603 | } else if (specType == MFlags) { | |
1604 | /* | 1604 | /* | |
1605 | * Call on functions in main.c to deal with these arguments and | 1605 | * Call on functions in main.c to deal with these arguments and | |
1606 | * set the initial character to a null-character so the loop to | 1606 | * set the initial character to a null-character so the loop to | |
1607 | * get sources won't get anything | 1607 | * get sources won't get anything | |
1608 | */ | 1608 | */ | |
1609 | Main_ParseArgLine(line); | 1609 | Main_ParseArgLine(line); | |
1610 | *line = '\0'; | 1610 | *line = '\0'; | |
1611 | } else if (specType == ExShell) { | 1611 | } else if (specType == ExShell) { | |
1612 | if (Job_ParseShell(line) != SUCCESS) { | 1612 | if (!Job_ParseShell(line)) { | |
1613 | Parse_Error(PARSE_FATAL, "improper shell specification"); | 1613 | Parse_Error(PARSE_FATAL, "improper shell specification"); | |
1614 | goto out; | 1614 | goto out; | |
1615 | } | 1615 | } | |
1616 | *line = '\0'; | 1616 | *line = '\0'; | |
1617 | } else if (specType == NotParallel || specType == SingleShell || | 1617 | } else if (specType == NotParallel || specType == SingleShell || | |
1618 | specType == DeleteOnError) { | 1618 | specType == DeleteOnError) { | |
1619 | *line = '\0'; | 1619 | *line = '\0'; | |
1620 | } | 1620 | } | |
1621 | 1621 | |||
1622 | /* | 1622 | /* | |
1623 | * NOW GO FOR THE SOURCES | 1623 | * NOW GO FOR THE SOURCES | |
1624 | */ | 1624 | */ | |
1625 | if (specType == Suffixes || specType == ExPath || | 1625 | if (specType == Suffixes || specType == ExPath || |