pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.668 2008/05/29 20:08:14 nilsson Exp $ + || $Id: builtin_functions.c,v 1.669 2008/05/30 15:19:02 mast Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:7595:    }else{    ret=0;    }    pop_n_elems(args);    push_int(!!ret);   }      /*! @module Array    */    - #ifdef HAVE_UNION_INIT - static const struct svalue one = {PIKE_T_INT, NUMBER_NUMBER, {1}}; - #endif -  +    /*! @decl array uniq(array a)    *!    *! Remove elements that are duplicates.    *!    *! @returns    *! This function returns an copy of the array @[a] with all    *! duplicate values removed. The order of the values is kept in the    *! result; it's always the first of several equal elements that is    *! kept.    *!    *! @note    *! Elements are compared with @[`==]. They are also hashed (see    *! @[lfun::__hash] for further details if the array contains    *! objects).    */   PMOD_EXPORT void f_uniq_array(INT32 args)   {    struct array *a, *b;    struct mapping *m; - #ifndef HAVE_UNION_INIT -  struct svalue one; - #endif +     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));    - #ifndef HAVE_UNION_INIT -  one.type = T_INT; -  one.subtype = NUMBER_NUMBER; -  one.u.integer = 1; - #endif +     for(i =0; i< a->size; i++)    { -  mapping_insert(m, ITEM(a)+i, &one); +  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);