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 "global.h" #include <math.h>
-
RCSID("$Id: operators.c,v 1.
95
2000/08/
03
17
:
52
:
55
grubba Exp $");
+
RCSID("$Id: operators.c,v 1.
96
2000/08/
09
15
:
07
:
34
grubba 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 "pike_memory.h"
pike.git/src/operators.c:156:
} bad_arg_error("`+", sp-args, args, 1, "string|object|int|float|array|mapping|multiset", sp-args, "Incompatible types\n"); return; /* compiler hint */ case BIT_STRING: { struct pike_string *r; PCHARP buf;
-
INT32
tmp;
+
ptrdiff_t
tmp;
int max_shift=0; if(args==1) return; size=0; 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;
pike.git/src/operators.c:1003:
sp[-1].type = T_TYPE; free_string(a); free_string(b); return; } #define STRING_BITOP(OP,STROP) \ case T_STRING: \ { \ struct pike_string *s; \
-
INT32
len, i;
\
+
ptrdiff_t
len, i; \
\ len = sp[-2].u.string->len; \ if (len != sp[-1].u.string->len) \ PIKE_ERROR("`" #OP, "Bitwise "STROP \ " on strings of different lengths.\n", sp, 2); \ if(!sp[-2].u.string->size_shift && !sp[-1].u.string->size_shift) \ { \ s = begin_shared_string(len); \ for (i=0; i<len; i++) \ s->str[i] = sp[-2].u.string->str[i] OP sp[-1].u.string->str[i]; \
pike.git/src/operators.c:1605:
sp[-2].u.array->type_field); ret->type_field=sp[-2].u.array->type_field; pop_n_elems(2); push_array(ret); return; } case TWO_TYPES(T_STRING, T_INT): { struct pike_string *ret; char *pos;
-
INT32
e
,
len;
+
INT_TYPE
e
;
+
ptrdiff_t
len;
if(sp[-1].u.integer < 0) SIMPLE_BAD_ARG_ERROR("`*", 2, "int(0..)"); ret=begin_wide_shared_string(sp[-2].u.string->len * sp[-1].u.integer, sp[-2].u.string->size_shift); pos=ret->str; len=sp[-2].u.string->len << sp[-2].u.string->size_shift; for(e=0;e<sp[-1].u.integer;e++,pos+=len) MEMCPY(pos,sp[-2].u.string->str,len); pop_n_elems(2); push_string(low_end_shared_string(ret));
pike.git/src/operators.c:1725:
if(sp[-2].type!=sp[-1].type && !float_promote()) { if(call_lfun(LFUN_DIVIDE, LFUN_RDIVIDE)) return; switch(TWO_TYPES(sp[-2].type,sp[-1].type)) { case TWO_TYPES(T_STRING,T_INT): { struct array *a;
-
INT32
size,e,
len,
pos=0;
+
INT_TYPE
len;
+
ptrdiff_t
size,e,pos=0;
len=sp[-1].u.integer; if(!len) OP_DIVISION_BY_ZERO_ERROR("`/"); if(len<0) { len=-len; size=sp[-2].u.string->len / len; pos+=sp[-2].u.string->len % len;
pike.git/src/operators.c:1755:
} a->type_field=BIT_STRING; pop_n_elems(2); push_array(a); return; } case TWO_TYPES(T_STRING,T_FLOAT): { struct array *a;
-
INT32
last
,pos,
e
,
size
;
+
ptrdiff_t
size
,
pos,
last,
e;
double len; len=sp[-1].u.float_number; if(len==0.0) OP_DIVISION_BY_ZERO_ERROR("`/"); if(len<0) { len=-len;
-
size=(
INT32
)ceil( ((double)sp[-2].u.string->len) / len);
+
size=(
ptrdiff_t
)ceil( ((double)sp[-2].u.string->len) / len);
a=allocate_array(size); for(last=sp[-2].u.string->len,e=0;e<size-1;e++) { pos=sp[-2].u.string->len - (INT32)((e+1)*len); a->item[size-1-e].u.string=string_slice(sp[-2].u.string, pos, last-pos); a->item[size-1-e].type=T_STRING; last=pos;
pike.git/src/operators.c:1811:
a->type_field=BIT_STRING; pop_n_elems(2); push_array(a); return; } case TWO_TYPES(T_ARRAY, T_INT): { struct array *a;
-
INT32
size,e,len,pos;
+
ptrdiff_t
size,e,len,pos;
len=sp[-1].u.integer; if(!len) OP_DIVISION_BY_ZERO_ERROR("`/"); if(len<0) { len = -len; pos = sp[-2].u.array->size % len; }else{
pike.git/src/operators.c:1844:
} a->type_field=BIT_ARRAY; pop_n_elems(2); push_array(a); return; } case TWO_TYPES(T_ARRAY,T_FLOAT): { struct array *a;
-
INT32
last,pos,e,size;
+
ptrdiff_t
last,pos,e,size;
double len; len=sp[-1].u.float_number; if(len==0.0) OP_DIVISION_BY_ZERO_ERROR("`/"); if(len<0) { len=-len;
-
size=(
INT32
)ceil( ((double)sp[-2].u.array->size) / len);
+
size
=
(
ptrdiff_t
)ceil( ((double)sp[-2].u.array->size) / len);
a=allocate_array(size); for(last=sp[-2].u.array->size,e=0;e<size-1;e++) { pos=sp[-2].u.array->size - (INT32)((e+1)*len); a->item[size-1-e].u.array=friendly_slice_array(sp[-2].u.array, pos, last); a->item[size-1-e].type=T_ARRAY; last=pos;
pike.git/src/operators.c:1934:
case T_FLOAT: if(sp[-1].u.float_number == 0.0) OP_DIVISION_BY_ZERO_ERROR("`/"); sp--; sp[-1].u.float_number /= sp[0].u.float_number; return; case T_INT: {
-
INT32
tmp;
+
INT_TYPE
tmp;
if (sp[-1].u.integer == 0) OP_DIVISION_BY_ZERO_ERROR("`/"); if(INT_TYPE_DIV_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer)) { #ifdef AUTO_BIGNUM stack_swap(); convert_stack_top_to_bignum(); stack_swap();
pike.git/src/operators.c:2015:
if(sp[-2].type != sp[-1].type && !float_promote()) { if(call_lfun(LFUN_MOD, LFUN_RMOD)) return; switch(TWO_TYPES(sp[-2].type,sp[-1].type)) { case TWO_TYPES(T_STRING,T_INT): { struct pike_string *s=sp[-2].u.string;
-
INT32
tmp,base;
+
ptrdiff_t
tmp,base;
+
if(!sp[-1].u.integer) OP_MODULO_BY_ZERO_ERROR("`%"); tmp=sp[-1].u.integer; if(tmp<0) { tmp=s->len % -tmp; base=0; }else{ tmp=s->len % tmp;
pike.git/src/operators.c:2349:
case T_ARRAY: { struct array *a; if(to >= sp[-1].u.array->size-1) { to = sp[-1].u.array->size-1; if(from>to+1) from=to+1; }
-
a=slice_array(sp[-1].u.array,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: PIKE_ERROR("`[]", "[ .. ] on non-scalar type.\n", sp, 3); } }