From 36f4ff10d235a8363103762f4db7ca423aaa3229 Mon Sep 17 00:00:00 2001 From: Arvid Norlander Date: Tue, 18 Nov 2008 13:36:56 -0500 Subject: [PATCH] Various other const warnings fixed. --- src/abcess.h | 4 ++-- src/arrgghh.c | 4 ++-- src/cesspool.c | 14 +++++++------- src/dekludge.c | 12 ++++++------ src/feh.h | 14 +++++++------- src/feh2.c | 34 +++++++++++++++++----------------- src/ick.h | 8 ++++---- src/ick_ec.c | 2 +- src/ick_ec.h | 2 +- src/numerals.c | 4 ++-- src/perpet.c | 2 +- 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/abcess.h b/src/abcess.h index c0ad047..93844ea 100644 --- a/src/abcess.h +++ b/src/abcess.h @@ -138,8 +138,8 @@ struct ick_tag_createdata ick_overop accessors;/* how to get and set this lvalue, or {0,0} */ unsigned long value; /* current value of the var or expression */ }; -extern void ick_registercreation(char*,unsigned long); -extern unsigned long ick_jicmatch(char*); +extern void ick_registercreation(const char*,unsigned long); +extern unsigned long ick_jicmatch(const char*); /* AIS: Multithreading types and defines */ #if MULTITHREAD != 0 diff --git a/src/arrgghh.c b/src/arrgghh.c index ef55bf6..53eb308 100644 --- a/src/arrgghh.c +++ b/src/arrgghh.c @@ -44,7 +44,7 @@ ick_parseargs(int argc, char **argv) { register int i, j; static int helpflag = -1; - static char *flags[] = { + static const char *flags[] = { "help", "wimpmode", "traditional", @@ -60,7 +60,7 @@ ick_parseargs(int argc, char **argv) &ick_printflow, /* AIS */ &ick_mystery, /* AIS */ }; - static int nflags = (int)(sizeof(flags)/sizeof(flags[0])); + static const int nflags = (int)(sizeof(flags)/sizeof(flags[0])); for(i = 1;i < argc;i++) { if(argv[i][0] != '+' && argv[i][0] != '-') { diff --git a/src/cesspool.c b/src/cesspool.c index 71e6511..05b3be6 100644 --- a/src/cesspool.c +++ b/src/cesspool.c @@ -167,7 +167,7 @@ unsigned int ick_pin(void) for(n=0,cp = strtok(buf, " ");cp;cp = strtok((char *)NULL, " "),n++) { int digit = -1; - numeral *np; + const numeral *np; for (np = ick_numerals; np < ick_numerals + sizeof(ick_numerals)/sizeof(numeral); np++) if (strcmp(np->name, cp) == 0) @@ -240,7 +240,7 @@ static void butcher(unsigned long val, /*@out@*/ char *result) char res[MAXROMANS], ovb[MAXROMANS]; /* We need FOUR columns because of the odd way that M and I interact. */ - static char br_equiv[MAXDIGITS][4] = + static const char br_equiv[MAXDIGITS][4] = { {'I', 'I', 'V', 'X'}, {'X', 'X', 'L', 'C'}, {'C', 'C', 'D', 'M'}, {'M', 'I', 'V', 'X'}, @@ -249,7 +249,7 @@ static void butcher(unsigned long val, /*@out@*/ char *result) {'c', 'c', 'd', 'm'}, {'m', 'i', 'v', 'x'}, }; - static char br_overbar[MAXDIGITS][4] = + static const char br_overbar[MAXDIGITS][4] = { {' ', ' ', ' ', ' '}, {' ', ' ', ' ', ' '}, @@ -865,7 +865,7 @@ int ick_multicome0(int errlineno, jmp_buf pc) struct ick_jictype { - /*@observer@*/ char* sig; /* a shallow copy of a constant string */ + /*@observer@*/ const char* sig; /* a shallow copy of a constant string */ unsigned long target; /*@null@*/ /*@only@*/ struct ick_jictype* next; }; @@ -874,7 +874,7 @@ struct ick_jictype /* Return a jic entry that matches the requested signature exactly, creating one if there isn't one yet. */ -static struct ick_jictype* jicextract(/*@observer@*/ char* sig) +static struct ick_jictype* jicextract(/*@observer@*/ const char* sig) { struct ick_jictype* jicptr = jiclist; while(jicptr) @@ -899,12 +899,12 @@ static struct ick_jictype* jicextract(/*@observer@*/ char* sig) return jicptr; } -void ick_registercreation(char* sig, unsigned long target) +void ick_registercreation(const char* sig, unsigned long target) { jicextract(sig)->target=target; } -unsigned long ick_jicmatch(char* sig) +unsigned long ick_jicmatch(const char* sig) { return jicextract(sig)->target; } diff --git a/src/dekludge.c b/src/dekludge.c index 84142b9..385fd1a 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(node* n1, node* n2) +ick_bool nodessame(const node* n1, const node* n2) { if(!n1) return !n2; if(!n2) return 0; @@ -101,7 +101,7 @@ ick_bool nodessame(node* n1, node* n2) } /* AIS: Checks if an abstention could affect a tuple. */ -int abstainmatch(int npconstant, int tptype) +static int abstainmatch(int npconstant, int tptype) { if(npconstant == tptype) return 1; if(npconstant == ABSTAIN) @@ -340,8 +340,8 @@ void optimizef(void) **************************************************************************/ extern int optimize_pass1(node *np); /* Read from idiotism.c */ -static void checkforintercaloperators(node *np); -static void checkW534(node *np); +static void checkforintercaloperators(const node *np); +static void checkW534(const node *np); node* optdebugnode; @@ -397,7 +397,7 @@ void nodefree(/*@keep@*/ /*@null@*/ node *np) } /* By AIS. This checks W534. */ -static void checkW534(node *np) +static void checkW534(const node *np) { if(!np) return; if(np->opcode == AND || np->opcode == OR || np->opcode == XOR) @@ -415,7 +415,7 @@ static void checkW534(node *np) } /* By AIS. This checks W018. */ -static void checkforintercaloperators(node *np) +static void checkforintercaloperators(const node *np) { if(!np) return; switch(np->opcode) diff --git a/src/feh.h b/src/feh.h index 4424b6e..63be732 100644 --- a/src/feh.h +++ b/src/feh.h @@ -11,7 +11,7 @@ extern void ppinit(int); /* AIS */ extern void typecast(node *np); extern void codecheck(void); extern void optimize(node *np); -/*@observer@*/ extern char *nameof(int value, assoc table[]); +/*@observer@*/ extern const char *nameof(int value, const assoc table[]); extern void emit(tuple *tn, FILE *fp); extern void emittextlines(FILE *fp); extern void emitslatproto(FILE *fp); /* AIS: emit prototypes for /-functions */ @@ -20,17 +20,17 @@ extern int comefromsearch(tuple *tn, unsigned int index); /* AIS */ extern void explexpr(node* np, FILE* fp); /* AIS */ extern void prexpr(node *np, FILE* fp, int freenode); /* AIS: destaticed */ extern void checknodeactbits(node *np); /* AIS */ -extern void optimizef(); /* AIS */ +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(node*); /* AIS */ -extern ick_bool nodessame(node*, node*); /* AIS */ +extern ick_bool nodessame(const node*, const node*); /* AIS */ extern node *optdebugnode; /* AIS */ -extern char **enablers; /* AIS: so that there can be an element before the - ick_first element of the ick_array (UNKNOWN is element - -1, just to cause a bit more confusion) */ -extern assoc vartypes[]; +extern const char **enablers; /* AIS: so that there can be an element before the + ick_first element of the ick_array (UNKNOWN is element + -1, just to cause a bit more confusion) */ +extern const assoc vartypes[]; extern int useprintflow; /* AIS */ diff --git a/src/feh2.c b/src/feh2.c index 6e095fe..485a922 100644 --- a/src/feh2.c +++ b/src/feh2.c @@ -459,7 +459,7 @@ void prexpr(node *np, FILE *fp, int freenode); * If the order of statement-token defines in parser.y ever changes, * this will need to be reordered. */ -char *enablersm1[MAXTYPES+1] = +const char *enablersm1[MAXTYPES+1] = { "UNKNOWN", /* AIS: so comments can be ABSTAINED/REINSTATED */ "GETS", @@ -495,64 +495,64 @@ char *enablersm1[MAXTYPES+1] = "COMPUCREATE", /* AIS */ "FROM", /* AIS: ABSTAIN expr FROM LABEL */ }; -char** enablers = enablersm1+1; +const char** enablers = enablersm1+1; -assoc vartypes[] = +const assoc vartypes[] = { { ick_ONESPOT, "ick_ONESPOT" }, { ick_TWOSPOT, "ick_TWOSPOT" }, { ick_TAIL, "ick_TAIL" }, { ick_HYBRID, "ick_HYBRID" }, - { 0, (char *)NULL } + { 0, (const char *)NULL } }; -static assoc forgetbits[] = +static const assoc forgetbits[] = { { ick_ONESPOT, "ick_oneforget" }, { ick_TWOSPOT, "ick_twoforget" }, { ick_TAIL, "ick_tailforget" }, { ick_HYBRID, "ick_hyforget" }, - { 0, (char *)NULL } + { 0, (const char *)NULL } }; /* AIS: Destatic. This is now needed in perpet.c. */ -assoc varstores[] = +const assoc varstores[] = { { ick_ONESPOT, "ick_onespots" }, { ick_TWOSPOT, "ick_twospots" }, { ick_TAIL, "ick_tails" }, { ick_HYBRID, "ick_hybrids" }, - { 0, (char *)NULL } + { 0, (const char *)NULL } }; /* AIS: A demangled version */ -static assoc varstoresdem[] = +static const assoc varstoresdem[] = { { ick_ONESPOT, "onespots" }, { ick_TWOSPOT, "twospots" }, { ick_TAIL, "tails" }, { ick_HYBRID, "hybrids" }, - { 0, (char *)NULL } + { 0, (const char *)NULL } }; -static assoc typedefs[] = +static const assoc typedefs[] = { { ick_ONESPOT, "ick_type16" }, { ick_TWOSPOT, "ick_type32" }, { ick_TAIL, "ick_type16" }, { ick_HYBRID, "ick_type32" }, - { 0, (char *)NULL } + { 0, (const char *)NULL } }; -/*@observer@*/ char *nameof(int value, assoc table[]) +/*@observer@*/ const char *nameof(int value, const assoc table[]) /* return string corresponding to value in table */ { - assoc *ap; + const assoc *ap; for (ap = table; ap->name; ap++) if (ap->value == value) return(ap->name); - return((char *)NULL); + return((const char *)NULL); } /* AIS: Code for printing explanations (mixed C/INTERCAL code that lets @@ -2719,7 +2719,7 @@ void emit(tuple *tn, FILE *fp) void emitslatproto(FILE* fp) { node* np=firstslat; - char* t="ick_type32"; + const char* t="ick_type32"; while(np) { fprintf(fp,"%s ick_og%lx(%s);\nvoid ick_os%lx(%s, void(*)());\n", @@ -2733,7 +2733,7 @@ void emitslat(FILE* fp) { node* np=firstslat; node* temp, *temp2; - char* t="ick_type32"; + const char* t="ick_type32"; while(np) { fprintf(fp, diff --git a/src/ick.h b/src/ick.h index 0caf499..60fefe3 100644 --- a/src/ick.h +++ b/src/ick.h @@ -114,7 +114,7 @@ atom; typedef struct { int value; - char *name; + const char *name; } assoc; @@ -128,9 +128,9 @@ extern int tuplecount; /*@dependent@*/ extern tuple *optuple; /* AIS: The tuple currently being optimized */ -extern char **enablers; -extern char *enablersm1[MAXTYPES+1]; -extern assoc vartypes[]; +extern const char **enablers; +extern const char *enablersm1[MAXTYPES+1]; +extern const assoc vartypes[]; /* the lexical analyzer keeps copies of the source logical lines */ /*@only@*/ extern char **textlines; diff --git a/src/ick_ec.c b/src/ick_ec.c index 65324c8..f25197d 100644 --- a/src/ick_ec.c +++ b/src/ick_ec.c @@ -270,7 +270,7 @@ void ick_settwospot(unsigned short extername, uint32_t value) /* Register a CREATE target. This is just a wrapper for ick_registercreation that gets around scoping problems. */ -void ick_create(char* sig, unsigned long target) +void ick_create(const char* sig, unsigned long target) { ick_registercreation(sig, target); } diff --git a/src/ick_ec.h b/src/ick_ec.h index 35dfd68..c123bb8 100644 --- a/src/ick_ec.h +++ b/src/ick_ec.h @@ -269,7 +269,7 @@ void ick_setonespot(unsigned short, uint16_t); uint32_t ick_gettwospot(unsigned short); void ick_settwospot(unsigned short, uint32_t); -void ick_create(char*, unsigned long); +void ick_create(const char*, unsigned long); /* For accessing the arguments to an ick_created command */ int ick_c_i_width(int); diff --git a/src/numerals.c b/src/numerals.c index 7c398ad..c5b800d 100644 --- a/src/numerals.c +++ b/src/numerals.c @@ -38,12 +38,12 @@ LICENSE TERMS typedef struct { - char *name; + const char *name; int value; } numeral; -numeral ick_numerals[] = +const numeral ick_numerals[] = { /* English */ { "OH", 0 }, diff --git a/src/perpet.c b/src/perpet.c index b0f20db..06e75c8 100644 --- a/src/perpet.c +++ b/src/perpet.c @@ -155,7 +155,7 @@ int tuplecount = 0; tuple *optuple = NULL; /* AIS: Tuple being optimized */ -extern assoc varstores[]; /* AIS: Need to know this for PIC compilation */ +extern const assoc varstores[]; /* AIS: Need to know this for PIC compilation */ #ifndef HAVE_UNISTD_H /* AIS: We don't have unistd.h, so we can't use getopt. Write our own version -- 2.43.0