pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.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: stralloc.c,v 1.155 2003/04/07 15:28:47 mast Exp $ + || $Id: stralloc.c,v 1.156 2003/05/15 15:33:31 mast Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "pike_error.h"   #include "gc.h"
pike.git/src/stralloc.c:17:   #include "bignum.h"   #include "interpret.h"   #include "block_alloc.h"   #include "operators.h"      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>    - RCSID("$Id: stralloc.c,v 1.155 2003/04/07 15:28:47 mast Exp $"); + RCSID("$Id: stralloc.c,v 1.156 2003/05/15 15:33:31 mast Exp $");      /* #define STRALLOC_USE_PRIMES */      #ifdef STRALLOC_USE_PRIMES      #define SET_HSIZE(X) htable_size=hashprimes[(X)]   #define HMODULO(X) ((X) % htable_size)      #else   
pike.git/src/stralloc.c:160:    Pike_fatal("Illegal shift size!\n");    return 0;   }      PMOD_EXPORT INLINE unsigned INT32 index_shared_string(struct pike_string *s,    ptrdiff_t pos)   {   #ifdef PIKE_DEBUG    if(pos > s->len || pos<0) {    if (s->len) { -  Pike_fatal("String index %ld is out of range [0 - %ld]!\n", -  DO_NOT_WARN((long)pos), -  DO_NOT_WARN((long)s->len-1)); +  Pike_fatal("String index %"PRINTPTRDIFFT"d is out of " +  "range 0..%"PRINTPTRDIFFT"d.\n", +  pos, s->len-1);    } else { -  Pike_fatal("Attempt to index the empty string with %ld!\n", -  DO_NOT_WARN((long)pos)); +  Pike_fatal("Attempt to index the empty string with %"PRINTPTRDIFFT"d.\n", +  pos);    }    }   #endif    return generic_extract(s->str,s->size_shift,pos);   }      PMOD_EXPORT INLINE void low_set_index(struct pike_string *s, ptrdiff_t pos,    int value)   {   #ifdef PIKE_DEBUG -  if(pos > s->len || pos<0) -  Pike_fatal("string index out of range!\n"); +  if(pos > s->len || pos<0) { +  if (s->len) { +  Pike_fatal("String index %"PRINTPTRDIFFT"d is out of " +  "range 0..%"PRINTPTRDIFFT"d.\n", +  pos, s->len-1); +  } else { +  Pike_fatal("Attempt to index the empty string with %"PRINTPTRDIFFT"d.\n", +  pos); +  } +  }       if(pos == s->len && value)    Pike_fatal("string zero termination foul!\n");   #endif    switch(s->size_shift)    {    case 0: STR0(s)[pos]=value; break;    case 1: STR1(s)[pos]=value; break;    case 2: STR2(s)[pos]=value; break;    default: