From: Arvid Norlander Date: Tue, 18 Nov 2008 17:25:17 +0000 (-0500) Subject: First const patch. X-Git-Tag: 0.29~190 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=00841542ee19e3d4a586f9896e23abf202d7840d;p=intercal.git First const patch. --- diff --git a/src/ick_ec.h b/src/ick_ec.h index 0aaccf2..35dfd68 100644 --- a/src/ick_ec.h +++ b/src/ick_ec.h @@ -293,7 +293,7 @@ void ick_c_i_setvalue(int, uint32_t); #define ICK_IE778 "778 UNEXPLAINED COMPILER BUG\n\ ON THE WAY TO %d\n" -extern void /*@noreturn@*/ ick_lose(char *m, int n, /*@null@*/ char *s) +extern void /*@noreturn@*/ ick_lose(const char *m, int n, /*@null@*/ const char *s) #ifdef __GNUC__ __attribute__ ((noreturn)) #endif diff --git a/src/ick_lose.c b/src/ick_lose.c index d33b6a3..b38158c 100644 --- a/src/ick_lose.c +++ b/src/ick_lose.c @@ -32,7 +32,7 @@ int ick_coreonerr = 0; /* AIS */ int ick_checkforbugs; /* AIS */ /*@-formatconst@*/ -void ick_lose(char *m, int n, char *s) +void ick_lose(const char *m, int n, const char *s) { (void) fflush(stdout); /* AIS: To stop stdout getting muddled with stderr*/ (void) fprintf(stderr, @@ -52,7 +52,7 @@ void ick_lose(char *m, int n, char *s) } /* AIS: This function reports potential bugs. It's paraphrased from ick_lose. */ -void ick_lwarn(char *m, int n, char *s) +void ick_lwarn(const char *m, int n, const char *s) { if(!ick_checkforbugs) return; /* Don't report a potential bug without -l */ (void) fflush(stdout); diff --git a/src/ick_lose.h b/src/ick_lose.h index 1684b18..fb36e51 100644 --- a/src/ick_lose.h +++ b/src/ick_lose.h @@ -242,12 +242,12 @@ extern int ick_lineno; -extern void /*@noreturn@*/ ick_lose(char *m, int n, /*@null@*/ char *s) +extern void /*@noreturn@*/ ick_lose(const char *m, int n, /*@null@*/ const char *s) #ifdef __GNUC__ __attribute__ ((noreturn)) #endif ; -extern void ick_lwarn(char *m, int n, /*@null@*/ char *s); +extern void ick_lwarn(const char *m, int n, /*@null@*/ const char *s); /* ick_lose.h ends here */ diff --git a/src/perpet.c b/src/perpet.c index d68d475..7f2b2c8 100644 --- a/src/perpet.c +++ b/src/perpet.c @@ -143,7 +143,7 @@ static int smallsizes[8] = {0, 0, 16, 10, 8, 6, 6, 5}; static unsigned int maxsmalls[8] = {0, 0, 65535, 59048, 65535, 15624, 46655, 16806}; -/*@observer@*/ static char *compiler; +/*@observer@*/ static const char *compiler; atom *oblist = NULL, *obdex; int obcount = 0; @@ -193,7 +193,7 @@ static RETSIGTYPE abend(int signim) /*@-noeffect@*/ (void) signim; /*@=noeffect@*/ ick_lose(IE778, iyylineno, (char *)NULL); } -static void print_usage(char *prog, char *options) +static void print_usage(const char *prog, const char *options) { fprintf(stderr,"Usage: %s [-%s] [ ...]\n",prog,options); fprintf(stderr,"\t-b\t:reduce the probability of E774 to zero\n"); @@ -263,13 +263,15 @@ static void print_usage(char *prog, char *options) fprintf(stderr,"\t\tfor base 2 or .3i, etc., for base 3, etc.).\n"); } +#if __DJGPP__ /* AIS: Determine whether an environment variable exists (this is used to find a temp directory) */ -int isenv(char* e) +static int isenv(char* e) { char* x=getenv(e); return x != NULL && *x != '\0'; } +#endif /*@-redef@*/ int main(int argc, char *argv[]) @@ -284,10 +286,10 @@ int main(int argc, char *argv[]) atom *op; int c, i; /*@-shadow@*/ /* no it doesn't, cesspool isn't linked to perpet */ - char *includedir, *libdir, *ick_datadir; + const char *includedir, *libdir, *ick_datadir; /*@=shadow@*/ /* AIS: removed getenv(), added ick_datadir */ - char *cooptsh; /* AIS */ + const char *cooptsh; /* AIS */ FILE *ifp, *ofp; int maxabstain, /* nextcount, AIS */ bugline; ick_bool needsyslib, firstfile; @@ -528,7 +530,7 @@ int main(int argc, char *argv[]) along the same lines as CLC-INTERCAL's preloads. Search for it in the usual places, then make a copy in a temp directory and substitute that on the command line. */ - char* tempfn; + const char* tempfn; FILE* fromcopy; FILE* tocopy; int c2; @@ -1656,7 +1658,7 @@ int main(int argc, char *argv[]) FILE* cioallec; char* buf2ptr; long remspace; - char* tempfn="ickectmp.c"; + const char* tempfn="ickectmp.c"; int needc99=0; #if __DJGPP__ /* Look for a temp directory, as above. */ diff --git a/src/uncommon.c b/src/uncommon.c index abc98be..2ef57c2 100644 --- a/src/uncommon.c +++ b/src/uncommon.c @@ -26,8 +26,8 @@ LICENSE TERMS /* Options that might affect this */ int ick_printfopens=0; -/*@dependent@*/ /*@null@*/ FILE* ick_debfopen(/*@observer@*/ char* fname, - /*@observer@*/ char* mode) +/*@dependent@*/ /*@null@*/ FILE* ick_debfopen(/*@observer@*/ const char* fname, + /*@observer@*/ const char* mode) { FILE* t; if(ick_printfopens) fprintf(stderr,"Trying to open '%s'...\n",fname); @@ -43,13 +43,13 @@ int ick_printfopens=0; overflows, instead truncating filenames (and if that manages to find them, I'll be incredibly surprised). It also tries argv[0]/../lib and argv[0]/../include (where they are when running without installing). */ -/*@dependent@*/ /*@null@*/ FILE* ick_findandfopen(/*@observer@*/ char* file, - /*@observer@*/ char* guessdir, - /*@observer@*/ char* mode, - /*@observer@*/ char* argv0) +/*@dependent@*/ /*@null@*/ FILE* ick_findandfopen(/*@observer@*/ const char* file, + /*@observer@*/ const char* guessdir, + /*@observer@*/ const char* mode, + /*@observer@*/ const char* argv0) { static char buf2[BUFSIZ]; - /*@observer@*/ static char *fileiter; + /*@observer@*/ static const char *fileiter; size_t i = 0, j; FILE* ret; while(*guessdir != '\0' && i