pike.git / src / operators.c

version» Context lines:

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.170 2008/05/21 21:13:04 mast Exp $ + || $Id$   */      #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.170 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:2480:       case TWO_TYPES(T_ARRAY, T_INT):    {    struct array *a;    ptrdiff_t size,e,len,pos;       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:2514:    case TWO_TYPES(T_ARRAY,T_FLOAT):    {    struct array *a;    ptrdiff_t last,pos,e,size;    double 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,