pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include <math.h>   #include "global.h" - RCSID("$Id: operators.c,v 1.4 1996/11/27 03:47:02 hubbe Exp $"); + RCSID("$Id: operators.c,v 1.5 1997/01/27 01:27:13 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"   #include "opcodes.h"   #include "operators.h"   #include "language.h"   #include "memory.h"
pike.git/src/operators.c:88:    struct pike_string *r;    char *buf;       switch(args)    {    case 1: return;    default:    size=0;    for(e=-args;e<0;e++) size+=sp[e].u.string->len;    + #if 1 +  if(sp[-args].u.string->refs==1) +  { +  struct pike_string *tmp=sp[-args].u.string; +  +  unlink_pike_string(tmp); +  r=(struct pike_string *)realloc((char *)tmp, +  sizeof(struct pike_string)+size); +  +  if(!r) +  {    r=begin_shared_string(size); -  +  MEMCPY(r->str, sp[-args].u.string->str, sp[-args].u.string->len); +  free((char *)r); +  } +  +  buf=r->str + r->len; +  r->len=size; +  r->str[size]=0; +  +  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; +  } +  sp[-args].u.string=end_shared_string(r); +  for(e=-args+1;e<0;e++) free_string(sp[e].u.string); +  sp-=args-1; +  return; +  } + #endif +  r=begin_shared_string(size);    buf=r->str;    for(e=-args;e<0;e++)    { - #if 1 -  int q; -  for(q=0;q<sp[e].u.string->len;q++) -  buf[q]=sp[e].u.string->str[q]; - #else +     MEMCPY(buf,sp[e].u.string->str,sp[e].u.string->len); - #endif +     buf+=sp[e].u.string->len;    }    r=end_shared_string(r);    }       for(e=-args;e<0;e++) free_string(sp[e].u.string);    sp-=args;    push_string(r);    break;    }
pike.git/src/operators.c:1085:    error("Bad argument 2 to [ .. ]\n");       from=sp[-2].u.integer;    if(from<0) from=0;    to=sp[-1].u.integer;    if(to<from-1) to=from-1;    sp-=2;       switch(sp[-1].type)    { +  case T_OBJECT: +  CALL_OPERATOR(LFUN_INDEX, 2); +  break; +     case T_STRING:    {    struct pike_string *s;    if(to>=sp[-1].u.string->len-1)    {    if(from==0) return;    to=sp[-1].u.string->len-1;       if(from>to+1) from=to+1;    }
pike.git/src/operators.c:1123:    if(from>to+1) from=to+1;    }       a=slice_array(sp[-1].u.array,from,to+1);    free_array(sp[-1].u.array);    sp[-1].u.array=a;    break;    }       default: -  error("[ .. ] can only be done on strings and arrays.\n"); +  error("[ .. ] on non-scalar type.\n");    }   }      void f_sizeof(INT32 args)   {    INT32 tmp;    if(args<1)    error("Too few arguments to sizeof()\n");       tmp=pike_sizeof(sp-args);