pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:18:      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>      #ifndef HUGE   #define HUGE HUGE_VAL   #endif /*!HUGE*/    - RCSID("$Id: stralloc.c,v 1.90 2000/08/09 14:53:11 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.91 2000/08/09 18:46:10 grubba Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3      /* Experimental dynamic hash length */   #ifndef HASH_PREFIX   static unsigned int HASH_PREFIX=64;   static unsigned int need_more_hash_prefix=0;   #endif   
pike.git/src/stralloc.c:110: Inside #if defined(PIKE_DEBUG)
   if (s->len) {    fatal("String index %d is out of range [0 - %d]!\n", pos, s->len-1);    } else {    fatal("Attempt to index the empty string with %d!\n", pos);    }    }   #endif    return generic_extract(s->str,s->size_shift,pos);   }    - PMOD_EXPORT INLINE void low_set_index(struct pike_string *s, int pos, int value) + 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)    fatal("string index out of range!\n");       if(pos == s->len && value)    fatal("string zero termination foul!\n");   #endif    switch(s->size_shift)    {
pike.git/src/stralloc.c:1632:   PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    INT32 i;    string_build_mkspace(s,1,min_magnitude(ch));    s->known_shift=MAXIMUM(min_magnitude(ch),s->known_shift);    i=s->s->len++;    low_set_index(s->s,i,ch);   }       - PMOD_EXPORT void string_builder_binary_strcat(struct string_builder *s, char *str, INT32 len) + PMOD_EXPORT void string_builder_binary_strcat(struct string_builder *s, char *str, ptrdiff_t len)   {    string_build_mkspace(s,len,0);    switch(s->s->size_shift)    {    case 0: convert_0_to_0(STR0(s->s)+s->s->len,(p_wchar0 *)str,len); break;    case 1: convert_0_to_1(STR1(s->s)+s->s->len,(p_wchar0 *)str,len); break;    case 2: convert_0_to_2(STR2(s->s)+s->s->len,(p_wchar0 *)str,len); break;    default:    fatal("Illegal magnitude!\n");    }    s->s->len+=len;   }         PMOD_EXPORT void string_builder_append(struct string_builder *s,    PCHARP from, -  INT32 len) +  ptrdiff_t len)   {    string_build_mkspace(s,len,from.shift);    generic_memcpy(MKPCHARP_STR_OFF(s->s,s->s->len), from, len);    s->s->len+=len;   }      PMOD_EXPORT void string_builder_fill(struct string_builder *s, -  int howmany, +  ptrdiff_t howmany,    PCHARP from, -  INT32 len, -  INT32 offset) +  ptrdiff_t len, +  ptrdiff_t offset)   { -  INT32 tmp; +  ptrdiff_t tmp; +    #ifdef PIKE_DEBUG    if(len<=0)    fatal("Cannot fill with zero length strings!\n");   #endif    if(howmany<=0) return;       if(!s->s->size_shift &&    len == 1 &&    (!from.shift || !min_magnitude(EXTRACT_PCHARP(from))))    {    MEMSET(string_builder_allocate(s,howmany,0),    EXTRACT_PCHARP(from),    howmany);    return;    }       string_build_mkspace(s,howmany,from.shift); -  tmp=MINIMUM(howmany, len - offset); +  tmp = MINIMUM(howmany, len - offset);       generic_memcpy(MKPCHARP_STR_OFF(s->s,s->s->len),    ADD_PCHARP(from,offset),    tmp);    s->s->len+=tmp;    howmany-=tmp;    if(howmany > 0)    {    void *new_from;    PCHARP to;    tmp=MINIMUM(howmany, len);    to=MKPCHARP_STR_OFF(s->s,s->s->len);    generic_memcpy(to,from, tmp);    s->s->len+=tmp;    howmany-=tmp;       while(howmany > 0)    { -  tmp=MINIMUM(len, howmany); +  tmp = MINIMUM(len, howmany);    MEMCPY(s->s->str + (s->s->len << s->s->size_shift),    to.ptr,    tmp << s->s->size_shift);    len+=tmp;    howmany-=tmp;    s->s->len+=tmp;    }    }   }