Branch: Tag:

1998-10-11

1998-10-11 11:18:53 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

more wide char support

Rev: src/array.c:1.40
Rev: src/builtin_functions.c:1.128
Rev: src/global.h:1.25
Rev: src/module_support.c:1.17
Rev: src/operators.c:1.41
Rev: src/pike_memory.c:1.26
Rev: src/pike_memory.h:1.6
Rev: src/stralloc.c:1.40
Rev: src/stralloc.h:1.19
Rev: src/testsuite.in:1.124

5:   \*/   #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.40 1998/09/18 21:34:28 hubbe Exp $"); + RCSID("$Id: operators.c,v 1.41 1998/10/11 11:18:52 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"
141:    struct pike_string *r;    char *buf;    INT32 tmp; +  int max_shift=0;    -  switch(args) -  { -  case 1: return; -  default: +  if(args==1) return; +     size=0; -  for(e=-args;e<0;e++) size+=sp[e].u.string->len; +  for(e=-args;e<0;e++) +  { +  size+=sp[e].u.string->len; +  if(sp[e].u.string->size_shift > max_shift) +  max_shift=sp[e].u.string->size_shift; +  }       tmp=sp[-args].u.string->len; -  r=realloc_shared_string(sp[-args].u.string,size); +  r=new_realloc_shared_string(sp[-args].u.string,size,max_shift);    sp[-args].type=T_INT; -  buf=r->str+tmp; +  buf=r->str+(tmp<<max_shift);    for(e=-args+1;e<0;e++)    { -  MEMCPY(buf,sp[e].u.string->str,sp[e].u.string->len); -  buf+=sp[e].u.string->len; +  pike_string_cpy(buf,max_shift,sp[e].u.string); +  buf+=sp[e].u.string->len << max_shift;    }    sp[-args].u.string=end_shared_string(r);    sp[-args].type=T_STRING;    for(e=-args+1;e<0;e++) free_string(sp[e].u.string);    sp-=args-1; -  } +        break;    }
172:    case BIT_STRING | BIT_FLOAT | BIT_INT:    {    struct pike_string *r; -  char *buf,*str; +  char *buf; +  char buffer[50]; +  int max_shift=0;    size=0;    for(e=-args;e<0;e++)    {
180:    {    case T_STRING:    size+=sp[e].u.string->len; +  if(sp[e].u.string->size_shift > max_shift) +  max_shift=sp[e].u.string->size_shift;    break;       case T_INT:
191:    break;    }    } -  str=buf=xalloc(size+1); +  +  r=begin_wide_shared_string(size,max_shift); +  buf=r->str;    size=0;       for(e=-args;e<0;e++)
199:    switch(sp[e].type)    {    case T_STRING: -  MEMCPY(buf,sp[e].u.string->str,sp[e].u.string->len); -  buf+=sp[e].u.string->len; +  pike_string_cpy(buf,max_shift,sp[e].u.string); +  buf+=sp[e].u.string->len<<max_shift;    break;       case T_INT: -  sprintf(buf,"%ld",(long)sp[e].u.integer); -  buf+=strlen(buf); -  break; +  sprintf(buffer,"%ld",(long)sp[e].u.integer); +  goto append_buffer;       case T_FLOAT: -  sprintf(buf,"%f",(double)sp[e].u.float_number); -  buf+=strlen(buf); -  break; +  sprintf(buffer,"%f",(double)sp[e].u.float_number); +  append_buffer: +  switch(max_shift) +  { +  case 0: convert_0_to_0((p_wchar0 *)buf,buffer,strlen(buffer)); break; +  case 1: convert_0_to_1((p_wchar1 *)buf,buffer,strlen(buffer)); break; +  case 2: convert_0_to_2((p_wchar2 *)buf,buffer,strlen(buffer)); break;    } -  +  buf+=strlen(buffer)<<max_shift;    } -  r=make_shared_binary_string(str,buf-str); -  free(str); +  } +  r->len=(buf-r->str)>>max_shift; +  low_set_index(r,r->len,0); +  r=end_shared_string(r);    pop_n_elems(args);    push_string(r);    break;
1725:    fatal("Error in o_range.\n");   #endif    -  s=make_shared_binary_string(sp[-1].u.string->str+from,to-from+1); +  s=string_slice(sp[-1].u.string, from, to-from+1);    free_string(sp[-1].u.string);    sp[-1].u.string=s;    break;