--- stack/stack.c 2002/03/12 14:53:19 1.105 +++ stack/stack.c 2002/03/12 22:03:21 1.108 @@ -37,12 +37,17 @@ #include /* EX_NOINPUT, EX_USAGE */ #include +/* assert */ +#include + +#ifdef __linux__ /* mtrace, muntrace */ #include /* ioctl */ #include /* KDMKTONE */ #include +#endif /* __linux__ */ #include "stack.h" @@ -118,6 +123,7 @@ stackitem *nitem= malloc(sizeof(stackitem)); nval->content.ptr= NULL; + nval->type= integer; nitem->item= nval; nitem->next= env->gc_ref; @@ -255,6 +261,7 @@ value *new_value= new_val(env); new_value->content.c= malloc(sizeof(cons)); + assert(new_value->content.c!=NULL); new_value->type= tcons; CAR(new_value)= val; CDR(new_value)= env->head; @@ -883,7 +890,9 @@ if(env->free_string!=NULL) free(env->free_string); +#ifdef __linux__ muntrace(); +#endif exit(EXIT_SUCCESS); } @@ -958,7 +967,9 @@ int c; /* getopt option character */ +#ifdef __linux__ mtrace(); +#endif init_env(&myenv); @@ -989,7 +1000,7 @@ } if(myenv.interactive) { - printf("Stack version $Revision: 1.105 $\n\ + printf("Stack version $Revision: 1.108 $\n\ Copyright (C) 2002 Mats Alritzson and Teddy Hogeborn\n\ Stack comes with ABSOLUTELY NO WARRANTY; for details type `warranty;'.\n\ This is free software, and you are welcome to redistribute it\n\ @@ -1256,7 +1267,6 @@ protect(old_value); new_value= new_val(env); - protect(new_value); new_value->type= old_value->type; switch(old_value->type){ @@ -1271,15 +1281,16 @@ strdup((char *)(old_value->content.ptr)); break; case tcons: - new_value= NULL; new_value->content.c= malloc(sizeof(cons)); + assert(new_value->content.c!=NULL); + CAR(new_value)= copy_val(env, CAR(old_value)); /* recurse */ CDR(new_value)= copy_val(env, CDR(old_value)); /* recurse */ break; } - unprotect(old_value); unprotect(new_value); + unprotect(old_value); return new_value; } @@ -1362,6 +1373,26 @@ eval(env); } +extern void sx_656c7365(environment *env) +{ + if(env->head==NULL || CDR(env->head)==NULL + || CDR(CDR(env->head))==NULL || CDR(CDR(CDR(env->head)))==NULL) { + printerr("Too Few Arguments"); + env->err= 1; + return; + } + + if(CAR(CDR(env->head))->type!=symb + || strcmp(CAR(CDR(env->head))->content.sym->id, "if")!=0) { + printerr("Bad Argument Type"); + env->err= 2; + return; + } + + swap(env); toss(env); + ifelse(env); +} + /* "while" */ extern void sx_7768696c65(environment *env) { @@ -1652,6 +1683,7 @@ return sx_72656164(env); } +#ifdef __linux__ extern void beep(environment *env) { int freq, dur, period, ticks; @@ -1694,6 +1726,7 @@ abort(); } } +#endif /* __linux__ */ /* "wait" */ extern void sx_77616974(environment *env)