--- stack/stack.c 2002/03/12 14:06:05 1.104 +++ stack/stack.c 2002/03/12 21:05:11 1.107 @@ -37,12 +37,15 @@ #include /* EX_NOINPUT, EX_USAGE */ #include + +#ifdef __linux__ /* mtrace, muntrace */ #include /* ioctl */ #include /* KDMKTONE */ #include +#endif /* __linux__ */ #include "stack.h" @@ -467,7 +470,7 @@ printf("\"%s\"", (char*)CAR(stack_head)->content.ptr); break; case symb: - printf("%s", ((symbol *)(CAR(stack_head)->content.ptr))->id); + printf("%s", CAR(stack_head)->content.sym->id); break; case func: printf("#", (funcp)(CAR(stack_head)->content.ptr)); @@ -594,7 +597,7 @@ return; } - val= ((symbol *)(CAR(env->head)->content.ptr))->val; + val= CAR(env->head)->content.sym->val; if(val == NULL){ printerr("Unbound Variable"); env->err= 3; @@ -655,7 +658,7 @@ push_val(env, CAR(iterator)); if(CAR(env->head)->type==symb - && (((symbol*)(CAR(env->head)->content.ptr))->id[0]==';')) { + && CAR(env->head)->content.sym->id[0]==';') { toss(env); if(env->err) return; @@ -717,14 +720,14 @@ iterator= env->head; if(iterator==NULL || (CAR(iterator)->type==symb - && ((symbol*)(CAR(iterator)->content.ptr))->id[0]=='[')) { + && CAR(iterator)->content.sym->id[0]=='[')) { temp= NULL; toss(env); } else { /* Search for first delimiter */ while(CDR(iterator)!=NULL && (CAR(CDR(iterator))->type!=symb - || ((symbol*)(CAR(CDR(iterator))->content.ptr))->id[0]!='[')) + || CAR(CDR(iterator))->content.sym->id[0]!='[')) iterator= CDR(iterator); /* Extract list */ @@ -883,7 +886,9 @@ if(env->free_string!=NULL) free(env->free_string); +#ifdef __linux__ muntrace(); +#endif exit(EXIT_SUCCESS); } @@ -940,7 +945,7 @@ return; } - sym_id= ((symbol*)(CAR(stack_head)->content.ptr))->id; + sym_id= CAR(stack_head)->content.sym->id; toss(env); return forget_sym(hash(env->symbols, sym_id)); @@ -958,7 +963,9 @@ int c; /* getopt option character */ +#ifdef __linux__ mtrace(); +#endif init_env(&myenv); @@ -989,7 +996,7 @@ } if(myenv.interactive) { - printf("Stack version $Revision: 1.104 $\n\ + printf("Stack version $Revision: 1.107 $\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\ @@ -1013,7 +1020,7 @@ return EXIT_SUCCESS; /* EOF */ } else if(myenv.head!=NULL && CAR(myenv.head)->type==symb - && ((symbol*)(CAR(myenv.head)->content.ptr))->id[0] + && CAR(myenv.head)->content.sym->id[0] ==';') { toss(&myenv); /* No error check in main */ eval(&myenv); @@ -1362,6 +1369,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) { @@ -1488,7 +1515,7 @@ push_val(env, CAR(iterator)); push_val(env, loop); eval(env); if(env->err) return; - if (CDR(iterator)->type == tcons){ + if (iterator->type == tcons){ iterator= CDR(iterator); } else { printerr("Bad Argument Type"); /* Improper list */ @@ -1537,15 +1564,14 @@ if(iterator==NULL || (CAR(iterator)->type==symb - && ((symbol*)(CAR(iterator)->content.ptr))->id[0]=='[')) { + && CAR(iterator)->content.sym->id[0]=='[')) { temp= NULL; toss(env); } else { /* Search for first delimiter */ - while(CDR(iterator)!=NULL + while(CDR(iterator)!=NULL && (CAR(CDR(iterator))->type!=symb - || ((symbol*)(CAR(CDR(iterator))->content.ptr))->id[0] - !='[')) + || CAR(CDR(iterator))->content.sym->id[0]!='[')) iterator= CDR(iterator); /* Extract list */ @@ -1653,6 +1679,7 @@ return sx_72656164(env); } +#ifdef __linux__ extern void beep(environment *env) { int freq, dur, period, ticks; @@ -1695,6 +1722,7 @@ abort(); } } +#endif /* __linux__ */ /* "wait" */ extern void sx_77616974(environment *env)