pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:16:   #include "pike_types.h"   #include "fsort.h"   #include "builtin_functions.h"   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "security.h"   #include "stuff.h"   #include "bignum.h"    - RCSID("$Id: array.c,v 1.89 2000/09/30 15:58:30 mast Exp $"); + RCSID("$Id: array.c,v 1.90 2000/10/10 01:20:37 hubbe Exp $");      PMOD_EXPORT struct array empty_array=   {    1, /* Never free */   #ifdef PIKE_SECURITY    0,   #endif    &empty_array, /* Next */    &empty_array, /* previous (circular) */    0, /* Size = 0 */
pike.git/src/array.c:1548:    return a;   }      PMOD_EXPORT struct array *append_array(struct array *a, struct svalue *s)   {    a=resize_array(a,a->size+1);    array_set_index(a, a->size-1, s);    return a;   }    + typedef char *(* explode_searchfunc)(void *,void *,size_t); +    PMOD_EXPORT struct array *explode(struct pike_string *str,    struct pike_string *del)   {    INT32 e;    struct array *ret;    char *s, *end, *tmp;      #if 0    if(!str->len)    {
pike.git/src/array.c:1570:   #endif    if(!del->len)    {    ret=allocate_array_no_init(str->len,0);    for(e=0;e<str->len;e++)    {    ITEM(ret)[e].type=T_STRING;    ITEM(ret)[e].u.string=string_slice(str,e,1);    }    }else{ -  struct generic_mem_searcher searcher; +  SearchMojt mojt; +  explode_searchfunc f;       s=str->str;    end=s+(str->len << str->size_shift);       ret=allocate_array(10);    ret->size=0;    -  init_generic_memsearcher(&searcher, -  del->str, +  mojt=compile_memsearcher(MKPCHARP_STR(del),    del->len, -  (char)del->size_shift, +     str->len, -  (char)str->size_shift); +  del);    -  while((tmp=(char *)generic_memory_search(&searcher, -  s, -  (end-s)>>str->size_shift, -  (char)str->size_shift))) +  switch(str->size_shift)    { -  +  case 0: f=(explode_searchfunc)mojt.vtab->func0; break; +  case 1: f=(explode_searchfunc)mojt.vtab->func1; break; +  case 2: f=(explode_searchfunc)mojt.vtab->func2; break; + #ifdef PIKE_DEBUG +  default: fatal("Illegal shift.\n"); + #endif +  } +  +  while((tmp = f(mojt.data, s, (end-s)>> str->size_shift))) +  {    if(ret->size == ret->malloced_size)    {    e=ret->size;    ret=resize_array(ret, e * 2);    ret->size=e;    }       ITEM(ret)[ret->size].u.string=string_slice(str,    (s-str->str)>>str->size_shift,    (tmp-s)>>str->size_shift);
pike.git/src/array.c:1619:    ret=resize_array(ret, e * 2);    ret->size=e;    }       ITEM(ret)[ret->size].u.string=string_slice(str,    (s-str->str)>>str->size_shift,    (end-s)>>str->size_shift);       ITEM(ret)[ret->size].type=T_STRING;    ret->size++; +  mojt.vtab->freeme(mojt.data);    }    ret->type_field=BIT_STRING;    return ret;   }      PMOD_EXPORT struct pike_string *implode(struct array *a,struct pike_string *del)   {    INT32 len,e, inited;    PCHARP r;    struct pike_string *ret,*tmp;