From b5d76acd280040f50f02470762c12e39b49751f6 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sat, 29 Dec 2018 08:55:02 -0500 Subject: [PATCH] Use stdbool.h to define bool, in C99 and later; allow it to be included before curses.h; redundantly-named section headers. --- curses.h | 61 ++++++++++++++++++++++++++++----------------------- man/MANUAL.md | 4 ++-- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/curses.h b/curses.h index f5ab8c91..0444d00e 100644 --- a/curses.h +++ b/curses.h @@ -46,6 +46,11 @@ PDCurses portable platform definitions list: # include #endif +#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ + !defined(__bool_true_false_are_defined) +# include +#endif + #ifdef __cplusplus extern "C" { @@ -54,33 +59,35 @@ extern "C" /*---------------------------------------------------------------------- * - * PDCurses Manifest Constants + * Constants and Types * */ -#ifndef FALSE +#undef FALSE +#undef TRUE + +#ifdef __bool_true_false_are_defined + +# define FALSE false +# define TRUE true + +#else + +typedef unsigned char bool; + # define FALSE 0 -#endif -#ifndef TRUE # define TRUE 1 -#endif -#ifndef NULL -# define NULL (void *)0 -#endif -#ifndef ERR -# define ERR (-1) -#endif -#ifndef OK -# define OK 0 + #endif -/*---------------------------------------------------------------------- - * - * PDCurses Type Declarations - * - */ +#undef NULL +#define NULL (void *)0 -typedef unsigned char bool; /* PDCurses Boolean type */ +#undef ERR +#define ERR (-1) + +#undef OK +#define OK 0 #if _LP64 typedef unsigned int chtype; @@ -96,7 +103,7 @@ typedef chtype attr_t; /*---------------------------------------------------------------------- * - * PDCurses Mouse Interface -- SYSVR4, with extensions + * Mouse Interface -- SYSVR4, with extensions * */ @@ -233,7 +240,7 @@ typedef struct /*---------------------------------------------------------------------- * - * PDCurses Structure Definitions + * Window and Screen Structures * */ @@ -326,7 +333,7 @@ typedef struct /*---------------------------------------------------------------------- * - * PDCurses External Variables + * External Variables * */ @@ -354,8 +361,8 @@ PDCEX char ttytype[]; /* terminal name/description */ /*man-start************************************************************** -PDCurses Text Attributes -======================== +Text Attributes +=============== PDCurses uses a long (32 bits) for its chtype, as in System V. @@ -573,8 +580,8 @@ bits for character data. /*---------------------------------------------------------------------- * - * Function and Keypad Key Definitions. - * Many are just for compatibility. + * Function and Keypad Key Definitions + * Many are just for compatibility * */ @@ -829,7 +836,7 @@ bits for character data. /*---------------------------------------------------------------------- * - * PDCurses Function Declarations + * Functions * */ diff --git a/man/MANUAL.md b/man/MANUAL.md index cdaf0fa9..a7480e0b 100644 --- a/man/MANUAL.md +++ b/man/MANUAL.md @@ -24,8 +24,8 @@ PDCurses portable platform definitions list: -------------------------------------------------------------------------- -PDCurses Text Attributes -======================== +Text Attributes +=============== PDCurses uses a long (32 bits) for its chtype, as in System V.