• no longer use <stdbool.h> even if it’s available
• ensure that bool/true/false are cpp macros, overriding any pre-defined • document the requirement that tobool(x) must map any-type 'x' into bool • document the requirement that a bool must only be true or false, and that it (tobool() rather) must have an identity mapping to 'short' • possibly fix ksh_func for/and fpFUNCTf – maybe spotted by cnuke@
This commit is contained in:
35
sh.h
35
sh.h
@@ -68,9 +68,6 @@
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#if HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@@ -154,7 +151,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.459 2011/04/09 14:58:53 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.460 2011/04/09 15:14:53 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R39 2011/04/01"
|
||||
|
||||
@@ -185,20 +182,6 @@ typedef long rlim_t;
|
||||
typedef void (*sig_t)(int);
|
||||
#endif
|
||||
|
||||
#if !HAVE_STDBOOL_H
|
||||
/* kludge, but enough for mksh */
|
||||
typedef unsigned char mksh_bool;
|
||||
#define bool mksh_bool
|
||||
#define false 0
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
/* choose the one that is optimised on most platforms? */
|
||||
#define tobool(cond) ((cond) ? true : false)
|
||||
/*#define tobool(cond) (!!(cond))*/
|
||||
/* the following only with <stdbool.h> and even then sometimes buggy */
|
||||
/*#define tobool(cond) ((bool)(cond))*/
|
||||
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
#if !HAVE_CAN_UCBINTS
|
||||
typedef signed int int32_t;
|
||||
@@ -367,6 +350,19 @@ typedef int32_t Tflag;
|
||||
typedef int32_t mksh_ari_t;
|
||||
typedef uint32_t mksh_uari_t;
|
||||
|
||||
/* boolean type (no <stdbool.h> deliberately) */
|
||||
typedef unsigned char mksh_bool;
|
||||
#undef bool
|
||||
#undef false
|
||||
#undef true
|
||||
/* access macros for boolean type */
|
||||
#define bool mksh_bool
|
||||
/* values must have identity mapping between mksh_bool and short */
|
||||
#define false 0
|
||||
#define true 1
|
||||
/* make any-type into bool or short */
|
||||
#define tobool(cond) ((cond) ? true : false)
|
||||
|
||||
/* these shall be smaller than 100 */
|
||||
#ifdef MKSH_CONSERVATIVE_FDS
|
||||
#define NUFILE 32 /* Number of user-accessible files */
|
||||
@@ -1115,7 +1111,8 @@ struct op {
|
||||
*/
|
||||
int lineno; /* TCOM/TFUNC: LINENO for this */
|
||||
short type; /* operation type, see below */
|
||||
union { /* WARNING: newtp(), tcopy() use evalflags = 0 to clear union */
|
||||
union {
|
||||
/* WARNING: newtp(), tcopy() use evalflags = 0 to clear union */
|
||||
short evalflags; /* TCOM: arg expansion eval() flags */
|
||||
short ksh_func; /* TFUNC: function x (vs x()) */
|
||||
} u;
|
||||
|
Reference in New Issue
Block a user