]> thyrsus.com Git - intercal.git/commitdiff
Various other const warnings fixed.
authorArvid Norlander <anmaster@tele2.se>
Tue, 18 Nov 2008 18:36:56 +0000 (13:36 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 00:35:20 +0000 (20:35 -0400)
src/abcess.h
src/arrgghh.c
src/cesspool.c
src/dekludge.c
src/feh.h
src/feh2.c
src/ick.h
src/ick_ec.c
src/ick_ec.h
src/numerals.c
src/perpet.c

index c0ad047c80667676f8428559780097089801b315..93844ea68772ab5d629e55f8670307a2672bb19a 100644 (file)
@@ -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
index ef55bf6c2897bb4176216d32463372d61361000e..53eb308b23482580e6dff76e39e0cec37bd507f4 100644 (file)
@@ -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] != '-') {
index 71e6511550de9329ee73e2025f59591b41e895ea..05b3be6fe3fd2be412e5907727cae2b2e6a1a08b 100644 (file)
@@ -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;
 }
index 84142b94205bd51602e89eb29bfd4b483d4efe5b..385fd1ad917eae949d6f8c8cdb021707a5b80dfa 100644 (file)
@@ -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)
index 4424b6efddd10f3c4f3dcbe3c2da45a283339588..63be73232f25484d59fc53a90abbe1950028349a 100644 (file)
--- 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 */
 
index 6e095fead4583c38a3e7de152359c0a8025623d4..485a922a3f710558580167d55c5e93edeab14301 100644 (file)
@@ -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,
index 0caf4996a907dce54e3501657748d1ec39cea06e..60fefe3d818603adf71de5bd37d4c26c8c69bee7 100644 (file)
--- 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;
index 65324c8a5996f0942724815301a2aa8810c3e790..f25197d31a13ca301230b4d5fd5d8d3002e3ac46 100644 (file)
@@ -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);
 }
index 35dfd6801e74dd49eabcc03794c081adf93dca2a..c123bb8628bb4a0740dd9100eac503167f644780 100644 (file)
@@ -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);
index 7c398adf24987ab16acbaa0637b2466deb2188bc..c5b800d11d69f1f249eeb6412c04e402ea256c0b 100644 (file)
@@ -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 },
index b0f20db819d2a4a91c80f7db75c5c63b8e62a7d5..06e75c861fae508e94b378a3f740e573015c4fca 100644 (file)
@@ -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