Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): document the value restrictions for Bo...
details: https://anonhg.NetBSD.org/src/rev/8a01de8548c5
branches: trunk
changeset: 943417:8a01de8548c5
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Sep 02 23:42:58 2020 +0000
description:
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.
diffstat:
usr.bin/make/make.h | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (29 lines):
diff -r 43523fac41cd -r 8a01de8548c5 usr.bin/make/make.h
--- a/usr.bin/make/make.h Wed Sep 02 23:38:11 2020 +0000
+++ b/usr.bin/make/make.h Wed Sep 02 23:42:58 2020 +0000
@@ -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 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
Home |
Main Index |
Thread Index |
Old Index