Sat Aug 29 08:09:07 2020 UTC ()
make(1): add another Boolean variant to check during development


(rillig)
diff -r1.132 -r1.133 src/usr.bin/make/compat.c
diff -r1.130 -r1.131 src/usr.bin/make/make.h

cvs diff -r1.132 -r1.133 src/usr.bin/make/compat.c (expand / switch to unified diff)

--- src/usr.bin/make/compat.c 2020/08/28 04:48:56 1.132
+++ src/usr.bin/make/compat.c 2020/08/29 08:09:07 1.133
@@ -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
73static char rcsid[] = "$NetBSD: compat.c,v 1.132 2020/08/28 04:48:56 rillig Exp $"; 73static 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
78static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; 78static 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 /*

cvs diff -r1.130 -r1.131 src/usr.bin/make/make.h (expand / switch to unified diff)

--- src/usr.bin/make/make.h 2020/08/29 07:52:55 1.130
+++ src/usr.bin/make/make.h 2020/08/29 08:09:07 1.131
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make.h,v 1.130 2020/08/29 07:52:55 rillig Exp $ */ 1/* $NetBSD: make.h,v 1.131 2020/08/29 08:09:07 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.
@@ -123,28 +123,35 @@ @@ -123,28 +123,35 @@
123 123
124#if MAKE_GNUC_PREREQ(2, 7) 124#if MAKE_GNUC_PREREQ(2, 7)
125#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ 125#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
126 __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 126 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
127#else 127#else
128#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ 128#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
129#endif 129#endif
130 130
131/* 131/*
132 * A boolean type is defined as an integer, not an enum. This allows a 132 * A boolean type is defined as an integer, not an enum. This allows a
133 * boolean argument to be an expression that isn't strictly 0 or 1 valued. 133 * boolean argument to be an expression that isn't strictly 0 or 1 valued.
134 */ 134 */
135 135
136#ifdef USE_DOUBLE_BOOLEAN /* Just to find type mismatches. */ 136#ifdef USE_DOUBLE_BOOLEAN
 137/* During development, to find type mismatches in function declarations. */
137typedef double Boolean; 138typedef double Boolean;
 139#elif defined(USE_UCHAR_BOOLEAN)
 140/* During development, to find code that depends on the exact value of TRUE or
 141 * that stores other values in Boolean variables. */
 142typedef unsigned char Boolean;
 143#define TRUE ((unsigned char)0xFF)
 144#define FALSE ((unsigned char)0x00)
138#else 145#else
139typedef int Boolean; 146typedef int Boolean;
140#endif 147#endif
141#ifndef TRUE 148#ifndef TRUE
142#define TRUE 1 149#define TRUE 1
143#endif /* TRUE */ 150#endif /* TRUE */
144#ifndef FALSE 151#ifndef FALSE
145#define FALSE 0 152#define FALSE 0
146#endif /* FALSE */ 153#endif /* FALSE */
147 154
148/* 155/*
149 * Functions that must return a status can return a ReturnStatus to 156 * Functions that must return a status can return a ReturnStatus to
150 * indicate success or type of failure. 157 * indicate success or type of failure.