From b0aa949ad54b98fc671d552eb5335c210dd23e0e Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Sat, 19 Aug 2023 22:02:16 -0700 Subject: [PATCH] simplify booleans when header file is missing --- bool.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bool.h b/bool.h index e14a71d..1b0ee7c 100644 --- a/bool.h +++ b/bool.h @@ -39,29 +39,25 @@ /* * standard truth :-) */ -#if !defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#if !defined(HAVE_STDBOOL_H) -/* have a C99 compiler - we should have , true, false */ - -#elif !defined(__cplusplus) - -/* do not have a C99 compiler - fake a header file */ -typedef unsigned char bool; +/* fake a header file */ +typedef unsigned char bool; /* fake boolean value */ #undef true #define true ((bool)(1)) #undef false #define false ((bool)(0)) -#endif /* standard truth :-) */ +#endif /* !HAVE_STDBOOL_H */ /* * calc historic booleans */ #undef TRUE -#define TRUE ((bool) true) +#define TRUE (true) #undef FALSE -#define FALSE ((bool) false) +#define FALSE (false) #undef BOOL #define BOOL bool @@ -78,7 +74,7 @@ typedef unsigned char bool; * strtobool - convert a string to a boolean */ #if !defined(strtobool) -#define strtobool(x) ((bool) ((x) != NULL && !strcmp((x), "true"))) +#define strtobool(x) ((bool) ((x) != NULL && strcmp((x), "true") == 0)) #endif