Module Name:    src
Committed By:   rillig
Date:           Wed Sep  2 23:42:58 UTC 2020

Modified Files:
        src/usr.bin/make: make.h

Log Message:
make(1): document the value restrictions for Boolean variables

The previous lenient rule came from the sprite.h header that was not
specific to make.  To avoid confusion, only the expected values should
be stored in a Boolean variable.  To help find obvious violations and
inconsistencies, there are different possibilities for the Boolean type,
during development.

In C there is no way to actually enforce this restriction at runtime.
It would be possible in C++, but the code is not ready to be compiled
with a C++ compiler.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/make/make.h

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/make.h
diff -u src/usr.bin/make/make.h:1.136 src/usr.bin/make/make.h:1.137
--- src/usr.bin/make/make.h:1.136	Wed Sep  2 04:08:54 2020
+++ src/usr.bin/make/make.h	Wed Sep  2 23:42:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.136 2020/09/02 04:08:54 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.137 2020/09/02 23:42:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,8 +130,8 @@
 #endif
 
 /*
- * A boolean type is defined as an integer, not an enum. This allows a
- * boolean argument to be an expression that isn't strictly 0 or 1 valued.
+ * A boolean type is defined as an integer, not an enum, for historic reasons.
+ * The only allowed values are the constants TRUE and FALSE (1 and 0).
  */
 
 #ifdef USE_DOUBLE_BOOLEAN
@@ -143,6 +143,8 @@ typedef double Boolean;
 typedef unsigned char Boolean;
 #define TRUE ((unsigned char)0xFF)
 #define FALSE ((unsigned char)0x00)
+#elif defined(USE_ENUM_BOOLEAN)
+typedef enum { FALSE, TRUE} Boolean;
 #else
 typedef int Boolean;
 #endif

Reply via email to