pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:3114:    push_object (res);    }    }       /*! @decl int `[]=(int index, int ch)    */    PIKEFUN int `[]=(int index, int ch)    {    struct Buffer_struct *str = THIS;    struct pike_string *s = str->str.s; -  unsigned len = s->len, shift = s->size_shift; -  void *p = s->str; +  unsigned len = s->len;       pop_n_elems(args);       if (index<0)    index += len;    if (index<0 || index>=len)    index_error("Buffer->`[]=", Pike_sp, args, NULL, Pike_sp,    "Index %"PRINTPIKEINT"d is out of array range 0..%d,\n",    index, len-1); -  p = (char*)p+(index<<shift); -  if (!shift) -  *(p_wchar0*)p = ch; -  else if(shift==1) -  *(p_wchar1*)p = ch; +  if ((unsigned)ch >= 256) +  switch(s->size_shift) { +  case 0: +  if ((unsigned)ch < 65536) +  len = 1; +  else { +  case 1: +  if((unsigned)ch >= 65536) +  len = 2;    else -  *(p_wchar2*)p = ch; +  break; +  } +  string_build_mkspace(&str->str, 0, str->str.known_shift = len); +  } +  low_set_index(str->str.s,index,ch);    push_int(ch);    }       /*! @decl Buffer `+( string|Buffer what )    */    PIKEFUN object `+( string|Buffer what )    rawtype tFunc(tOr(tString, tObjIs_BUFFER), tObjIs_BUFFER);    {    struct Buffer_struct *str = THIS, *str2;    struct object *res = fast_clone_object( Buffer_program );