From: Alex Smith Date: Wed, 1 Apr 2009 05:21:52 +0000 (-0400) Subject: Portability changes, to run on K&R C compilers with unprotoize (unfinished) X-Git-Tag: 0.29~142 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=cc761671c7d894f6b6ebb906659b52ccbcafe062;p=intercal.git Portability changes, to run on K&R C compilers with unprotoize (unfinished) --- diff --git a/src/bin2c.c b/src/bin2c.c index 6300697..25c3475 100644 --- a/src/bin2c.c +++ b/src/bin2c.c @@ -34,6 +34,7 @@ int main(int argc, char** argv) } (void) puts("/* This file is automatically generated; to modify it,"); (void) puts(" modify the source file, not this file. */"); + (void) puts("#include \"config.h\""); printf("const char* %s=\"\\\n",argv[1]); colno=0; while((c=getchar())!=EOF) diff --git a/src/cesspool.c b/src/cesspool.c index 0ea2a29..fbb4a0f 100644 --- a/src/cesspool.c +++ b/src/cesspool.c @@ -407,10 +407,10 @@ static void clcbinin(unsigned int type, ick_array *a, ick_bool forget) if(!forget) while(i--) if(type==ick_TAIL) a->data.tail[i]=(ick_type16)tempcp[i]+ - (ick_type16)((rand()/(RAND_MAX/256))*256); + (ick_type16)((rand()%256)*256); else a->data.hybrid[i]=(ick_type32)tempcp[i]+ - (ick_type32)((rand()/(RAND_MAX/256))*256); + (ick_type32)((rand()%256)*256); free(tempcp); free(buf); } @@ -722,10 +722,13 @@ void ick_stash(unsigned int type, unsigned int index, void *from, ick_overop* oo /* stash away the variable's value */ { /*@-nullassign@*/ - ick_overop dummyoo = {NULL, NULL}; + ick_overop dummyoo; /*@=nullassign@*/ /* create a new ick_stashbox and push it onto the stack */ - ick_stashbox *sp = (ick_stashbox*)malloc(sizeof(ick_stashbox)); + ick_stashbox *sp; + dummyoo.get = (ick_type32 (*)(ick_type32))NULL; + dummyoo.set = (void (*)(ick_type32, void(*)()))NULL; + sp = (ick_stashbox*)malloc(sizeof(ick_stashbox)); if (sp == NULL) ick_lose(IE222, ick_lineno, (const char *)NULL); sp->ick_next = ick_first; ick_first = sp; diff --git a/src/clc-cset.c b/src/clc-cset.c index 551cc37..ce17d63 100644 --- a/src/clc-cset.c +++ b/src/clc-cset.c @@ -192,7 +192,7 @@ static void ick_bitencout(char** pop, const struct cset* co, if(co->bitorder[i]>'l') { if((padstyle==1&&(i==1||i==9) && !(outword&(1<<(co->nbytes*8-i)))) || - (padstyle==2&&(rand()>RAND_MAX/2||!outword))) + (padstyle==2&&(rand()%2||!outword))) outword |= 1<<(co->nbytes*8-i-1); } /* Copy the appropriate bit from val to outword. */ diff --git a/src/ick_ec.c b/src/ick_ec.c index 7db2cef..27c4629 100644 --- a/src/ick_ec.c +++ b/src/ick_ec.c @@ -74,9 +74,14 @@ extern ick_overop* ick_oo_twospots; st = ick_jicmatch(unopstr); if(st) { - ick_createdata icd[3]={{16,0,1601,{og1,os1},arg1}, - {16,0,1602,{og2,os2},arg2}, - {16,0,1603,{og3,os3},0}}; + ick_createdata icd[3]; + icd[0].width=16; icd[1].width=16; icd[2].width=16; + icd[0].isarray=0; icd[1].isarray=0; icd[2].isarray=0; + icd[0].varnumber=1601; icd[1].varnumber=1602; icd[2].varnumber=1603; + icd[0].accessors.get=og1;icd[1].accessors.get=og2;icd[2].accessors.get=og3; + icd[0].accessors.set=os1;icd[1].accessors.set=os2;icd[2].accessors.set=os3; + icd[0].value=arg1; icd[1].value=arg2; icd[2].value=0; + ick_stash(ick_TWOSPOT, vi1, ick_twospots+vi1, ick_oo_twospots); ick_stash(ick_TWOSPOT, vi2, ick_twospots+vi2, ick_oo_twospots); ick_stash(ick_TWOSPOT, vi3, ick_twospots+vi3, ick_oo_twospots); diff --git a/src/ick_ec.h b/src/ick_ec.h index 03c5ff2..2d37441 100644 --- a/src/ick_ec.h +++ b/src/ick_ec.h @@ -49,6 +49,10 @@ LICENSE TERMS #if ICK_HAVE_STDINT_H+1 == 2 #include #else +/* Ensure that uint32_t, etc, aren't implemented as compatibility macros + so that we can implement them as typedefs. */ +#undef uint32_t +#undef uint16_t typedef unsigned int uint32_t; typedef unsigned short uint16_t; #endif diff --git a/src/numerals.c b/src/numerals.c index ecdee2b..77068de 100644 --- a/src/numerals.c +++ b/src/numerals.c @@ -36,6 +36,8 @@ LICENSE TERMS Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + typedef struct { /*@observer@*/ const char *name; diff --git a/src/yuk.h b/src/yuk.h index 998b6d6..7428264 100644 --- a/src/yuk.h +++ b/src/yuk.h @@ -144,3 +144,11 @@ extern yukvar yukvars[]; extern char** globalargv; extern int globalargc; /*@=exportlocal@*/ + +/* Give our own definition of sig_atomic_t for systems that don't have + it. char ought to be atomic, on most systems (especially as we don't + touch anything but the bottom byte). */ +#if SIZEOF_SIG_ATOMIC_T + 0 == 0 +#undef sig_atomic_t +typedef char sig_atomic_t +#endif