]> thyrsus.com Git - intercal.git/commitdiff
Portability changes, to run on K&R C compilers with unprotoize (unfinished)
authorAlex Smith <ais523@bham.ac.uk>
Wed, 1 Apr 2009 05:21:52 +0000 (01:21 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 00:35:37 +0000 (20:35 -0400)
src/bin2c.c
src/cesspool.c
src/clc-cset.c
src/ick_ec.c
src/ick_ec.h
src/numerals.c
src/yuk.h

index 63006979873bca11c7dd609126f9218dbacc74fe..25c347557b6ab107052b05efca925814561eded7 100644 (file)
@@ -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)
index 0ea2a291eaa1881fd262dbc8abd831d59724c5e7..fbb4a0f319913acb9152b6f2a63a220d63b5bbb3 100644 (file)
@@ -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;
index 551cc37a1913acd802d6bcad4076a89d37b67e1d..ce17d637c527f70e82332a7921d4d49ea3135f31 100644 (file)
@@ -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. */
index 7db2cef79305c5f3a9703f9103b3e125ac55619c..27c46298fe4eec87c4fd7b5f7c7326a09105cc69 100644 (file)
@@ -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);
index 03c5ff270fadb1d0f5f9a5fbe8918d5a151bc4a5..2d374412a20343f9b1625772e558f603477e2326 100644 (file)
@@ -49,6 +49,10 @@ LICENSE TERMS
 #if ICK_HAVE_STDINT_H+1 == 2
 #include <stdint.h>
 #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
index ecdee2bbb3433ba69001d7ff170424d5d2fa9272..77068de30ead2bc712dd034418eb6f3097fbfc04 100644 (file)
@@ -36,6 +36,8 @@ LICENSE TERMS
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "config.h"
+
 typedef struct
 {
     /*@observer@*/ const char *name;
index 998b6d67a0ef68682057138068ee8fc72887d2d7..742826409088a7c71d0c5d88ee186c3548f4bb8c 100644 (file)
--- 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