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.96 2000/08/11 13:44:03 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.97 2000/08/11 13:52:17 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:96:    switch(size)    {    case 0: return ((unsigned char *)str)[pos];    case 1: return ((unsigned INT16 *)str)[pos];    case 2: return ((unsigned INT32 *)str)[pos];    }    fatal("Illegal shift size!\n");    return 0;   }    - PMOD_EXPORT INLINE unsigned INT32 index_shared_string(struct pike_string *s, ptrdiff_t pos) + 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) { -  fatal("String index %d is out of range [0 - %d]!\n", pos, s->len-1); +  fatal("String index %ld is out of range [0 - %ld]!\n", +  DO_NOT_WARN((long)pos), +  DO_NOT_WARN((long)s->len-1));    } else { -  fatal("Attempt to index the empty string with %d!\n", pos); +  fatal("Attempt to index the empty string with %ld!\n", +  DO_NOT_WARN((long)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
pike.git/src/stralloc.c:178:    }   }         PMOD_EXPORT void generic_memcpy(PCHARP to,    PCHARP from,    ptrdiff_t len)   {   #ifdef PIKE_DEBUG    if(len<0) -  fatal("Cannot copy %d bytes!\n",len); +  fatal("Cannot copy %ld bytes!\n", +  DO_NOT_WARN((long)len));   #endif       switch(TWO_SIZES(from.shift,to.shift))    {    case TWO_SIZES(0,0):    convert_0_to_0((p_wchar0 *)to.ptr,(p_wchar0 *)from.ptr,len);    break;    case TWO_SIZES(0,1):    convert_0_to_1((p_wchar1 *)to.ptr,(p_wchar0 *)from.ptr,len);    break;
pike.git/src/stralloc.c:1372:    return (r-haystack->str)>>haystack->size_shift;   }      PMOD_EXPORT struct pike_string *string_slice(struct pike_string *s,    ptrdiff_t start,    ptrdiff_t len)   {   #ifdef PIKE_DEBUG    if(start < 0 || len<0 || start+len>s->len )    { -  fatal("string_slice, start = %d, len = %d, s->len = %d\n",start,len,s->len); +  fatal("string_slice, start = %ld, len = %ld, s->len = %ld\n", +  DO_NOT_WARN((long)start), +  DO_NOT_WARN((long)len), +  DO_NOT_WARN((long)s->len));    }   #endif       if(start==0 && len==s->len)    {    add_ref(s);    return s;    }       switch(s->size_shift)
pike.git/src/stralloc.c:1607:    {    struct pike_string *n;    ptrdiff_t l = s->s->len + chars + s->malloced;    n=begin_wide_shared_string(l,mag);    pike_string_cpy(MKPCHARP_STR(n),s->s);    n->len=s->s->len;    s->malloced=l;    free((char *)s->s);    s->s=n;    } -  else if(s->s->len+chars > s->malloced) +  else if(((size_t)s->s->len+chars) > ((size_t)s->malloced))    { -  ptrdiff_t newlen = MAXIMUM(s->malloced*2, s->s->len + chars); +  size_t newlen = MAXIMUM((size_t)(s->malloced*2), +  (size_t)(s->s->len + chars));       s->s=(struct pike_string *)realloc((char *)s->s,    sizeof(struct pike_string)+    ((newlen+1)<<s->s->size_shift));    if(!s->s)    fatal("Out of memory.\n");    s->malloced=newlen;    }   }   
pike.git/src/stralloc.c:1634:    if(chars<0) s->known_shift=0;    ret = s->s->str + (s->s->len<<s->s->size_shift);    s->s->len += chars;    return ret;   }      PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    ptrdiff_t i;    string_build_mkspace(s,1,min_magnitude(ch)); -  s->known_shift=MAXIMUM(min_magnitude(ch),s->known_shift); +  s->known_shift=MAXIMUM((size_t)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, ptrdiff_t len)   {    string_build_mkspace(s,len,0);    switch(s->s->size_shift)    {
pike.git/src/stralloc.c:1729:   PMOD_EXPORT void string_builder_strcat(struct string_builder *s, char *str)   {    string_builder_binary_strcat(s,str,strlen(str));   }      PMOD_EXPORT void string_builder_shared_strcat(struct string_builder *s, struct pike_string *str)   {    string_build_mkspace(s,str->len,str->size_shift);       pike_string_cpy(MKPCHARP_STR_OFF(s->s,s->s->len), str); -  s->known_shift=MAXIMUM(s->known_shift,str->size_shift); +  s->known_shift=MAXIMUM(s->known_shift,(size_t)str->size_shift);    s->s->len+=str->len;   }         PMOD_EXPORT void reset_string_builder(struct string_builder *s)   {    s->known_shift=0;    s->s->len=0;   }      PMOD_EXPORT void free_string_builder(struct string_builder *s)   {    free((char *)s->s);   }      PMOD_EXPORT struct pike_string *finish_string_builder(struct string_builder *s)   {    low_set_index(s->s,s->s->len,0); -  if(s->known_shift == s->s->size_shift) +  if(s->known_shift == (size_t)s->s->size_shift)    return low_end_shared_string(s->s);    return end_shared_string(s->s);   }      PMOD_EXPORT PCHARP MEMCHR_PCHARP(PCHARP ptr, int chr, ptrdiff_t len)   {    switch(ptr.shift)    {    case 0: return MKPCHARP(MEMCHR0(ptr.ptr,chr,len),0);    case 1: return MKPCHARP(MEMCHR1((p_wchar1 *)ptr.ptr,chr,len),1);