Skip to content

Commit 25e267a

Browse files
author
Nicholas Reed
committed
Replaced basic.h's Boolean/True/False with bool/true/false via stdbool.h or else scl_stdbool.h. Includes changes from SCL git e40cbca and 71bd7b2. Honest attempts made to ensure all affected symbols were actually being used as real booleans (as opposed to sdaiEnum.h's trinary Boolean type).
1 parent 6443546 commit 25e267a

23 files changed

Lines changed: 244 additions & 189 deletions

include/exppp/exppp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ extern int exppp_continuation_indent; /* default nesting indent for */
66
extern int exppp_linelength; /* leave some slop for closing */
77
/* parens. \n is not included in */
88
/* this count either */
9-
extern int exppp_rmpp; /* if true, create rmpp */
10-
extern int exppp_alphabetize; /* if true, alphabetize */
11-
extern int exppp_terse; /* don't describe action to stdout */
12-
extern int exppp_reference_info; /* if true, add commentary */
9+
extern bool exppp_rmpp; /* if true, create rmpp */
10+
extern bool exppp_alphabetize; /* if true, alphabetize */
11+
extern bool exppp_terse; /* don't describe action to stdout */
12+
extern bool exppp_reference_info; /* if true, add commentary */
1313
/* about where things came from */
14-
extern int exppp_preserve_comments; /* if true, preserve comments where */
14+
extern bool exppp_preserve_comments; /* if true, preserve comments where */
1515
/* possible */
1616
extern char * exppp_output_filename; /* force output filename */
17-
extern int exppp_output_filename_reset; /* if true, force output filename */
17+
extern bool exppp_output_filename_reset; /* if true, force output filename */
1818

1919
void EXPRESSout( Express e );
2020

include/express/basic.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@
7878
/* type Boolean and constants */
7979
/******************************/
8080

81-
typedef enum Boolean_ { False, True} Boolean;
81+
#ifdef HAVE_STDBOOL_H
82+
# include <stdbool.h>
83+
#else
84+
# include <scl_stdbool.h>
85+
#endif
8286

8387
/************************/
8488
/* Generic pointer type */

include/express/entity.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct Entity_ {
100100
Linked_List instances; /* hook for applications */
101101
int mark; /* usual hack - prevent traversing sub/super */
102102
/* graph twice */
103-
Boolean abstract;/* is this an abstract supertype? */
103+
bool abstract;/* is this an abstract supertype? */
104104
Type type; /* type pointing back to ourself */
105105
/* Useful to have when evaluating */
106106
/* expressions involving entities */
@@ -155,10 +155,10 @@ extern struct Scope_ * ENTITYcopy PROTO( ( struct Scope_ * ) );
155155
extern Entity ENTITYfind_inherited_entity PROTO( ( struct Scope_ *, char *, int ) );
156156
extern Variable ENTITYfind_inherited_attribute PROTO( ( struct Scope_ *, char *, struct Symbol_ ** ) );
157157
extern Variable ENTITYresolve_attr_ref PROTO( ( Entity, Symbol *, Symbol * ) );
158-
extern Boolean ENTITYhas_immediate_supertype PROTO( ( Entity, Entity ) );
158+
extern bool ENTITYhas_immediate_supertype PROTO( ( Entity, Entity ) );
159159
extern Variable ENTITYget_named_attribute PROTO( ( Entity, char * ) );
160160
extern Linked_List ENTITYget_all_attributes PROTO( ( Entity ) );
161-
extern Boolean ENTITYhas_supertype PROTO( ( Entity, Entity ) );
161+
extern bool ENTITYhas_supertype PROTO( ( Entity, Entity ) );
162162
extern void ENTITYadd_instance PROTO( ( Entity, Generic ) );
163163
extern int ENTITYget_initial_offset PROTO( ( Entity ) );
164164
extern int ENTITYdeclares_variable PROTO( ( Entity, struct Variable_ * ) );

include/express/error.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef enum {
6464
/***************************/
6565

6666
typedef struct Error_ {
67-
Boolean enabled;
67+
bool enabled;
6868
Severity severity;
6969
char * message;
7070
} * Error;
@@ -82,11 +82,11 @@ typedef struct Error_Warning_ {
8282
/* global variables */
8383
/********************/
8484

85-
extern Boolean __ERROR_buffer_errors;
85+
extern bool __ERROR_buffer_errors;
8686
extern char * current_filename;
8787

8888
/* flag to remember whether non-warning errors have occurred */
89-
extern Boolean ERRORoccurred;
89+
extern bool ERRORoccurred;
9090

9191

9292
extern Error experrc;
@@ -122,27 +122,27 @@ static_inline
122122
void
123123
ERRORdisable( Error error ) {
124124
if( error != ERROR_none ) {
125-
error->enabled = False;
125+
error->enabled = false;
126126
}
127127
}
128128

129129
static_inline
130130
void
131131
ERRORenable( Error error ) {
132132
if( error != ERROR_none ) {
133-
error->enabled = True;
133+
error->enabled = true;
134134
}
135135
}
136136

137137
static_inline
138-
Boolean
138+
bool
139139
ERRORis_enabled( Error error ) {
140140
return error->enabled;
141141
}
142142

143143
static_inline
144144
void
145-
ERRORbuffer_messages( Boolean flag ) {
145+
ERRORbuffer_messages( bool flag ) {
146146
extern void ERROR_start_message_buffer( void ),
147147
ERROR_flush_message_buffer( void );
148148

@@ -181,7 +181,7 @@ extern void ERRORreport PROTO( ( Error, ... ) );
181181
struct Symbol_; /* mention Symbol to avoid warning on following line */
182182
extern void ERRORreport_with_symbol PROTO( ( Error, struct Symbol_ *, ... ) );
183183
extern void ERRORreport_with_line PROTO( ( Error, int, ... ) );
184-
extern void ERRORbuffer_messages PROTO( ( Boolean ) );
184+
extern void ERRORbuffer_messages PROTO( ( bool ) );
185185
extern void ERRORflush_messages PROTO( ( void ) );
186186

187187
extern void ERROR_start_message_buffer PROTO( ( void ) );
@@ -196,7 +196,7 @@ extern void ERRORunsafe PROTO( ( void ) );
196196
#if deprecated
197197
extern void ERRORdisable PROTO( ( Error ) );
198198
extern void ERRORenable PROTO( ( Error ) );
199-
extern Boolean ERRORis_enabled PROTO( ( Error ) );
199+
extern bool ERRORis_enabled PROTO( ( Error ) );
200200
#endif
201201

202202
#endif /* ERROR_H */

include/express/expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ union expr_union {
149149
char * attribute; /* inverse .... for 'attr' */
150150
char * binary;
151151
int logical;
152-
Boolean boolean;
152+
bool boolean;
153153
struct Query_ * query;
154154
struct Funcall funcall;
155155

include/express/express.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extern void ( *EXPRESSbackend ) PROTO( ( Express ) );
101101
extern char * EXPRESSprogram_name;
102102
extern char EXPRESSgetopt_options[]; /* initialized elsewhere */
103103
extern int ( *EXPRESSgetopt ) PROTO( ( int, char * ) );
104-
extern int EXPRESSignore_duplicate_schemas;
104+
extern bool EXPRESSignore_duplicate_schemas;
105105

106106
extern Dictionary EXPRESSbuiltins; /* procedures/functions */
107107

include/express/lexact.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct Scan_Buffer {
6060
char * savedPos;
6161
FILE * file;
6262
char * filename;
63-
Boolean readEof;
63+
bool readEof;
6464
int lineno;
6565
int bol;
6666
} Scan_Buffer;
@@ -110,7 +110,7 @@ extern int SCANprocess_string PROTO( ( const char * ) );
110110
extern int SCANprocess_encoded_string PROTO( ( const char * ) );
111111
extern int SCANprocess_semicolon PROTO( ( const char *, int ) );
112112
extern void SCANsave_comment PROTO( ( const char * ) );
113-
extern Boolean SCANread PROTO( ( void ) );
113+
extern bool SCANread PROTO( ( void ) );
114114
#if macros_bit_the_dust
115115
extern void SCANdefine_macro PROTO( ( char *, char * ) );
116116
#endif

include/express/type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ extern TypeBody TYPEBODYcreate PROTO( ( enum type_enum ) );
342342
/*extern Type TYPEcopy_shallow PROTO((Type));*/
343343
extern void TYPEinitialize PROTO( ( void ) );
344344

345-
extern Boolean TYPEinherits_from PROTO( ( Type, enum type_enum ) );
345+
extern bool TYPEinherits_from PROTO( ( Type, enum type_enum ) );
346346
extern Type TYPEget_nonaggregate_base_type PROTO( ( Type ) );
347347

348348
extern Type TYPEcreate_user_defined_type PROTO( ( Type, Scope, struct Symbol_ * ) );

include/scl_stdbool.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#ifndef STDBOOL_H_
2+
#define STDBOOL_H_
3+
4+
/**
5+
* stdbool.h - ISO C99 Boolean type
6+
* Author - Bill Chatfield
7+
* E-mail - bill underscore chatfield at yahoo dot com
8+
* Copyright - You are free to use for any purpose except illegal acts
9+
* Warrenty - None: don't blame me if it breaks something
10+
*
11+
* In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but
12+
* some compilers don't offer these yet. This header file is an
13+
* implementation of the standard ISO C99 stdbool.h header file. It checks
14+
* for various compiler versions and defines things that are missing in
15+
* those versions.
16+
*
17+
* The GNU and Watcom compilers include a stdbool.h, but the Borland
18+
* C/C++ 5.5.1 compiler and the Microsoft compilers do not.
19+
*
20+
* See http://predef.sourceforge.net/precomp.html for compile macros.
21+
*/
22+
23+
#ifndef __cplusplus
24+
25+
/**
26+
* Borland C++ 5.5.1 does not define _Bool.
27+
*/
28+
#if defined(__BORLANDC__) && __BORLANDC__ < 0x630
29+
typedef int _Bool;
30+
#endif
31+
32+
/**
33+
* Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005,
34+
* and version 15.00.30729.01, which comes with Visual C++ 2008, do not
35+
* define _Bool.
36+
*/
37+
#if defined(_MSC_VER)
38+
typedef int _Bool;
39+
#endif
40+
41+
/**
42+
* Define the Boolean macros only if they are not already defined.
43+
*/
44+
#ifndef __bool_true_false_are_defined
45+
#define bool _Bool
46+
#define false 0
47+
#define true 1
48+
#define __bool_true_false_are_defined 1
49+
#endif
50+
51+
#endif /* __cplusplus */
52+
53+
#endif /*STDBOOL_H_*/

src/exppp/exppp-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ exppp_usage() {
3131

3232
int Handle_Exppp_Args( int i, char * arg ) {
3333
if( ( ( char )i == 'a' ) || ( ( char )i == 'A' ) ) {
34-
exppp_alphabetize = True;
34+
exppp_alphabetize = true;
3535
} else {
36-
exppp_alphabetize = False;
36+
exppp_alphabetize = false;
3737
}
3838
return 0;
3939
}

0 commit comments

Comments
 (0)