Module Name:    src
Committed By:   rillig
Date:           Sat Aug 29 07:52:56 UTC 2020

Modified Files:
        src/usr.bin/make: main.c make.h nonints.h parse.c str.c var.c

Log Message:
make(1): allow for strict type checking for Boolean

Having Boolean aliased to int creates ambiguities since int is widely
used.  Allow to occasionally compile make with -DUSE_DOUBLE_BOOLEAN to
check that the type definitions still agree.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 src/usr.bin/make/main.c
cvs rdiff -u -r1.129 -r1.130 src/usr.bin/make/make.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/parse.c
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/make/str.c
cvs rdiff -u -r1.472 -r1.473 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.322 src/usr.bin/make/main.c:1.323
--- src/usr.bin/make/main.c:1.322	Sat Aug 29 07:13:17 2020
+++ src/usr.bin/make/main.c	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.322 2020/08/29 07:13:17 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.323 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.322 2020/08/29 07:13:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.323 2020/08/29 07:52:55 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.322 2020/08/29 07:13:17 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.323 2020/08/29 07:52:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1399,8 +1399,9 @@ main(int argc, char **argv)
 	if (!compatMake)
 	    Job_ServerStart(maxJobTokens, jp_0, jp_1);
 	if (DEBUG(JOB))
-	    fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
-		jp_0, jp_1, maxJobs, maxJobTokens, compatMake);
+	    fprintf(debug_file,
+		    "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
+		    jp_0, jp_1, maxJobs, maxJobTokens, compatMake ? 1 : 0);
 
 	if (!printVars)
 	    Main_ExportMAKEFLAGS(TRUE);	/* initial export */

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.129 src/usr.bin/make/make.h:1.130
--- src/usr.bin/make/make.h:1.129	Fri Aug 28 19:14:07 2020
+++ src/usr.bin/make/make.h	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.129 2020/08/28 19:14:07 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.130 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -133,7 +133,11 @@
  * boolean argument to be an expression that isn't strictly 0 or 1 valued.
  */
 
+#ifdef USE_DOUBLE_BOOLEAN	/* Just to find type mismatches. */
+typedef double Boolean;
+#else
 typedef int Boolean;
+#endif
 #ifndef TRUE
 #define TRUE	1
 #endif /* TRUE */

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.99 src/usr.bin/make/nonints.h:1.100
--- src/usr.bin/make/nonints.h:1.99	Thu Aug 27 06:13:53 2020
+++ src/usr.bin/make/nonints.h	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.99 2020/08/27 06:13:53 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.100 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -82,7 +82,7 @@ void Arch_FindLib(GNode *, Lst);
 Boolean Arch_LibOODate(GNode *);
 void Arch_Init(void);
 void Arch_End(void);
-int Arch_IsLib(GNode *);
+Boolean Arch_IsLib(GNode *);
 
 /* compat.c */
 int CompatRunCommand(void *, void *);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.268 src/usr.bin/make/parse.c:1.269
--- src/usr.bin/make/parse.c:1.268	Fri Aug 28 04:48:57 2020
+++ src/usr.bin/make/parse.c	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.268 2020/08/28 04:48:57 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.268 2020/08/28 04:48:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.268 2020/08/28 04:48:57 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.269 2020/08/29 07:52:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2541,7 +2541,7 @@ IsInclude(const char *line, Boolean sysv
 	static const size_t inclen = sizeof(inc) - 1;
 
 	/* 'd' is not valid for sysv */
-	int o = strchr(&("ds-"[sysv]), *line) != NULL;
+	int o = strchr(sysv ? "s-" : "ds-", *line) != NULL;
 
 	if (strncmp(line + o, inc, inclen) != 0)
 		return FALSE;

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.62 src/usr.bin/make/str.c:1.63
--- src/usr.bin/make/str.c:1.62	Sun Aug 23 18:26:35 2020
+++ src/usr.bin/make/str.c	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.62 2020/08/23 18:26:35 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.63 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.62 2020/08/23 18:26:35 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.63 2020/08/29 07:52:55 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char     sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.62 2020/08/23 18:26:35 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.63 2020/08/29 07:52:55 rillig Exp $");
 #endif
 #endif				/* not lint */
 #endif
@@ -383,7 +383,7 @@ Str_Match(const char *str, const char *p
 		 */
 		if (*pat == '[') {
 			Boolean neg = pat[1] == '^';
-			pat += 1 + neg;
+			pat += neg ? 2 : 1;
 
 			for (;;) {
 				if (*pat == ']' || *pat == 0) {

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.472 src/usr.bin/make/var.c:1.473
--- src/usr.bin/make/var.c:1.472	Tue Aug 25 21:16:53 2020
+++ src/usr.bin/make/var.c	Sat Aug 29 07:52:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.472 2020/08/25 21:16:53 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.473 2020/08/29 07:52:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.472 2020/08/25 21:16:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.473 2020/08/29 07:52:55 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.472 2020/08/25 21:16:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.473 2020/08/29 07:52:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3409,6 +3409,12 @@ Var_Parse(const char * const str, GNode 
     extramodifiers = NULL;	/* extra modifiers to apply first */
     dynamic = FALSE;
 
+#ifdef USE_DOUBLE_BOOLEAN
+    /* Appease GCC 5.5.0, which thinks that the variable might not be
+     * initialized. */
+    endc = '\0';
+#endif
+
     startc = str[1];
     if (startc != PROPEN && startc != BROPEN) {
 	char name[2];

Reply via email to