From dff64f3b718f058b7056c48ed748f7068c7585db Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 12 Jun 2019 21:37:15 +0100 Subject: [PATCH] wmail: use stdbool.h if available. --- wmail/configure.ac | 1 + wmail/src/common.h | 19 ++++++++++++++----- wmail/src/config.c | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/wmail/configure.ac b/wmail/configure.ac index 644b9d0..5d79797 100644 --- a/wmail/configure.ac +++ b/wmail/configure.ac @@ -14,6 +14,7 @@ PKG_CHECK_MODULES([dockapp], [dockapp]) dnl Checks for header files. AC_HEADER_DIRENT +AC_HEADER_STDBOOL AC_HEADER_STDC AC_CHECK_HEADERS([limits.h strings.h sys/time.h]) CPPFLAGS_old="$CPPFLAGS" diff --git a/wmail/src/common.h b/wmail/src/common.h index 02385c8..af3a49b 100644 --- a/wmail/src/common.h +++ b/wmail/src/common.h @@ -59,11 +59,20 @@ /////////////////////////////////////////////////////////////////////////////// // typedefs -#if !defined(__cplusplus) && !defined(c_plusplus) -typedef enum { - false = 0, - true = 1 -} bool; +#ifdef HAVE_STDBOOL_H +# include +#else +# ifndef HAVE__BOOL +# ifdef __cplusplus +typedef bool _Bool; +# else +# define _Bool signed char +# endif +# endif +# define bool _Bool +# define false 0 +# define true 1 +# define __bool_true_false_are_defined 1 #endif diff --git a/wmail/src/config.c b/wmail/src/config.c index 6a523b9..023869a 100644 --- a/wmail/src/config.c +++ b/wmail/src/config.c @@ -497,7 +497,7 @@ static bool ReadEnum( const char *from, unsigned int line, int *to, static bool IsWhiteSpace( const char *chr ) { - return ( chr != NULL && ( *chr == ' ' || *chr == '\t' || *chr == '\n' )) ? true : false; + return chr != NULL && ( *chr == ' ' || *chr == '\t' || *chr == '\n' ); } static const char *SkipWhiteSpaces( const char *str ) -- 2.11.4.GIT