pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:12:   #include "interpret.h"   #include "language.h"   #include "error.h"   #include "pike_types.h"   #include "fsort.h"   #include "builtin_functions.h"   #include "pike_memory.h"   #include "gc.h"   #include "main.h"    - RCSID("$Id: array.c,v 1.35 1998/04/27 22:33:17 hubbe Exp $"); + RCSID("$Id: array.c,v 1.36 1998/04/28 23:54:21 grubba Exp $");      struct array empty_array=   {    1, /* Never free */    &empty_array, /* Next */    &empty_array, /* previous (circular) */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    0, /* no flags */
pike.git/src/array.c:154:      void simple_array_index_no_free(struct svalue *s,    struct array *a,struct svalue *ind)   {    INT32 i;    switch(ind->type)    {    case T_INT:    i=ind->u.integer;    if(i<0) i+=a->size; -  if(i<0 || i>=a->size) error("Index out of range.\n"); +  if(i<0 || i>=a->size) { +  if (a->size) { +  error("Index %d is out of range 0 - %d.\n", i, a->size-1); +  } else { +  error("Attempt to index the empty array with %d.\n", i); +  } +  }    array_index_no_free(s,a,i);    break;       case T_STRING:    check_stack(4);    ref_push_array(a);    assign_svalue_no_free(sp++,ind);    f_column(2);    s[0]=sp[-1];    sp--;
pike.git/src/array.c:211:   }         void simple_set_index(struct array *a,struct svalue *ind,struct svalue *s)   {    INT32 i;    if(ind->type != T_INT)    error("Index is not an integer.\n");    i=ind->u.integer;    if(i<0) i+=a->size; -  if(i<0 || i>=a->size) error("Index out of range.\n"); +  if(i<0 || i>=a->size) { +  if (a->size) { +  error("Index %d is out of range 0 - %d.\n", i, a->size-1); +  } else { +  error("Attempt to index the empty array with %d.\n", i); +  } +  }    array_set_index(a,i,s);   }      /*    * Insert an svalue into an array, grow the array if nessesary    */   struct array *array_insert(struct array *v,struct svalue *s,INT32 index)   {   #ifdef DEBUG    if(index<0 || index>v->size)
pike.git/src/array.c:880:    */   union anything *array_get_item_ptr(struct array *a,    struct svalue *ind,    TYPE_T t)   {    INT32 i;    if(ind->type != T_INT)    error("Index is not an integer.\n");    i=ind->u.integer;    if(i<0) i+=a->size; -  if(i<0 || i>=a->size) error("Index out of range.\n"); +  if(i<0 || i>=a->size) { +  if (a->size) { +  error("Index %d is out of range 0 - %d.\n", i, a->size-1); +  } else { +  error("Attempt to index the empty array with %d.\n", i); +  } +  }    return low_array_get_item_ptr(a,i,t);   }      /*    * organize an array of INT32 to specify how to zip two arrays together    * to maintain the order.    * the first item in this array is the size of the result    * the rest is n >= 0 for a[ n ]    * or n < 0 for b[ ~n ]    */