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.216 2008/05/02 04:15:16 mast Exp $ + || $Id: stralloc.c,v 1.217 2008/05/03 15:29:26 nilsson 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:150:   }      static INLINE unsigned INT32 generic_extract (const void *str, int size, ptrdiff_t pos)   {    switch(size)    {    case 0: return ((unsigned char *)str)[pos];    case 1: return ((unsigned INT16 *)str)[pos];    case 2: return ((unsigned INT32 *)str)[pos];    } + #ifdef PIKE_DEBUG    Pike_fatal("Illegal shift size!\n"); -  + #endif    return 0;   }      PMOD_EXPORT 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 %"PRINTPTRDIFFT"d is out of "
pike.git/src/stralloc.c:195: Inside #if defined(PIKE_DEBUG)
   }       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; + #ifdef PIKE_DEBUG    default:    Pike_fatal("Illegal shift size!\n"); -  + #endif    }    s->flags |= STRING_NOT_HASHED;   }      #ifdef PIKE_DEBUG   PMOD_EXPORT struct pike_string *debug_check_size_shift(struct pike_string *a,    int shift)   {    if(a->size_shift != shift)    Pike_fatal("Wrong STRX macro used!\n");
pike.git/src/stralloc.c:792:   /*    * This function checks if the shift size can be decreased before    * entering the string in the shared string table    */   PMOD_EXPORT struct pike_string *end_shared_string(struct pike_string *s)   {    struct pike_string *s2;       switch(s->size_shift)    { + #ifdef PIKE_DEBUG    default:    Pike_fatal("ARGHEL! size_shift:%d\n", s->size_shift); -  + #endif       case 2:    switch(find_magnitude2(STR2(s),s->len))    {    case 0:    s2=begin_shared_string(s->len);    convert_2_to_0(STR0(s2),STR2(s),s->len);    free_string(s);    s=s2;    break;
pike.git/src/stralloc.c:889:   PMOD_EXPORT struct pike_string * debug_make_shared_binary_pcharp(const PCHARP str,size_t len)   {    switch(str.shift)    {    case 0:    return make_shared_binary_string((char *)(str.ptr), len);    case 1:    return make_shared_binary_string1((p_wchar1 *)(str.ptr), len);    case 2:    return make_shared_binary_string2((p_wchar2 *)(str.ptr), len); + #ifdef PIKE_DEBUG    default:    Pike_fatal("Unknown string width!\n"); -  + #endif    }    /* NOT REACHED */    return NULL; /* Keep the compiler happy */   }      PMOD_EXPORT struct pike_string * debug_make_shared_pcharp(const PCHARP str)   {    return debug_make_shared_binary_pcharp(str, pcharp_strlen(str));   }   
pike.git/src/stralloc.c:1676:    free_string(a);    return end_shared_string(b);       case TWO_SIZES(2,1):    b=begin_wide_shared_string(a->len,2);    convert_1_to_2(STR2(b),STR1(a),a->len);    STR2(b)[index]=c;    free_string(a);    return end_shared_string(b);    + #ifdef PIKE_DEBUG    default:    Pike_fatal("Odd wide string conversion!\n"); -  + #endif    }    }          /* Next we test if the new string can be shrunk    * if all characters in the new string can fit in a string    * of a lower magnitude, it must be shrunk    */       if(min_magnitude(old_value) == a->size_shift &&
pike.git/src/stralloc.c:1877:    {    case 0:    return make_shared_binary_string((char *)STR0(s)+start,len);       case 1:    return make_shared_binary_string1(STR1(s)+start,len);       case 2:    return make_shared_binary_string2(STR2(s)+start,len);    } + #ifdef PIKE_DEBUG    Pike_fatal("Illegal shift size!\n"); -  + #endif    return 0;   }      /*** replace function ***/   typedef char *(* replace_searchfunc)(void *,void *,size_t);   PMOD_EXPORT struct pike_string *string_replace(struct pike_string *str,    struct pike_string *del,    struct pike_string *to)   {    struct pike_string *ret;
pike.git/src/stralloc.c:2997:   }      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);    case 2: return MKPCHARP(MEMCHR2((p_wchar2 *)ptr.ptr,chr,len),2);    } + #ifdef PIKE_DEBUG    Pike_fatal("Illegal shift in MEMCHR_PCHARP.\n"); -  + #endif    return MKPCHARP(0,0); /* make wcc happy */   }      #define DIGIT(x) (WIDE_ISDIGIT(x) ? (x) - '0' : \    WIDE_ISLOWER(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')   #define MBASE ('z' - 'a' + 1 + 10)      PMOD_EXPORT long STRTOL_PCHARP(PCHARP str, PCHARP *ptr, int base)   {    /* Note: Code duplication in STRTOL and pcharp_to_svalue_inumber. */
pike.git/src/stralloc.c:3440:   {    switch(s->size_shift)    {    case 0:    *to_free=0;    return STR0(s);    case 1:    case 2:    return 0;    + #ifdef PIKE_DEBUG    default:    Pike_fatal("Illegal shift size in string.\n"); -  + #endif    }    return 0;   }      PMOD_EXPORT p_wchar1 *require_wstring1(struct pike_string *s,    char **to_free)   {    switch(s->size_shift)    {    case 0:
pike.git/src/stralloc.c:3463:    convert_0_to_1((p_wchar1 *)*to_free, STR0(s),s->len+1);    return (p_wchar1 *)*to_free;       case 1:    *to_free=0;    return STR1(s);       case 2:    return 0;    + #ifdef PIKE_DEBUG    default:    Pike_fatal("Illegal shift size in string.\n"); -  + #endif    }    return 0;   }         PMOD_EXPORT p_wchar2 *require_wstring2(struct pike_string *s,    char **to_free)   {    switch(s->size_shift)    {
pike.git/src/stralloc.c:3489:       case 1:    *to_free=xalloc((s->len+1)*4);    convert_1_to_2((p_wchar2 *)*to_free, STR1(s),s->len+1);    return (p_wchar2 *)*to_free;       case 2:    *to_free=0;    return STR2(s);    + #ifdef PIKE_DEBUG    default:    Pike_fatal("Illegal shift size in string.\n"); -  + #endif    }    return 0;   }