pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
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.
6
1997/
01
/
28
03
:
10
:
22
hubbe Exp $");
+
RCSID("$Id: operators.c,v 1.
7
1997/
02
/
11
07
:
11
:
51
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:80:
error("Bad argument 1 to summation\n"); } } error("Incompatible types to sum() or +\n"); return; /* compiler hint */ case BIT_STRING: { struct pike_string *r; char *buf;
+
INT32 tmp;
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;
-
+
tmp=
sp[-args].u.string->
len;
+
r=realloc
_
shared_
string
(
sp[-args].u.string,size);
+
sp[-args].
type=T_INT
;
+
buf=r->
str+tmp
;
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);
-
+
sp[-args].type=T_STRING;
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++)
-
{
-
MEMCPY(buf,sp[e].u.string->str,sp[e].u.string->len);
-
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; } case BIT_STRING | BIT_INT: case BIT_STRING | BIT_FLOAT: case BIT_STRING | BIT_FLOAT | BIT_INT: { struct pike_string *r; char *buf,*str; size=0;