pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:7853:    *! objects).    */   PMOD_EXPORT void f_uniq_array(INT32 args)   {    struct array *a, *b;    struct mapping *m;    int i, j=0,size=0;       get_all_args("uniq", args, "%a", &a);    push_mapping(m = allocate_mapping(a->size)); -  push_array(b = allocate_array(a->size)); +  b = allocate_array(a->size);       for(i =0; i< a->size; i++)    {    mapping_insert(m, ITEM(a)+i, &svalue_int_one);    if(m_sizeof(m) != size)    {    size=m_sizeof(m);    assign_svalue_no_free(ITEM(b)+ j++, ITEM(a)+i);    }    } -  dmalloc_touch_svalue(Pike_sp-1); -  Pike_sp--; /* keep the ref to 'b' */ -  ACCEPT_UNFINISHED_TYPE_FIELDS { -  b=resize_array(b, j); -  } END_ACCEPT_UNFINISHED_TYPE_FIELDS; +     b->type_field = a->type_field; -  pop_n_elems(args-1); /* pop args and the mapping */ +  b=array_shrink(b, j);    push_array(b);   }      /*! @decl array(mixed) splice(array(mixed) arr1, array(mixed) arr2, @    *! array(mixed) ... more_arrays)    *!    *! Splice two or more arrays.    *!    *! This means that the returned array has the first element in the    *! first given array, then the first argument in next array and so
pike.git/src/builtin_functions.c:7899:    INT32 size=0x7fffffff;    INT32 i,j,k;       for(i=0;i<args;i++)    if (TYPEOF(Pike_sp[i-args]) != T_ARRAY)    SIMPLE_BAD_ARG_ERROR("splice", i+1, "array");    else    if (Pike_sp[i-args].u.array->size < size)    size=Pike_sp[i-args].u.array->size;    -  out=allocate_array(args * size); -  if (!args) +  if(!args || !size)    { -  push_array(out); +  push_empty_array();    return;    }    -  +  out=allocate_array(args * size);    out->type_field=0; -  for(i=-args; i<0; i++) out->type_field|=Pike_sp[i].u.array->type_field; +        for(k=j=0; j<size; j++)    for(i=-args; i<0; i++) -  assign_svalue_no_free(out->item+(k++), Pike_sp[i].u.array->item+j); +  { +  assign_svalue_no_free(out->item+k, Pike_sp[i].u.array->item+j); +  out->type_field |= (1<<TYPEOF(*(out->item+(k++)))); +  }    -  pop_n_elems(args); +     push_array(out);    return;   }      /*! @decl array(mixed) everynth(array(mixed) a, void|int n, @    *! void|int start)    *!    *! Return an array with every @[n]:th element of the array @[a].    *!    *! If @[n] is zero every other element will be returned.
pike.git/src/builtin_functions.c:7965:    }       a=allocate_array(((size=ina->size)-start+n-1)/n);    types = 0;    for(k=0; start<size; k++, start+=n) {    assign_svalue_no_free(ITEM(a) + k, ina->item+start);    types |= 1 << TYPEOF(ITEM(a)[k]);    }    a->type_field=types;    -  pop_n_elems(args); +     push_array(a);    return;   }      /*! @decl array(array) transpose(array(array) matrix)    *! Takes an array of equally sized arrays (essentially a matrix of size M*N)    *! and returns the transposed (N*M) version of it, where rows and columns    *! are exchanged for one another.    */   PMOD_EXPORT void f_transpose(INT32 args)
pike.git/src/builtin_functions.c:7995:    SIMPLE_TOO_FEW_ARGS_ERROR("transpose", 1);       if (TYPEOF(Pike_sp[-args]) != T_ARRAY)    SIMPLE_BAD_ARG_ERROR("transpose", 1, "array(array)");       in=Pike_sp[-args].u.array;    sizein=in->size;       if(!sizein)    { -  pop_n_elems(args); -  out=allocate_array(0); -  push_array(out); +  push_empty_array();    return;    }       if( (in->type_field != BIT_ARRAY) &&    (array_fix_type_field(in) != BIT_ARRAY) )    SIMPLE_BAD_ARG_ERROR("transpose", 1, "array(array)");       sizeininner=in->item->u.array->size;       for(i=1 ; i<sizein; i++)
pike.git/src/builtin_functions.c:8032:    ett=outinner->item;    tva=in->item;    for(i=0; i<sizein; i++)    assign_svalue_no_free(ett+i, tva[i].u.array->item+j);       outinner->type_field=type;    SET_SVAL(out->item[j], T_ARRAY, 0, array, outinner);    }       out->type_field=BIT_ARRAY; -  pop_n_elems(args); +     push_array(out);    return;   }      /*! @endmodule    */      #ifdef PIKE_DEBUG   /*! @decl void locate_references(string|array|mapping| @    *! multiset|function|object| @