/[cvs]/stack/stack.c
ViewVC logotype

Diff of /stack/stack.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.119 by teddy, Wed Mar 20 17:19:46 2002 UTC revision 1.120 by teddy, Thu Mar 21 03:19:32 2002 UTC
# Line 2451  extern void cons(environment *env) Line 2451  extern void cons(environment *env)
2451  /*  1: [ [ 1 . 2 ] [ 3 . 4 ] ]  =>  1: [ 3 . 4 ]  */  /*  1: [ [ 1 . 2 ] [ 3 . 4 ] ]  =>  1: [ 3 . 4 ]  */
2452  extern void assq(environment *env)  extern void assq(environment *env)
2453  {  {
2454      assocgen(env, eq);
2455    }
2456    
2457    
2458    /* General assoc function */
2459    void assocgen(environment *env, funcp eqfunc)
2460    {
2461    value *key, *item;    value *key, *item;
2462    
2463    /* Needs two values on the stack, the top one must be an association    /* Needs two values on the stack, the top one must be an association
# Line 2478  extern void assq(environment *env) Line 2485  extern void assq(environment *env)
2485      }      }
2486      push_val(env, key);      push_val(env, key);
2487      push_val(env, CAR(CAR(item)));      push_val(env, CAR(CAR(item)));
2488      eq(env); if(env->err) return;      eqfunc(env); if(env->err) return;
2489        
2490        /* Check the result of 'eqfunc' */
2491        if(env->head->type==empty) {
2492          printerr("Too Few Arguments");
2493          env->err= 1;
2494        return;
2495        }
2496        if(CAR(env->head)->type!=integer) {
2497          printerr("Bad Argument Type");
2498          env->err= 2;
2499          return;
2500        }
2501    
2502      if(CAR(env->head)->content.i){      if(CAR(env->head)->content.i){
2503        toss(env);        toss(env); if(env->err) return;
2504        break;        break;
2505      }      }
2506      toss(env);      toss(env); if(env->err) return;
2507    
2508        if(item->type!=tcons) {
2509          printerr("Bad Argument Type");
2510          env->err= 2;
2511          return;
2512        }
2513    
2514      item=CDR(item);      item=CDR(item);
2515    }    }
2516    

Legend:
Removed from v.1.119  
changed lines
  Added in v.1.120

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26