bridge/class-master/depend/pari/src/basemath/bibli2.c
/* return NULL if t_CLOSURE k is a "key" (arity 1) and not a sorting func */
return NULL if t_CLOSURE k is a "key" (arity 1) and not a sorting func
return NULL if t_CLOSURE k is a " key " ( arity 1 ) and not a sorting func
static CMP_FUN
sort_function(void **E, GEN x, GEN k)
{
  int (*cmp)(GEN,GEN) = &lexcmp;
  long tx = typ(x);
  if (!k)
  {
    *E = (void*)((typ(x) == t_VECSMALL)? cmp_small: cmp);
    return &cmp_nodata;
  }
  if (tx == t_VECSMALL) pari_err_TYPE("sort_function", x);
  switch(typ(k))
  {
    case t_INT: k = mkvecsmall(itos(k));  break;
    case t_VEC: case t_COL: k = ZV_to_zv(k); break;
    case t_VECSMALL: break;
    case t_CLOSURE:
     if (closure_is_variadic(k))
       pari_err_TYPE("sort_function, variadic cmpf",k);
     *E = (void*)k;
     switch(closure_arity(k))
     {
       case 1: return NULL; 
       case 2: return &closurecmp;
       default: pari_err_TYPE("sort_function, cmpf arity != 1, 2",k);
     }
    default: pari_err_TYPE("sort_function",k);
  }
  check_positive_entries(k);
  *E = (void*)k; return &veccmp;
}
static CMP_FUN sort_function ( void * * E , GEN x , GEN k ) { int ( * cmp ) ( GEN , GEN ) = & lexcmp ; long tx = typ ( x ) ; if ( ! k ) { * E = ( void * ) ( ( typ ( x ) == t_VECSMALL ) ? cmp_small : cmp ) ; return & cmp_nodata ; } if ( tx == t_VECSMALL ) pari_err_TYPE ( " " , x ) ; switch ( typ ( k ) ) { case t_INT : k = mkvecsmall ( itos ( k ) ) ; break ; case t_VEC : case t_COL : k = ZV_to_zv ( k ) ; break ; case t_VECSMALL : break ; case t_CLOSURE : if ( closure_is_variadic ( k ) ) pari_err_TYPE ( " " , k ) ; * E = ( void * ) k ; switch ( closure_arity ( k ) ) { case 1 : return NULL ; case 2 : return & closurecmp ; default : pari_err_TYPE ( " " , k ) ; } default : pari_err_TYPE ( " " , k ) ; } check_positive_entries ( k ) ; * E = ( void * ) k ; return & veccmp ; }
return NULL if t_CLOSURE k is a "key" (arity 1) and not a sorting func
return NULL if t_CLOSURE k is a " key " ( arity 1 ) and not a sorting func
/* wrt key */