pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
||
$Id: operators.c,v 1.193 2008/05/21 21:13:04 mast Exp $
+
||
$Id$
*/ #include "global.h" #include <math.h>
-
RCSID("
$Id: operators.c,v 1.193 2008/05/21 21:13:04 mast Exp $
");
+
RCSID("
$Id$
");
#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:3452:
case TWO_TYPES(T_ARRAY, T_INT): { struct array *a; ptrdiff_t size,e,pos; INT_TYPE len=sp[-1].u.integer; if(!len) OP_DIVISION_BY_ZERO_ERROR("`/");
+
if (!Pike_sp[-2].u.array->size) {
+
pop_n_elems (2);
+
ref_push_array (&empty_array);
+
return;
+
}
+
if(len<0) { len = -len; pos = sp[-2].u.array->size % len; }else{ pos = 0; } size = sp[-2].u.array->size / len; a=allocate_array(size);
pike.git/src/operators.c:3486:
case TWO_TYPES(T_ARRAY,T_FLOAT): { struct array *a; ptrdiff_t last,pos,e,size; FLOAT_ARG_TYPE len; len=sp[-1].u.float_number; if(len==0.0) OP_DIVISION_BY_ZERO_ERROR("`/");
+
if (!Pike_sp[-2].u.array->size) {
+
pop_n_elems (2);
+
ref_push_array (&empty_array);
+
return;
+
}
+
if(len<0) { len=-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 - (ptrdiff_t)((e+1)*len+0.5); a->item[size-1-e].u.array=friendly_slice_array(sp[-2].u.array,