Branch: Tag:

1999-08-21

1999-08-21 23:21:07 by Fredrik Noring <noring@nocrew.org>

More descriptive error messages for "index out of range" on strings and arrays.

Rev: src/array.c:1.53
Rev: src/opcodes.c:1.43

21:   #include "main.h"   #include "security.h"    - RCSID("$Id: array.c,v 1.52 1999/08/17 22:00:00 hubbe Exp $"); + RCSID("$Id: array.c,v 1.53 1999/08/21 23:21:06 noring Exp $");      struct array empty_array=   {
173:    tmp.type=T_ARRAY;    tmp.u.array=a;    if (a->size) { -  index_error(0,0,0,&tmp,ind,"Index %d is out of range 0 - %d.\n", i, a->size-1); +  index_error(0,0,0,&tmp,ind,"Index %d is out of array range 0 - %d.\n", i, a->size-1);    } else {    index_error(0,0,0,&tmp,ind,"Attempt to index the empty array with %d.\n", i);    }
245:    if(i<0) i+=a->size;    if(i<0 || i>=a->size) {    if (a->size) { -  error("Index %d is out of range 0 - %d.\n", i, a->size-1); +  error("Index %d is out of array range 0 - %d.\n", i, a->size-1);    } else {    error("Attempt to index the empty array with %d.\n", i);    }
950:    if(i<0) i+=a->size;    if(i<0 || i>=a->size) {    if (a->size) { -  error("Index %d is out of range 0 - %d.\n", i, a->size-1); +  error("Index %d is out of array range 0 - %d.\n", i, a->size-1);    } else {    error("Attempt to index the empty array with %d.\n", i);    }