pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:249:   }      static INLINE int min_magnitude(p_wchar2 c)   {    if(c<0) return 2;    if(c<256) return 0;    if(c<65536) return 1;    return 2;   }    - static INLINE p_wchar2 generic_extract (const void *str, int size, ptrdiff_t pos) - { -  switch(size) -  { -  case 0: return ((p_wchar0 *)str)[pos]; -  case 1: return ((p_wchar1 *)str)[pos]; -  case 2: return ((p_wchar2 *)str)[pos]; -  } - #ifdef PIKE_DEBUG -  Pike_fatal("Illegal shift size!\n"); - #endif -  return 0; - } -  - PMOD_EXPORT p_wchar2 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 " -  "range 0..%"PRINTPTRDIFFT"d.\n", -  pos, s->len-1); -  } else { -  Pike_fatal("Attempt to index the empty string with %"PRINTPTRDIFFT"d.\n", -  pos); -  } -  } - #endif -  return generic_extract(s->str,s->size_shift,pos); - } -  +    void low_set_index(struct pike_string *s, ptrdiff_t pos, int value)   {   #ifdef PIKE_DEBUG    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",
pike.git/src/stralloc.c:402:   }         #ifdef PIKE_DEBUG   #ifdef DEBUG_MALLOC   #define DM(X) X   #else   #define DM(X)   #endif    + PMOD_EXPORT p_wchar2 index_shared_string(struct pike_string *s, +  ptrdiff_t pos) + { +  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); +  } +  } +  return generic_extract(s->str,s->size_shift,pos); + } +  + PMOD_EXPORT p_wchar2 generic_extract (const void *str, int size, ptrdiff_t pos) + { +  switch(size) +  { +  case 0: return ((p_wchar0 *)str)[pos]; +  case 1: return ((p_wchar1 *)str)[pos]; +  case 2: return ((p_wchar2 *)str)[pos]; +  } +  Pike_fatal("Unsupported string shift: %d\n", size); +  return 0; + } +    static void locate_problem(int (*isproblem)(struct pike_string *))   {    unsigned INT32 e;    struct pike_string *s;    DM(struct memhdr *yes=alloc_memhdr());    DM(struct memhdr *no=alloc_memhdr());       for(e=0;e<htable_size;e++)    {    LOCK_BUCKET(e);