From: Arvid Norlander Date: Sat, 28 Mar 2009 21:56:12 +0000 (-0400) Subject: Update IFFI to support cfunge r633. X-Git-Tag: 0.29~149 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=b4f5e49ec0506e6e9f684e7ec4e3f11c79e21e90;p=intercal.git Update IFFI to support cfunge r633. --- diff --git a/etc/IFFI.spec b/etc/IFFI.spec index 48f24c2..3288a32 100644 --- a/etc/IFFI.spec +++ b/etc/IFFI.spec @@ -1,4 +1,4 @@ -%fingerprint-spec 1.2 +%fingerprint-spec 1.4 %fprint:IFFI %url:http://example.com %desc:INTERCAL-like Foreign Function Interface diff --git a/etc/IFFI/IFFI.c b/etc/IFFI/IFFI.c index 221fd17..ecaadc3 100644 --- a/etc/IFFI/IFFI.c +++ b/etc/IFFI/IFFI.c @@ -93,7 +93,7 @@ void ick_interpreter_run(void) void ick_iffi_interpreter_one_iteration(void) { - fungeCell opcode; + funge_cell opcode; opcode = fungespace_get(&iffiIP->position); if (setting_trace_level > 8) { @@ -110,7 +110,7 @@ void ick_iffi_interpreter_one_iteration(void) execute_instruction(opcode, iffiIP); if (iffiIP->needMove) - ip_forward(iffiIP, 1); + ip_forward(iffiIP); else iffiIP->needMove = true; } @@ -119,15 +119,15 @@ void ick_iffi_interpreter_one_iteration(void) static void finger_IFFI_create(instructionPointer * ip) { // arguments: line number on TOS, signature as 0gnirts beneath it - fungeCell l = stack_pop(ip->stack); - unsigned char * restrict str = stack_pop_string(ip->stack); + funge_cell l = stack_pop(ip->stack); + unsigned char * restrict str = stack_pop_string(ip->stack, NULL); ick_create((const char*)str, l); } // C - In markmode COME FROM the top of stack static void finger_IFFI_come_from(instructionPointer * ip) { - fungeCell l; + funge_cell l; l = stack_pop(ip->stack); @@ -148,7 +148,7 @@ static void finger_IFFI_create_data(instructionPointer * ip) // 0 if the argument is not a variable, or its number if it is // The argument's value at the time the CREATED instruction was called // The argument's value now (same as previous if -a was not used) - fungeCell i; + funge_cell i; if (firstload) { ip_reverse(ip); @@ -167,7 +167,7 @@ static void finger_IFFI_create_data(instructionPointer * ip) // F - FORGET NEXT stack entries equal to top of stack static void finger_IFFI_forget(instructionPointer * ip) { - fungeCell f; + funge_cell f; if (firstload) { ip_reverse(ip); @@ -193,7 +193,7 @@ static void finger_IFFI_var_get(instructionPointer * ip) // var numbers are positive for onespot, negative for twospot // return: the value of the variable - fungeCell v; + funge_cell v; if (firstload) { ip_reverse(ip); @@ -214,7 +214,7 @@ static void finger_IFFI_var_get(instructionPointer * ip) // L - Use top of stack as a line label for this point static void finger_IFFI_label(instructionPointer * ip) { - fungeCell l; + funge_cell l; if (firstload) { ip_reverse(ip); @@ -238,7 +238,7 @@ static void finger_IFFI_marker(instructionPointer * ip) // N - Try to NEXT to the line labelled with the top of stack static void finger_IFFI_next(instructionPointer * ip) { - fungeCell l; + funge_cell l; if (firstload) { ip_reverse(ip); @@ -260,7 +260,7 @@ static void finger_IFFI_next(instructionPointer * ip) // R - RESUME to the top-of-stackth NEXT stack entry static void finger_IFFI_resume(instructionPointer * ip) { - fungeCell f; + funge_cell f; if (firstload) { ip_reverse(ip); @@ -290,7 +290,7 @@ static void finger_IFFI_var_set(instructionPointer * ip) // var numbers are positive for onespot, negative for twospot // return: the value of the variable - fungeCell v, d; + funge_cell v, d; if (firstload) { ip_reverse(ip); @@ -314,7 +314,7 @@ static void finger_IFFI_arg_set(instructionPointer * ip) { // arguments: 0-based argument index on TOS, new value beneath it // note that this is a NOP unless -a was used when compiling - fungeCell i, d; + funge_cell i, d; if (firstload) { ip_reverse(ip); @@ -330,7 +330,7 @@ static void finger_IFFI_arg_set(instructionPointer * ip) // X - In markmode NEXT FROM the top of stack static void finger_IFFI_next_from(instructionPointer * ip) { - fungeCell l; + funge_cell l; l = stack_pop(ip->stack); diff --git a/etc/IFFI/IFFI.h b/etc/IFFI/IFFI.h index 1c70e23..88d82db 100644 --- a/etc/IFFI/IFFI.h +++ b/etc/IFFI/IFFI.h @@ -30,8 +30,12 @@ #include "../../global.h" #include "../manager.h" +#if !defined(CFUNGE_API_VERSION) || (CFUNGE_API_VERSION != 1) +# error "This version of IFFI isn't compatible with this cfunge version." +#endif + #ifdef CONCURRENT_FUNGE -#error The C-INTERCAL/cfunge external calls interface cannot be used concurrently +# error "The C-INTERCAL/cfunge external calls interface cannot be used concurrently." #endif // We need at least GCC 4.1 for this trick. diff --git a/etc/cftoec.sh b/etc/cftoec.sh index 0965eab..b9fccf3 100644 --- a/etc/cftoec.sh +++ b/etc/cftoec.sh @@ -102,7 +102,7 @@ echo " " Adding the IFFI fingerprint... cp -r "$ICKSRC_PATH/etc/IFFI" "$ICKSRC_PATH/etc/IFFI.spec" src/fingerprints echo " " Regenerating fingerprint lists... -$CFUNGE_PATH/tools/gen_fprint_list.sh > /dev/null || die "Failed to regen list." +tools/gen_fprint_list.sh > /dev/null || die "Failed to regen list." # Trust the filenames that are in the cfunge directory tree; if the user's # trying to trick themselves into running this on something that looks like diff --git a/src/cesspool.c b/src/cesspool.c index 05b3be6..0ea2a29 100644 --- a/src/cesspool.c +++ b/src/cesspool.c @@ -460,7 +460,7 @@ static void clcbinout(unsigned int type, const ick_array* a) while(i--) if(tempcp[i] == '\0') tempcp[i]='\x1a'; if(!ick_cesspoolout) ick_cesspoolout=stdout; fprintf(ick_cesspoolout,"%s\n",tempcp); - fflush(ick_cesspoolout); + (void) fflush(ick_cesspoolout); free(tempcp); free(buf); } diff --git a/src/dekludge.c b/src/dekludge.c index 59823fa..73f26a0 100644 --- a/src/dekludge.c +++ b/src/dekludge.c @@ -58,7 +58,7 @@ extern void prexpr(node *np, FILE* fp, int freenode); /* AIS */ just with extra arrows in. The annotations here show that nulls are allowed when called recursively, but not otherwise. */ /*@-incondefs@*/ -/*@null@*/ node *nodecopy(/*@null@*/ node* n) +/*@null@*/ node *nodecopy(/*@null@*/ const node* n) /*@=incondefs@*/ { node* np; @@ -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(const node* n1, const node* n2) +ick_bool nodessame(/*@observer@*/ const node* n1, /*@observer@*/ const node* n2) { if(!n1) return !n2; if(!n2) return 0; diff --git a/src/feh.h b/src/feh.h index 63be732..1876fb0 100644 --- a/src/feh.h +++ b/src/feh.h @@ -23,8 +23,8 @@ extern void checknodeactbits(node *np); /* 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(const node*, const node*); /* AIS */ +extern node *nodecopy(const node*); /* AIS */ +extern ick_bool nodessame(/*@observer@*/ const node*, /*@observer@*/ const node*); /* AIS */ extern node *optdebugnode; /* AIS */ extern const char **enablers; /* AIS: so that there can be an element before the diff --git a/src/feh2.c b/src/feh2.c index 2790d3b..827a639 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. */ -const char *enablersm1[MAXTYPES+1] = +/*@observer@*/ const char *enablersm1[MAXTYPES+1] = { "UNKNOWN", /* AIS: so comments can be ABSTAINED/REINSTATED */ "GETS", @@ -1594,10 +1594,10 @@ static int prunknownstr(node *np, FILE* fp) case BADCHAR: if (np->constant > 256) (void) fprintf(fp, "o%xx%x", - (int)(np->constant / 256), - (int)(np->constant % 256)); + (unsigned int)(np->constant / 256), + (unsigned int)(np->constant % 256)); else - (void) fprintf(fp, "u%x", (int)np->constant); + (void) fprintf(fp, "u%x", (unsigned int)np->constant); return 2; case US_ID: (void) fputc((char)np->constant, fp); return 0; case US_ELEM: (void) fputc(';', fp); return 1; diff --git a/src/ick.h b/src/ick.h index 60fefe3..e45231d 100644 --- a/src/ick.h +++ b/src/ick.h @@ -129,7 +129,7 @@ extern int tuplecount; /*@dependent@*/ extern tuple *optuple; /* AIS: The tuple currently being optimized */ extern const char **enablers; -extern const char *enablersm1[MAXTYPES+1]; +/*@observer@*/ extern const char *enablersm1[MAXTYPES+1]; extern const assoc vartypes[]; /* the lexical analyzer keeps copies of the source logical lines */ diff --git a/src/numerals.c b/src/numerals.c index 024228e..ecdee2b 100644 --- a/src/numerals.c +++ b/src/numerals.c @@ -38,8 +38,8 @@ LICENSE TERMS typedef struct { - const char *name; - int value; + /*@observer@*/ const char *name; + const int value; } numeral; diff --git a/src/perpet.c b/src/perpet.c index 468c95f..02607d6 100644 --- a/src/perpet.c +++ b/src/perpet.c @@ -544,7 +544,7 @@ static void handle_befunge98(char *libbuf, size_t libbuf_size, else if(c=='\n' && jlb) {jlb = 0; continue;} else if(c=='\n') {x=0; y++; jlb = 0;} else x++; - fprintf(of,"\\x%x",c); + fprintf(of,"\\x%x",(unsigned int)c); if(!x) fprintf(of,"\"\n\""); } fprintf(of,"\";\n\nint ick_iffi_markercount=%d;\n" @@ -555,7 +555,7 @@ static void handle_befunge98(char *libbuf, size_t libbuf_size, markerposns[markercount][1]); fprintf(of,"};\n"); - fclose(of); + (void) fclose(of); /* Put the libraries and .cio file in the command line. */ ick_snprintf_or_die(libbuf+strlen(libbuf),libbuf_size - strlen(libbuf), @@ -1516,10 +1516,10 @@ static void run_cc_and_maybe_debugger(/*@observer@*/ const char *cc_command, * @param cooptsh Path to coopt.sh * @param binaryname The output binary filename. */ -static void run_coopt(/*@observer@*/ /*@null@*/ const char* cooptsh, - /*@observer@*/ const char* binaryname) +static void run_coopt(/*@observer@*/ /*@null@*/ /*@unused@*/ const char* cooptsh, + /*@observer@*/ /*@unused@*/ const char* binaryname) { - char commandlinebuf[BUFSIZ]; + /* Note: Params are marked unused because they may not be used if sh isn't supported. */ #ifdef HAVE_PROG_SH # ifdef HAVE_SYS_INTERPRETER if(coopt) /* AIS */ @@ -1532,6 +1532,7 @@ static void run_coopt(/*@observer@*/ /*@null@*/ const char* cooptsh, WRITE IN. Double-oh-sevens screw this up, too. */ if(cooptsh) { + char commandlinebuf[BUFSIZ]; (void) ick_snprintf_or_die(commandlinebuf, sizeof commandlinebuf, "sh %s %s", cooptsh, binaryname); ICK_SYSTEM(commandlinebuf); /* replaces the output executable if @@ -1799,7 +1800,7 @@ int main(int argc, char *argv[]) #endif oldoptind=optind; /* AIS */ - *libbuf = 0; /* AIS */ + *libbuf = '\0'; /* AIS */ /* Begin file loop */ for (firstfile = ick_TRUE; optind < argc; optind++, firstfile = ick_FALSE) { @@ -1885,7 +1886,7 @@ int main(int argc, char *argv[]) it instead adds a space and the filename to libbuf. */ handle_archive(libbuf, sizeof libbuf, argv[optind] /* Archive name without extension. */); - *argv[optind]=0; + *argv[optind]='\0'; continue; }