Branch: Tag:

2014-08-27

2014-08-27 11:29:06 by Stephen R. van den Berg <srb@cuci.nl>

Support assigning characters which don't fit within the current shift size.

3121:    {    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);   
3132:    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);    }