From: Eric S. Raymond Date: Wed, 1 Sep 2010 22:34:24 +0000 (-0400) Subject: Use real bools everywhere. X-Git-Tag: 0.29~72 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=9fd2684bd82bc16579010a3983a0cc5ef4dba852;p=intercal.git Use real bools everywhere. It's possible to emulate the C99 bool type perfectly and autoconfigure doing so. This enables splint to do better checking, and looks cleaner too. make check and make distcheck both pass. --- diff --git a/buildaux/Makefile.am b/buildaux/Makefile.am index fdf4fa1..b926d10 100644 --- a/buildaux/Makefile.am +++ b/buildaux/Makefile.am @@ -42,6 +42,8 @@ fiddle.h : src/fiddle.h $(LN_S) `test -f 'src/fiddle.h' || echo '$(srcdir)/'`src/fiddle.h fiddle.h abcess.h : src/abcess.h $(LN_S) `test -f 'src/abcess.h' || echo '$(srcdir)/'`src/abcess.h abcess.h +ick_bool.h : src/ick_bool.h + $(LN_S) `test -f 'src/ick_bool.h' || echo '$(srcdir)/'`src/ick_bool.h ick_bool.h yuk.h : src/yuk.h $(LN_S) `test -f 'src/ick-ec.h' || echo '$(srcdir)/'`src/yuk.h yuk.h ick_LDADD = libidiot.a @@ -50,8 +52,8 @@ AM_YFLAGS = -d # create symlinks used by ick to find files if it's run without first being # installed. BUILT_SOURCES = parser.h ick-wrap.c pickwrap.c syslib.i syslib3.3i syslib4.4i \ - syslib5.5i syslib6.6i syslib7.7i floatlib.i ick_ec.h fiddle.h abcess.h \ - ick_lose.h yuk.h + syslib5.5i syslib6.6i syslib7.7i floatlib.i \ + ick_ec.h fiddle.h abcess.h ick_bool.h ick_lose.h yuk.h noinst_LIBRARIES = libidiot.a libidiot_a_SOURCES = src/idiotism.oil libidiot.a: src/idiotism.oil oil$(EXEEXT) src/oil.h src/sizes.h src/ick.h \ @@ -103,7 +105,7 @@ latin1.o: bin2c$(EXEEXT_FOR_BUILD) src/latin1.bin $(COMPILE) -c latin1.c ickinclude_HEADERS = src/ick_ec.h src/fiddle.h src/abcess.h src/ick_lose.h \ - src/yuk.h + src/yuk.h src/ick_bool.h nodist_ickinclude_HEADERS = config.h dist_ickdata_DATA = src/atari.bin src/baudot.bin src/ebcdic.bin src/latin1.bin \ src/ick-wrap.c src/pickwrap.c COPYING diff --git a/src/abcess.h b/src/abcess.h index 93844ea..92e0686 100644 --- a/src/abcess.h +++ b/src/abcess.h @@ -10,18 +10,26 @@ #include #include -#ifndef ICKBOOL_DEFINED +/* + * Duplicates contents of ick_bool.h. Someday maybe we'll install this + * and avoid such grottiness. + */ /*@-redef@*/ -typedef int ick_bool; -/*@=redef@*/ -#define ICKBOOL_DEFINED +#ifdef __STDC_VERSION__ +#if __STDC_VERSION__ >= 199901L +#include +#endif +#endif +#ifndef __bool_true_false_are_defined +typedef int bool; +#define true 1 +#define false 0 +#define __bool_true_false_are_defined 1 #endif +/*@=redef@*/ #define ICK_ABCESS_H_INCLUDED -#define ick_TRUE 1 -#define ick_FALSE 0 - #define ick_ONESPOT 0 #define ick_TWOSPOT 1 #define ick_TAIL 2 @@ -78,12 +86,12 @@ extern void ick_pushnext(unsigned n); extern unsigned int ick_popnext(unsigned n); extern unsigned int ick_resume(unsigned n); extern unsigned int ick_pin(void); -extern void ick_clockface(ick_bool mode); -extern void ick_setclcsemantics(ick_bool mode); /* AIS */ +extern void ick_clockface(bool mode); +extern void ick_setclcsemantics(bool mode); /* AIS */ extern void ick_pout(unsigned int val); -extern void ick_binin(unsigned int type, ick_array *a, ick_bool forget); +extern void ick_binin(unsigned int type, ick_array *a, bool forget); extern void ick_binout(unsigned int type, const ick_array *a); -extern unsigned int ick_assign(char *dest, unsigned int type, ick_bool forget, +extern unsigned int ick_assign(char *dest, unsigned int type, bool forget, unsigned int value); /* AIS: yuk, unravel and ick_ec need these */ @@ -116,7 +124,7 @@ extern void ick_stashinit(void); /* AIS: Added mentions of oo. This is set to 0 in a non-overloaded program. */ extern void ick_stash(unsigned int type, unsigned int index, void *from, ick_overop* oo); extern void ick_retrieve(void *to, unsigned int type, unsigned int index, - ick_bool forget, ick_overop* oo); + bool forget, ick_overop* oo); extern unsigned int ick_roll(unsigned int n); /* AIS: Lose with IE277 */ @@ -209,13 +217,13 @@ extern jmp_buf ick_cjb; /* AIS: Used by the debugger, multithread code, external calls */ #if (MULTITHREAD != 0) || (YUKDEBUG != 0) || defined(ICK_EC) extern ick_type16* ick_onespots; -extern ick_bool* ick_oneforget; +extern bool* ick_oneforget; extern ick_type32* ick_twospots; -extern ick_bool* ick_twoforget; +extern bool* ick_twoforget; extern ick_array* ick_tails; -extern ick_bool* ick_tailforget; +extern bool* ick_tailforget; extern ick_array* ick_hybrids; -extern ick_bool* ick_hyforget; +extern bool* ick_hyforget; #if (MULTITHREAD != 0) || defined(ICK_EC) /*@null@*/ extern ick_overop* ick_oo_onespots; /*@null@*/ extern ick_overop* ick_oo_twospots; diff --git a/src/cesspool.c b/src/cesspool.c index fbb4a0f..e1129b3 100644 --- a/src/cesspool.c +++ b/src/cesspool.c @@ -302,7 +302,7 @@ static void butcher(unsigned long val, /*@out@*/ char *result) } } -void ick_clockface(ick_bool mode) +void ick_clockface(bool mode) /* enable or disable ick_clockface mode (output IIII instead of IV) */ { if (mode) @@ -321,7 +321,7 @@ void ick_clockface(ick_bool mode) } } -void ick_setclcsemantics(ick_bool mode) /* AIS: CLC-INTERCAL semantics mode? */ +void ick_setclcsemantics(bool mode) /* AIS: CLC-INTERCAL semantics mode? */ { ick_clcsem=mode; } @@ -361,7 +361,7 @@ extern int ick_clc_cset_convert(const char* in, /*@partial@*/ char* out, const c const char* outcset, int padstyle, size_t outsize, /*@null@*/ FILE* errsto); -static void clcbinin(unsigned int type, ick_array *a, ick_bool forget) +static void clcbinin(unsigned int type, ick_array *a, bool forget) { size_t i; int ti; @@ -473,7 +473,7 @@ static void clcbinout(unsigned int type, const ick_array* a) * *********************************************************************/ -void ick_binin(unsigned int type, ick_array *a, ick_bool forget) +void ick_binin(unsigned int type, ick_array *a, bool forget) { static int lastin = 0; int c, v; @@ -533,7 +533,7 @@ void ick_binout(unsigned int type, const ick_array *a) * *********************************************************************/ -unsigned int ick_assign(char *dest, unsigned int type, ick_bool forget, +unsigned int ick_assign(char *dest, unsigned int type, bool forget, unsigned int value) { unsigned int retval = 0; @@ -619,7 +619,7 @@ void ick_resize(va_alist) va_dcl unsigned int type; #endif ick_array *a; - ick_bool forget; + bool forget; unsigned int i, r; size_t v; va_list ap; @@ -632,7 +632,7 @@ void ick_resize(va_alist) va_dcl type = va_arg(ap, unsigned int); #endif a = va_arg(ap, ick_array*); - forget = va_arg(ap, ick_bool); + forget = va_arg(ap, bool); /* AIS: a->dims is no longer initialised. So initialise it here if it isn't already initialised, with an annotation to explain that @@ -778,7 +778,7 @@ void ick_stash(unsigned int type, unsigned int index, void *from, ick_overop* oo } void ick_retrieve(void *to, unsigned int type, unsigned int index, - ick_bool forget, ick_overop* oo) + bool forget, ick_overop* oo) /* restore the value of a variable from the save stack */ { ick_stashbox *sp; @@ -831,7 +831,7 @@ void ick_retrieve(void *to, unsigned int type, unsigned int index, *********************************************************************/ unsigned int ick_roll(unsigned int n) -/* return ick_TRUE on n% chance, ick_FALSE otherwise */ +/* return true on n% chance, false otherwise */ { #ifdef USG return((unsigned int)(lrand48() % 100) < n); diff --git a/src/dekludge.c b/src/dekludge.c index 73f26a0..8c6cf49 100644 --- a/src/dekludge.c +++ b/src/dekludge.c @@ -72,7 +72,7 @@ extern void prexpr(node *np, FILE* fp, int freenode); /* AIS */ /* This function by AIS. Compares expressions. In C++, I'd call this node::operator== . */ -ick_bool nodessame(/*@observer@*/ const node* n1, /*@observer@*/ const node* n2) +bool nodessame(/*@observer@*/ const node* n1, /*@observer@*/ const node* n2) { if(!n1) return !n2; if(!n2) return 0; @@ -96,7 +96,7 @@ ick_bool nodessame(/*@observer@*/ const node* n1, /*@observer@*/ const node* n2) case XOR: return n1->width == n2->width; default: - return 1; + return true; } } @@ -155,19 +155,19 @@ void optimizef(void) /*@-onlytrans@*/ optuple = tp; /*@=onlytrans@*/ - if(tp->maybe) tp->abstainable = 1; - if(tp->exechance < 0) tp->initabstain = 1; - if(tp->exechance != 100 && tp->exechance != -100) tp->abstainable = 1; - if(tp->onceagainflag != onceagain_NORMAL) tp->abstainable = 1; + if(tp->maybe) tp->abstainable = true; + if(tp->exechance < 0) tp->initabstain = true; + if(tp->exechance != 100 && tp->exechance != -100) tp->abstainable = true; + if(tp->onceagainflag != onceagain_NORMAL) tp->abstainable = true; if(tp->type == ABSTAIN || tp->type == FROM) { tpa = tp->u.target - 1 + tuples; - if(tpa->exechance >= 0) tpa->abstainable = 1; + if(tpa->exechance >= 0) tpa->abstainable = true; } if(tp->type == REINSTATE) { tpa = tp->u.target - 1 + tuples; - if(tpa->exechance < 0) tpa->abstainable = 1; + if(tpa->exechance < 0) tpa->abstainable = true; } if(tp->type == DISABLE || tp->type == MANYFROM) { @@ -177,7 +177,7 @@ void optimizef(void) if(tp->type == MANYFROM) np = np->rval; for(; np; np = np -> rval) if(abstainmatch((int)np->constant, (int)tpa->type)) - if(tpa->exechance >= 0) tpa->abstainable = 1; + if(tpa->exechance >= 0) tpa->abstainable = true; } } if(tp->type == ENABLE) @@ -187,7 +187,7 @@ void optimizef(void) np = tp->u.node; for(; np; np = np -> rval) if(abstainmatch((int)np->constant, (int)tpa->type)) - if(tpa->exechance < 0) tpa->abstainable = 1; + if(tpa->exechance < 0) tpa->abstainable = true; } } if(tp->type == GETS && ick_Base == 2 && !opoverused) @@ -303,7 +303,7 @@ void optimizef(void) !tpb->abstainable) /* No COMING FROM a nonabstainable RESUME line! */ { - tp->optversion = ick_TRUE; + tp->optversion = true; free(tp->u.node); tp->u.node = nodecopy(tpb->u.node); /* If tp->u.node is 2, then the statement should translate to a @@ -377,7 +377,7 @@ void optimize(node *np) if(optdebug) fprintf(stderr,"\n"); if(optdebug >= 2) fprintf(stderr,"-----\n"); checkforintercaloperators(np); - if(optuple->type == RESUME && !np->optdata) optuple->warn622 = 1; + if(optuple->type == RESUME && !np->optdata) optuple->warn622 = true; } /* By AIS. This relies on free'd pointers being NULLed. The annotations @@ -407,7 +407,7 @@ static void checkW534(const node *np) { /* This looks suspicious, in that C-INTERCAL will do an op32, but INTERCAL-72 would have done an op16. */ - optuple->warn534=1; + optuple->warn534=true; } } checkW534(np->lval); @@ -421,7 +421,7 @@ static void checkforintercaloperators(const node *np) switch(np->opcode) { /* This only comes up in binary. */ case AND: case OR: case XOR: case MINGLE: case SELECT: - optuple->warn018 = 1; + optuple->warn018 = true; break; default: checkforintercaloperators(np->lval); @@ -446,8 +446,8 @@ void checknodeactbits(node *np) { case MINGLE: /*@-nullderef@*/ /* mingle has two nonnull arguments */ - if(np->lval->optdata & 0xffff0000LU) optuple->warn276 = 1; - if(np->rval->optdata & 0xffff0000LU) optuple->warn276 = 1; + if(np->lval->optdata & 0xffff0000LU) optuple->warn276 = true; + if(np->rval->optdata & 0xffff0000LU) optuple->warn276 = true; np->optdata = ick_mingle((unsigned)(np->lval->optdata & 0xffff), (unsigned)(np->rval->optdata & 0xffff)); /*@=nullderef@*/ @@ -614,14 +614,14 @@ void checknodeactbits(node *np) has its own case so that W276 can be given on an assignment. */ /*@-nullderef@*/ if(np->lval->optdata == 0xffff && - np->rval->optdata & 0xffff0000lu) optuple->warn276 = 1; + np->rval->optdata & 0xffff0000lu) optuple->warn276 = true; /*@=nullderef@*/ /*@fallthrough@*/ case UNKNOWNOP: default: /*@-nullderef@*/ - if(np->opcode == BY && !np->lval->optdata) optuple->warn239 = 1; + if(np->opcode == BY && !np->lval->optdata) optuple->warn239 = true; /*@=nullderef@*/ np->optdata = (np->width == 16 ? 0xffffLU : 0xffffffffLU); /* Some values of opcode are used as placeholders, to save more than 1 diff --git a/src/feh.h b/src/feh.h index ad4f9d2..7ad4442 100644 --- a/src/feh.h +++ b/src/feh.h @@ -24,7 +24,7 @@ extern void optimizef(void); /* AIS */ extern void nodefree(/*@keep@*/ /*@null@*/ node* np); /* AIS */ extern unsigned long varextern(unsigned long intern, int vartype); /* AIS */ extern node *nodecopy(const node*); /* AIS */ -extern ick_bool nodessame(/*@observer@*/ const node*, /*@observer@*/ const node*); /* AIS */ +extern bool nodessame(/*@observer@*/ const node*, /*@observer@*/ const node*); /* AIS */ extern node *optdebugnode; /* AIS */ extern const char **enablers; /* AIS: so that there can be an element before the @@ -32,6 +32,6 @@ extern const char **enablers; /* AIS: so that there can be an element before the -1, just to cause a bit more confusion) */ extern const assoc vartypes[]; -extern int useprintflow; /* AIS */ +extern bool useprintflow; /* AIS */ /* feh.h ends here */ diff --git a/src/feh2.c b/src/feh2.c index 53a70a9..c641242 100644 --- a/src/feh2.c +++ b/src/feh2.c @@ -43,12 +43,12 @@ LICENSE TERMS int emitlineno; /* line number for errors encountered during emit */ /*@-exportlocal@*/ /* the parser uses this */ -int mark112 = 0; /* AIS: Mark the ick_next generated tuple for W112 */ +bool mark112 = 0; /* AIS: Mark the ick_next generated tuple for W112 */ /*@=exportlocal@*/ /* AIS: From perpet.c */ -extern int pickcompile; -extern int ick_clcsemantics; +extern bool pickcompile; +extern bool ick_clcsemantics; /************************************************************************* * @@ -235,7 +235,7 @@ void treset(void) ick_lose(IE666, iyylineno, (const char *)NULL); memset(tuples + ick_lineno, 0, (tuplecount - ick_lineno) * sizeof(tuple)); } - if(mark112) tuples[ick_lineno].warn112 = 1; mark112 = 0; /* AIS */ + if(mark112) tuples[ick_lineno].warn112 = true; mark112 = false; /* AIS */ /* Yes, tuples is strictly speaking 'partial' at this point, but it's going to be filled in later, and isn't marked as partial due to it not being partial through most of the code, and you can't write out on a global. @@ -358,16 +358,16 @@ void codecheck(void) * Check that every NEXT, ABSTAIN, REINSTATE and COME_FROM actually has a * legitimate target label. */ - notpast1900 = ick_TRUE; + notpast1900 = 1; for (tp = tuples; tp < tuples + ick_lineno; tp++) { - if (tp->label == 1900) notpast1900 = ick_FALSE; /* AIS */ + if (tp->label == 1900) notpast1900 = false; /* AIS */ if (tp->type == NEXT || tp->type == ABSTAIN || tp->type == REINSTATE || tp->type == COME_FROM || tp->type == FROM || tp->type == NEXTFROMLABEL) /* AIS: added FROM, NEXTFROMLABEL. */ { - ick_bool foundit = ick_FALSE; + bool foundit = false; if (tp->u.target >= 1900 && tp->u.target <= 1998) { @@ -382,7 +382,7 @@ void codecheck(void) for (up = tuples; up < tuples + ick_lineno; up++) if (tp->u.target == up->label) { - foundit = ick_TRUE; + foundit = true; break; } @@ -429,7 +429,7 @@ void codecheck(void) else /* AIS */ { tp->nexttarget = (unsigned)(up - tuples + 1); - up->nextable = ick_TRUE; + up->nextable = true; } } } @@ -1150,7 +1150,7 @@ static void revprexpr(node *np, FILE *fp, node *target) (void) fprintf(fp,".set("); prexpr(target, fp, 0); (void) fprintf(fp,",os%dspot%lu);\n", - (np->opcode==ick_TWOSPOT)+1, np->constant); + ((np->opcode==ick_TWOSPOT)?1:0)+1, np->constant); } else if(!pickcompile) { @@ -1794,6 +1794,7 @@ void emittextlines(FILE *fp) (void) fprintf(fp, "\"\"\n"); } +/*@-nestedextern@*/ void emit(tuple *tn, FILE *fp) /* emit code for the given tuple */ { @@ -1865,7 +1866,7 @@ void emit(tuple *tn, FILE *fp) /* AIS: set weaving status if necessary */ if(tn->setweave) - (void) fprintf(fp, " weaving = %d;\n", tn->setweave>0); + (void) fprintf(fp, " weaving = %d;\n", (tn->setweave>0)?1:0); /* AIS: print warnings on -l */ if(ick_checkforbugs) @@ -2056,7 +2057,7 @@ void emit(tuple *tn, FILE *fp) (void) fprintf(fp,".set("); prexpr(tn->u.node->rval, fp, 1); (void) fprintf(fp,",os%dspot%lu);\n", - (tn->u.node->lval->opcode==ick_TWOSPOT)+1, + ((tn->u.node->lval->opcode==ick_TWOSPOT)?1:0)+1, tn->u.node->lval->constant); } else if(!pickcompile) @@ -2207,7 +2208,7 @@ void emit(tuple *tn, FILE *fp) case IGNORE: for (np = tn->u.node; np; np = np->rval) - (void) fprintf(fp,"\t""ICKIGNORE(%s,%lu,%s) = ick_TRUE;\n", + (void) fprintf(fp,"\t""ICKIGNORE(%s,%lu,%s) = true;\n", nameof(np->opcode, forgetbits), np->constant, nameof(np->opcode, varstores)); @@ -2215,7 +2216,7 @@ void emit(tuple *tn, FILE *fp) case REMEMBER: for (np = tn->u.node; np; np = np->rval) - (void) fprintf(fp,"\t""ICKIGNORE(%s,%lu,%s) = ick_FALSE;\n", + (void) fprintf(fp,"\t""ICKIGNORE(%s,%lu,%s) = false;\n", nameof(np->opcode, forgetbits), np->constant, nameof(np->opcode, varstores)); @@ -2246,7 +2247,7 @@ void emit(tuple *tn, FILE *fp) break; case REINSTATE: - /* (Joris Huizer) ensure it is not an GIVE UP statement */ + /* (Joris Huizer) ensure it is not a GIVE UP statement */ if ((tuples + tn->u.target - 1)->type != GIVE_UP) { if(!pickcompile) @@ -2494,14 +2495,14 @@ void emit(tuple *tn, FILE *fp) case CREATE: /* By AIS */ if(createsused == 0) goto splatme; (void) fprintf(fp,"\t""ick_registercreation(\""); - prunknownstr(tn->u.node, fp); + (void) prunknownstr(tn->u.node, fp); (void) fprintf(fp,"\",%uU);\n",tn->u.target); break; case COMPUCREATE: /* By AIS */ if(createsused == 0) goto splatme; (void) fprintf(fp,"\t""ick_registercreation(\""); - prunknownstr(tn->u.node->rval, fp); + (void) prunknownstr(tn->u.node->rval, fp); (void) fprintf(fp,"\","); prexpr(tn->u.node->lval, fp, 1); (void) fprintf(fp,");\n"); @@ -2716,6 +2717,7 @@ void emit(tuple *tn, FILE *fp) (void) fputs(" if(ick_printflow) fprintf(stderr," "\"[%d]\",ick_lineno);\n",fp); } +/*@=nestedextern@*/ /* AIS: Generate prototypes for slat expressions, args to UNKNOWN */ void emitslatproto(FILE* fp) diff --git a/src/ick.h b/src/ick.h index b342b16..210be13 100644 --- a/src/ick.h +++ b/src/ick.h @@ -1,5 +1,7 @@ /* ick.h -- compilation types for intercal parser */ +#include "ick_bool.h" + #ifdef ICKNOSEARCH #define ICKINCLUDEDIR "." #define ICKLIBDIR "." @@ -15,16 +17,6 @@ #define YY_NO_UNPUT -#ifndef ICKBOOL_DEFINED -/*@-redef@*/ -typedef int ick_bool; -/*@=redef@*/ -#define ICKBOOL_DEFINED -#endif - -#define ick_TRUE 1 -#define ick_FALSE 0 - #define ALLOC_CHUNK 256 /* @@ -63,23 +55,23 @@ typedef struct tuple_t have this line as a suck-point */ int exechance; /* chance of execution, initial abstain, (AIS) MAYBE details */ - ick_bool maybe; /* AIS: Where MAYBE details go when + bool maybe; /* AIS: Where MAYBE details go when exechance has been parsed */ - ick_bool abstainable; /* AIS: Is it possible for this line to + bool abstainable; /* AIS: Is it possible for this line to be abstained from? */ - ick_bool initabstain; /* AIS: Is this line initially + bool initabstain; /* AIS: Is this line initially abstained from? */ - ick_bool nextable; /* AIS: Can this line be a NEXT + bool nextable; /* AIS: Can this line be a NEXT target? */ - ick_bool optversion; /* AIS: Use an optimized version? (Only + bool optversion; /* AIS: Use an optimized version? (Only set if the optimizer thinks that it's safe.) */ - ick_bool preproc; /* AIS: Is this line a nonexistent one + bool preproc; /* AIS: Is this line a nonexistent one that was added to implement a command in the parser? */ - ick_bool warn112:1; /* AIS: Should this line produce warning + bool warn112:1; /* AIS: Should this line produce warning 112 during degeneration? */ - ick_bool warn128:1, warn534:1, warn018:1, warn016:1, warn276:1, warn239:1, + bool warn128:1, warn534:1, warn018:1, warn016:1, warn276:1, warn239:1, warn622:1; /* AIS: As warn112. The warnings are a bitfield to save space. */ unsigned int type; /* statement type */ struct @@ -90,7 +82,7 @@ typedef struct tuple_t unsigned int nexttarget; /* AIS: The target tuple of a NEXT must also be recorded for optimizef */ int ick_lineno; /* source line for error messages */ - ick_bool sharedline; /* if NZ, two statements on a line */ + bool sharedline; /* if NZ, two statements on a line */ enum onceagain onceagainflag; /* AIS: ONCE / AGAIN */ int ppnewtype; /* AIS: 'real' type of this line when the preprocessor is used; 0 on all @@ -142,32 +134,32 @@ extern unsigned long sparkearsstack[SENESTMAX]; extern int sparkearslev; /* compilation options */ -extern ick_bool compile_only; /* just compile into C, don't run the linker */ -extern ick_bool nocompilerbug; /* set possibility of IE774 to zero */ -extern int ick_traditional; /* compile as INTERCAL-72 */ +extern bool compile_only; /* just compile into C, don't run the linker */ +extern bool nocompilerbug; /* set possibility of IE774 to zero */ +extern bool ick_traditional; /* compile as INTERCAL-72 */ extern int yydebug; /* print debugging information while parsing */ extern int politesse; /* AIS: I added these */ -extern int yukdebug; /* debug the code with yuk */ -extern int yukprofile; /* profile the code with yuk */ +extern bool yukdebug; /* debug the code with yuk */ +extern bool yukprofile; /* profile the code with yuk */ extern int compucomecount; /* number of computed COME FROMs */ -extern int compucomesused; /* are computed COME FROMs used? */ -extern int nextfromsused; /* is NEXT FROM used? */ -extern int gerucomesused; /* is COME FROM gerund used? */ -extern int opoverused; /* is operand overloading used? */ -extern int useickec; /* are external calls used? */ -extern int createsused; /* are CREATEs used? */ +extern bool compucomesused; /* are computed COME FROMs used? */ +extern bool nextfromsused; /* is NEXT FROM used? */ +extern bool gerucomesused; /* is COME FROM gerund used? */ +extern bool opoverused; /* is operand overloading used? */ +extern bool useickec; /* are external calls used? */ +extern bool createsused; /* are CREATEs used? */ /*@null@*/ extern node* firstslat; /* the ick_first node with a slat */ /*@null@*/ extern node* prevslat; /* the last node so far with a slat */ -extern int multithread; /* is the program multithreaded? */ -extern int variableconstants; /* is any assignment allowed? */ -extern int ick_coreonerr; /* dump core on IE778? */ -extern int optdebug; /* debug the optimizer */ -extern int flowoptimize; /* optimize program flow */ -extern int ick_checkforbugs; /* check for bugs */ -extern int coopt; /* constant-output optimizer */ +extern bool multithread; /* is the program multithreaded? */ +extern bool variableconstants; /* is any assignment allowed? */ +extern bool ick_coreonerr; /* dump core on IE778? */ +extern int optdebug; /* debug the optimizer */ +extern bool flowoptimize; /* optimize program flow */ +extern bool ick_checkforbugs; /* check for bugs */ +extern bool coopt; /* constant-output optimizer */ /* ick.h ends here */ diff --git a/src/ick_lose.c b/src/ick_lose.c index 6e5b2b9..03c2f0f 100644 --- a/src/ick_lose.c +++ b/src/ick_lose.c @@ -25,11 +25,11 @@ LICENSE TERMS #include #include #include +#include "ick.h" /* ugh, just for bool */ #include "ick_lose.h" -int ick_coreonerr = 0; /* AIS */ - -int ick_checkforbugs; /* AIS */ +bool ick_coreonerr; /* AIS */ +bool ick_checkforbugs; /* AIS */ /*@-formatconst@*/ void ick_lose(const char *m, int n, const char *s) diff --git a/src/lexer.l b/src/lexer.l index f0ca2d2..d1ade32 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -78,7 +78,7 @@ static char linebuf[YYLMAX]; static char *lineptr = linebuf; -ick_bool re_send_token = ick_FALSE; +bool re_send_token = false; int lexer(void); static int myatoi(const char *text); @@ -111,23 +111,23 @@ int getc(FILE *fp) { extern FILE* yyin; - static ick_bool bangflag = ick_FALSE; - static ick_bool backflag = ick_FALSE; + static bool bangflag = false; + static bool backflag = false; - static ick_bool eolflag = ick_FALSE; + static bool eolflag = false; if ((size_t)(lineptr - linebuf) > sizeof linebuf) ick_lose(IE666, iyylineno, (char *)NULL); if (bangflag) { - bangflag = ick_FALSE; + bangflag = false; /* *lineptr++ = '!'; */ return('.'); } else if (backflag) /* converting ctrl-H (backspace) to two chars "^H" */ { - backflag = ick_FALSE; + backflag = false; /* *lineptr++ = '\b'; */ return('H'); } @@ -158,19 +158,19 @@ int getc(FILE *fp) if(c=='\0' || c==EOF) c='\n'; } - eolflag = ick_FALSE; + eolflag = false; if (c == '!') { *lineptr++ = '!'; - bangflag = ick_TRUE; + bangflag = true; return(c = '\''); } else if (c == '\b') /* convert ctrl-H (backspace) to two chars "^" and "H" so lex can take it */ { *lineptr++ = '\b'; - backflag = ick_TRUE; + backflag = true; return(c = '^'); } else if (c == '\n') @@ -193,7 +193,7 @@ int getc(FILE *fp) ick_lose(IE666, iyylineno, (char *)NULL); strcpy(textlines[iyylineno], linebuf); iyylineno++; - eolflag=ick_TRUE; + eolflag=true; return('\n'); } else @@ -454,7 +454,7 @@ int lexer(void) static int tok = BADCHAR; if (re_send_token) - re_send_token = ick_FALSE; + re_send_token = false; else { tok = yylex(); diff --git a/src/parser.y b/src/parser.y index eb2125d..9d0554b 100644 --- a/src/parser.y +++ b/src/parser.y @@ -668,7 +668,7 @@ static tuple *splat(int gentuple) { tuple *sp; int tok, i; - extern ick_bool re_send_token; + extern bool re_send_token; /* * The idea @@ -676,7 +676,7 @@ static tuple *splat(int gentuple) * which we can do with a tricky flag on the lexer (re_send_token). */ - if(re_send_token == ick_TRUE) /* By AIS */ + if(re_send_token == true) /* By AIS */ { /* We're still cleaning up from the previous error. */ return prevtuple; @@ -686,17 +686,17 @@ static tuple *splat(int gentuple) /* AIS: Set the flag to true the first time round, false for subsequent iterations. That way, if the error was triggered on a DO or label, we use that token as the start of the next statement. */ - for(i = 0,re_send_token = ick_TRUE;;i++,re_send_token = ick_FALSE) { + for(i = 0,re_send_token = true;;i++,re_send_token = false) { tok = lexer(); if (!tok) { - re_send_token = ick_TRUE; + re_send_token = true; tok = ' '; /* scanner must not see a NUL */ break; } else if (tok == DO || tok == PLEASE || tok == LABEL /* AIS */ || tok == MAYBE) { - re_send_token = ick_TRUE; + re_send_token = true; break; } } diff --git a/src/perpet.c b/src/perpet.c index fbfb4af..338a53b 100644 --- a/src/perpet.c +++ b/src/perpet.c @@ -80,46 +80,46 @@ extern int yyparse(void); int yydebug; /* compilation options */ -ick_bool compile_only; /* just compile into C, don't run the linker */ -ick_bool ick_traditional; /* insist on strict INTERCAL-72 conformance */ -ick_bool nocompilerbug; /* disable error IE774 */ -int yukdebug; /* AIS: Use the yuk debugger. */ -int yukprofile; /* AIS: Use the yuk profiler. */ -int useprintflow=0; /* AIS: Add +printflow support. */ -extern int ick_coreonerr; /* AIS: Dump core on IE778. (defined in ick_lose.c) */ -int multithread; /* AIS: Allow multithreading and backtracking. */ -int variableconstants; /* AIS: Allow anything on the left of an assignment. */ -int createsused=0; /* AIS: Allow the use of CREATE. */ -int useickec; /* AIS: Link together INTERCAL and C. */ -static int nosyslib=0; /* AIS: Don't link syslib under any circumstances. */ -static int showsystem=0;/* AIS: Show the command lines in system() calls */ -int cdebug; /* AIS: Pass -g to our C compiler, and leave C code. */ +bool compile_only; /* just compile into C, don't run the linker */ +bool ick_traditional; /* insist on strict INTERCAL-72 conformance */ +bool nocompilerbug; /* disable error IE774 */ +bool yukdebug; /* AIS: Use the yuk debugger. */ +bool yukprofile; /* AIS: Use the yuk profiler. */ +bool useprintflow; /* AIS: Add +printflow support. */ +extern bool ick_coreonerr; /* AIS: Dump core on IE778. (defined in ick_lose.c) */ +bool multithread; /* AIS: Allow multithreading and backtracking. */ +bool variableconstants; /* AIS: Allow anything on the left of an assignment. */ +bool createsused; /* AIS: Allow the use of CREATE. */ +bool useickec; /* AIS: Link together INTERCAL and C. */ +static bool nosyslib; /* AIS: Don't link syslib under any circumstances. */ +static bool showsystem; /* AIS: Show the command lines in system() calls */ +bool cdebug; /* AIS: Pass -g to our C compiler, and leave C code. */ int optdebug; /* AIS: Debug the optimizer. Value is 0, 1, 2, or 3. */ -int flowoptimize; /* AIS: Do flow optimizations (in INTERCAL!). */ -int coopt; /* AIS: The constant-output optimization. This should +bool flowoptimize; /* AIS: Do flow optimizations (in INTERCAL!). */ +bool coopt; /* AIS: The constant-output optimization. This should mean that INTERCAL will beat any other language at many benchmark programs (!) */ -extern int ick_printfopens; /* AIS: Print messages whenever attempting to open a +extern bool ick_printfopens; /* AIS: Print messages whenever attempting to open a file: from uncommon.c */ -extern int ick_checkforbugs;/* AIS: Try to find possible bugs in the source code */ -int pickcompile; /* AIS: Compile for PIC? */ +extern bool ick_checkforbugs;/* AIS: Try to find possible bugs in the source code */ +bool pickcompile; /* AIS: Compile for PIC? */ /*@-exportlocal@*/ /* AIS: relevant to the lexer */ -int clclex; /* AIS: 1 means use CLC-INTERCAL meanings for @, ? */ +bool clclex; /* AIS: 1 means use CLC-INTERCAL meanings for @, ? */ /*@=exportlocal@*/ -int ick_clcsemantics; /* AIS: CLC semantics for I/O, abstaining GIVE UP, &c*/ -static int outtostdout; /* AIS: Output on stdout rather than the output file */ +bool ick_clcsemantics; /* AIS: CLC semantics for I/O, abstaining GIVE UP, &c*/ +static bool outtostdout; /* AIS: Output on stdout rather than the output file */ /* AIS: Autodetected compilation options */ -int compucomecount=0; /* Computed COME FROM count */ -int compucomesused=0; /* Are computed COME FROMs used? */ -int gerucomesused=0; /* Is COME FROM gerund used? */ -int nextfromsused=0; /* Is NEXT FROM used? */ -int opoverused=0; /* Is operand overloading used? */ +int compucomecount; /* Computed COME FROM count */ +bool compucomesused; /* Are computed COME FROMs used? */ +bool gerucomesused; /* Is COME FROM gerund used? */ +bool nextfromsused; /* Is NEXT FROM used? */ +bool opoverused; /* Is operand overloading used? */ /*@null@*/ node* firstslat=0; /* The first slat expression in the program */ /*@null@*/ node* prevslat=0; /* The last slat expression used so far */ -static ick_bool dooptimize; /* do optimizations? (controlled by -O) */ -static ick_bool ick_clockface; /* set up output to do IIII for IV */ +static bool dooptimize; /* do optimizations? (controlled by -O) */ +static bool ick_clockface; /* set up output to do IIII for IV */ #define SKELETON "ick-wrap.c" #define PSKELETON "pickwrap.c" @@ -313,152 +313,153 @@ static void parse_options(int argc, char *argv[]) switch (c) { case 'b': - nocompilerbug = ick_TRUE; + nocompilerbug = true; break; case 'c': - compile_only = ick_TRUE; - /* AIS */ coopt = ick_FALSE; + compile_only = true; + /* AIS */ coopt = false; break; case 'o': /* AIS */ - compile_only = ick_TRUE; - outtostdout = ick_TRUE; - coopt = ick_FALSE; + compile_only = true; + outtostdout = true; + coopt = false; break; case 'd': - yydebug = compile_only = ick_TRUE; - /* AIS */ coopt = ick_FALSE; + yydebug = 1; + compile_only = true; + /* AIS */ coopt = false; break; case 'e': /* AIS */ - useickec = ick_TRUE; - multithread = pickcompile = coopt = yukdebug = yukprofile = ick_FALSE; + useickec = true; + multithread = pickcompile = coopt = yukdebug = yukprofile = false; break; case 'E': /* AIS */ - nosyslib = ick_TRUE; - pickcompile = ick_FALSE; + nosyslib = true; + pickcompile = false; break; case 'C': - ick_clockface = ick_TRUE; + ick_clockface = true; break; case 't': - ick_traditional = ick_TRUE; + ick_traditional = true; if(multithread) ick_lose(IE111, 1, (const char*) NULL); /* AIS */ if(pickcompile) ick_lose(IE111, 1, (const char*) NULL); /* AIS */ break; case 'O': - dooptimize = ick_TRUE; - variableconstants = ick_FALSE; /* AIS */ + dooptimize = true; + variableconstants = false; /* AIS */ break; case 'f': /* By AIS */ - flowoptimize = ick_TRUE; - yukdebug = yukprofile = ick_FALSE; - variableconstants = ick_FALSE; + flowoptimize = true; + yukdebug = yukprofile = false; + variableconstants = false; break; case 'F': /* By AIS */ - coopt = flowoptimize = dooptimize = ick_TRUE; - variableconstants = useickec = ick_FALSE; - yukdebug = yukprofile = yydebug = outtostdout = - compile_only = cdebug = ick_FALSE; + coopt = flowoptimize = dooptimize = true; + variableconstants = useickec = false; + yukdebug = yukprofile = outtostdout = compile_only = cdebug = false; + yydebug = 0; if(pickcompile) ick_lose(IE256, 1, (const char*) NULL); break; case 'h': /* By AIS */ optdebug|=1; - compile_only=dooptimize=ick_TRUE; - coopt=ick_FALSE; + compile_only=dooptimize=true; + coopt=false; break; case 'H': /* By AIS */ optdebug|=2; - compile_only=dooptimize=ick_TRUE; - coopt=ick_FALSE; + compile_only=dooptimize=true; + coopt=false; break; case 'y': /* By AIS */ #ifdef HAVE_UNISTD_H - yukdebug=ick_TRUE; - multithread=flowoptimize=coopt=useickec=ick_FALSE; + yukdebug=true; + multithread=flowoptimize=coopt=useickec=false; #endif break; case 'p': /* By AIS */ #ifdef HAVE_UNISTD_H - yukprofile=ick_TRUE; - multithread=flowoptimize=coopt=useickec=ick_FALSE; + yukprofile=true; + multithread=flowoptimize=coopt=useickec=false; #endif break; case 'w': /* By AIS */ - useprintflow = ick_TRUE; + useprintflow = true; break; case 'm': /* By AIS */ - multithread=ick_TRUE; - yukprofile=ick_FALSE; - yukdebug=ick_FALSE; - useickec=ick_FALSE; + multithread=true; + yukprofile=false; + yukdebug=false; + useickec=false; if(ick_traditional) ick_lose(IE111, 1, (const char*) NULL); break; case 'a': /* By AIS */ - createsused=ick_TRUE; - pickcompile=ick_FALSE; + createsused=true; + pickcompile=false; break; case 'v': /* By AIS */ - variableconstants=ick_TRUE; - dooptimize=ick_FALSE; - flowoptimize=ick_FALSE; - coopt=ick_FALSE; - pickcompile=ick_FALSE; + variableconstants=true; + dooptimize=false; + flowoptimize=false; + coopt=false; + pickcompile=false; break; case 'l': /* By AIS */ - ick_checkforbugs=ick_TRUE; - dooptimize=ick_TRUE; + ick_checkforbugs=true; + dooptimize=true; break; case 'U': /* By AIS */ - ick_coreonerr=ick_TRUE; + ick_coreonerr=true; break; case 'u': /* By AIS */ - ick_printfopens=ick_TRUE; + ick_printfopens=true; break; case 'Y': /* By AIS */ - showsystem=ick_TRUE; + showsystem=true; break; case 'P': /* By AIS */ - pickcompile=ick_TRUE; - multithread=coopt=variableconstants=createsused=ick_FALSE; - ick_clcsemantics=useickec=nosyslib=ick_FALSE; - compile_only=ick_TRUE; - dooptimize=flowoptimize=ick_TRUE; /* needed for PICs */ + pickcompile=true; + multithread=coopt=variableconstants=createsused=false; + ick_clcsemantics=useickec=nosyslib=false; + compile_only=true; + dooptimize=flowoptimize=true; /* needed for PICs */ break; case 'X': /* By AIS */ - clclex=ick_TRUE; + clclex=true; break; case 'x': /* By AIS */ - ick_clcsemantics=ick_TRUE; - pickcompile=ick_FALSE; + ick_clcsemantics=true; + pickcompile=false; break; case 'g': /* By AIS */ - cdebug=ick_TRUE; - coopt=ick_FALSE; + cdebug=true; + coopt=false; break; case '?': @@ -489,10 +490,10 @@ static void handle_archive(char *libbuf, size_t libbuf_size, it instead adds a space and the filename to libbuf. */ if(library[0]=='l'&&library[1]=='i'&& library[2]=='b') - ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), + (void) ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), " -l%s",library+3); else - ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), + (void) ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), " %s.a",library); } @@ -540,7 +541,7 @@ static void handle_befunge98(char *libbuf, size_t libbuf_size, /* Compile the .b98 file into a .cio. It's open on stdin right now, so we just need to handle the output side of things. */ - ick_snprintf_or_die(outputfilename, sizeof outputfilename, "%s.cio", filename); + (void) ick_snprintf_or_die(outputfilename, sizeof outputfilename, "%s.cio", filename); if(!((of = ick_debfopen(outputfilename,"w")))) ick_lose(IE888,-1,(const char *)NULL); @@ -577,7 +578,7 @@ static void handle_befunge98(char *libbuf, size_t libbuf_size, (void) fclose(of); /* Put the libraries and .cio file in the command line. */ - ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), + (void) ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), " %s.cio -lick_ecto_b98 -lm -lncurses", filename); } @@ -630,14 +631,14 @@ static void find_intercal_base(char* chp) * @param buffer Output buffer that may be modified to contain the path of * syslib.i or syslib.Ni (where N is 3-7). * @param size Size of buffer. - * @param needsyslib Pointer to the ick_bool needsyslib declared in main(). + * @param needsyslib Pointer to the bool needsyslib declared in main(). * @param argv0 Should be argv[0], which wasn't modified. * @param ick_sysdir The ick data directory. * @note May (directly) call ick_lose() with IE127. */ static void check_syslib(/*@partial@*/ char *buffer, size_t size, - /*@out@*/ ick_bool *needsyslib, + /*@out@*/ bool *needsyslib, /*@observer@*/ const char *argv0, /*@observer@*/ const char *ick_sysdir) { @@ -645,7 +646,7 @@ static void check_syslib(/*@partial@*/ char *buffer, struct linerange_t *lp; if (nosyslib || pickcompile) { - *needsyslib = ick_FALSE; + *needsyslib = false; return; } @@ -654,7 +655,7 @@ static void check_syslib(/*@partial@*/ char *buffer, */ for (lp = lineranges; lp->start; lp++) { - *needsyslib = ick_FALSE; + *needsyslib = false; for (tp = tuples; tp->type; tp++) { /* * If some label in the specified range is defined, @@ -662,7 +663,7 @@ static void check_syslib(/*@partial@*/ char *buffer, * can stop searching. */ if (tp->label >= lp->start && tp->label <= lp->end) { - *needsyslib = ick_FALSE; + *needsyslib = false; goto breakout; } /* @@ -671,7 +672,7 @@ static void check_syslib(/*@partial@*/ char *buffer, */ if (tp->type == NEXT && tp->u.target >= lp->start && tp->u.target <= lp->end) - *needsyslib = ick_TRUE; + *needsyslib = true; } if (*needsyslib) { if (ick_Base == 2) @@ -716,8 +717,8 @@ static void propagate_typeinfo(void) || tp->type == FORGET || tp->type == RESUME || tp->type == COMPUCOME || tp->type == UNKNOWN) typecast(tp->type == MANYFROM ? tp->u.node->lval : tp->u.node); - if (tp->type == WRITE_IN) coopt = 0; /* AIS: may as well do - this here */ + if (tp->type == WRITE_IN) coopt = false; /* AIS: may as well do + this here */ } } @@ -842,7 +843,7 @@ static void gen_cc_command(char* buffer, size_t size, */ static void generate_code(FILE *ifp, FILE *ofp, /*@observer@*/ const char* source_name_stem, - ick_bool *needsyslib, + bool *needsyslib, int bugline, /*@observer@*/ const char* compilercommand) { @@ -883,7 +884,7 @@ static void generate_code(FILE *ifp, FILE *ofp, isn't referenced; if it isn't, we can allow one double-oh-seven if syslib was automagically inclulded. */ - if(*needsyslib) *needsyslib = 0; else coopt = 0; + if(*needsyslib) *needsyslib = false; else coopt = false; } if(!pickcompile) { @@ -898,7 +899,7 @@ static void generate_code(FILE *ifp, FILE *ofp, else { (void) fprintf(ofp, "1, "); tp->exechance = -tp->exechance; - tp->initabstain=1; /* AIS: As above */ + tp->initabstain=true; /* AIS: As above */ /* AIS: If the line was ick_abstained, we need to swap ONCEs and AGAINs on it round, to suit the code degenerator. */ @@ -910,10 +911,10 @@ static void generate_code(FILE *ifp, FILE *ofp, if(tp->exechance >= 101) { /* AIS: This line has a MAYBE */ - tp->maybe = 1; + tp->maybe = true; tp->exechance /= 100; } - else tp->maybe = 0; + else tp->maybe = false; } else /* AIS: hardcoded abstain bits for PICs */ { @@ -1067,7 +1068,7 @@ static void generate_code(FILE *ifp, FILE *ofp, (void) fprintf(ofp, "ick_type16* ick_onespots;\n"); (void) fprintf(ofp, - "ick_bool* ick_oneforget;\n"); + "bool* ick_oneforget;\n"); if(yukprofile || yukdebug) { (void) fprintf(ofp, @@ -1101,7 +1102,7 @@ static void generate_code(FILE *ifp, FILE *ofp, (void) fprintf(ofp, "ick_type32* ick_twospots;\n"); (void) fprintf(ofp, - "ick_bool* ick_twoforget;\n"); + "bool* ick_twoforget;\n"); if(yukprofile || yukdebug) { (void) fprintf(ofp, @@ -1135,7 +1136,7 @@ static void generate_code(FILE *ifp, FILE *ofp, (void) fprintf(ofp, "ick_array* ick_tails;\n"); (void) fprintf(ofp, - "ick_bool* ick_tailforget;\n"); + "bool* ick_tailforget;\n"); if(multithread) { (void) fprintf(ofp, @@ -1148,7 +1149,7 @@ static void generate_code(FILE *ifp, FILE *ofp, (void) fprintf(ofp, "ick_array* ick_hybrids;\n"); (void) fprintf(ofp, - "ick_bool* ick_hyforget;\n"); + "bool* ick_hyforget;\n"); if(multithread) { (void) fprintf(ofp, @@ -1260,9 +1261,9 @@ static void generate_code(FILE *ifp, FILE *ofp, case 'F': /* set options from command line */ if (ick_clockface) - (void) fprintf(ofp, "ick_clockface(ick_TRUE);\n"); + (void) fprintf(ofp, "ick_clockface(true);\n"); if (ick_clcsemantics) /* AIS */ - (void) fprintf(ofp, "ick_setclcsemantics(ick_TRUE);\n"); + (void) fprintf(ofp, "ick_setclcsemantics(true);\n"); break; case 'G': /* degenerated code */ @@ -1323,7 +1324,9 @@ static void generate_code(FILE *ifp, FILE *ofp, fprintf(ofp,"%d,",tp->ick_lineno); } (void) fprintf(ofp, "-1};\n\n"); + /*@+boolint@*/ (void) fprintf(ofp, "int yukopts = %d;\n", yukprofile+yukdebug*2); + /*@=boolint@*/ (void) fprintf(ofp, "yptimer ypexectime[%d];\n", ick_lineno); (void) fprintf(ofp, "ypcounter ypexecount[%d];\n",ick_lineno); (void) fprintf(ofp, "ypcounter ypabscount[%d];\n",ick_lineno); @@ -1344,11 +1347,11 @@ static void generate_code(FILE *ifp, FILE *ofp, case 'M': /* AIS: place new features defines in program */ /* This is needed even in a non-multithread program, to let the header files know it's non-multithread */ - (void) fprintf(ofp, "#define MULTITHREAD %d\n", multithread); + (void) fprintf(ofp, "#define MULTITHREAD %d\n", multithread?1:0); /* Likewise, to let the header files know whether it overloads operands (I don't think this is used at the moment, though) */ - (void) fprintf(ofp, "#define OPOVERUSED %d\n",opoverused); + (void) fprintf(ofp, "#define OPOVERUSED %d\n",opoverused?1:0); /* and whether to use the ICK_EC code */ if(useickec) (void) fprintf(ofp, "#define ICK_EC 1\n"); @@ -1771,7 +1774,7 @@ int main(int argc, char *argv[]) const char *cooptsh; /* AIS */ FILE *ifp, *ofp; int /* nextcount, AIS */ bugline; - ick_bool needsyslib, firstfile; + bool needsyslib, firstfile; int oldoptind; #ifdef HAVE_UNISTD_H int oldstdin; /* AIS: for keeping track of where stdin was */ @@ -1830,7 +1833,7 @@ int main(int argc, char *argv[]) oldoptind=optind; /* AIS */ *libbuf = '\0'; /* AIS */ /* Begin file loop */ - for (firstfile = ick_TRUE; optind < argc; optind++, firstfile = ick_FALSE) + for (firstfile = true; optind < argc; optind++, firstfile = false) { /* AIS: Read as binary to pick up Latin-1 and UTF-8 better */ if (/* AIS */ strrchr(argv[optind],'.') != NULL && @@ -1842,7 +1845,7 @@ int main(int argc, char *argv[]) /* strip off the file extension */ if(!(chp = strrchr(argv[optind],'.'))) { - if(useickec && firstfile == ick_FALSE) /* By AIS */ + if(useickec && firstfile == false) /* By AIS */ { /* the filename indicates a request for an expansion library, along the same lines as CLC-INTERCAL's preloads. Search for @@ -1901,7 +1904,7 @@ int main(int argc, char *argv[]) if(useickec && (!strcmp(chp,"c") || !strcmp(chp,"cio") || !strcmp(chp,"c99"))) /* AIS */ { - if(firstfile != ick_FALSE) /* need exactly 1 INTERCAL file */ + if(firstfile != false) /* need exactly 1 INTERCAL file */ ick_lose(IE998, 1, (const char *)NULL); continue; /* don't process C or cio files further yet */ } @@ -1927,7 +1930,7 @@ int main(int argc, char *argv[]) goto fixexpansionlibrary; } - if(useickec && firstfile == ick_FALSE) /* AIS */ + if(useickec && firstfile == false) /* AIS */ ick_lose(IE998, 1, (const char *)NULL); /* determine the file type from the extension */ @@ -1940,9 +1943,10 @@ int main(int argc, char *argv[]) treset(); politesse = 0; /* JH: default to no op-overusage and no computed come from */ - opoverused = 0; - compucomesused = compucomecount = 0; - gerucomesused = 0; /* AIS: you forgot this one */ + opoverused = false; + compucomesused = false; + compucomecount = 0; + gerucomesused = false; /* AIS: you forgot this one */ /* AIS: ensure that at least one variable exists, to prevent NULL pointers later on */ (void) intern(ick_ONESPOT, 1); /* mention .1 */ diff --git a/src/uncommon.c b/src/uncommon.c index 692191a..f55eb17 100644 --- a/src/uncommon.c +++ b/src/uncommon.c @@ -26,7 +26,7 @@ LICENSE TERMS #include "uncommon.h" /* Options that might affect this */ -int ick_printfopens=0; +bool ick_printfopens=0; /*@dependent@*/ /*@null@*/ FILE* ick_debfopen(/*@observer@*/ const char* fname, /*@observer@*/ const char* mode) diff --git a/src/uncommon.h b/src/uncommon.h index c3c25cd..b337692 100644 --- a/src/uncommon.h +++ b/src/uncommon.h @@ -2,6 +2,8 @@ #include "config.h" +#include "ick_bool.h" + /*@null@*/ /*@dependent@*/ extern FILE* ick_debfopen(/*@observer@*/ const char*, /*@observer@*/ const char*); /*@null@*/ /*@dependent@*/ extern FILE* ick_findandfopen(/*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*); /*@observer@*/ /*@null@*/ extern const char* ick_findandtestopen(/*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*, /*@observer@*/ const char*);