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.190 2004/11/11 16:01:05 grubba Exp $ + || $Id: stralloc.c,v 1.191 2004/11/14 18:21:56 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:2038:    return ret;   }      PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    ptrdiff_t i;    int mag = min_magnitude(ch);       if (mag > s->s->size_shift) {    string_build_mkspace(s, 1, mag); -  s->known_shift = (size_t)mag; +  s->known_shift = mag;    } else if (((size_t)s->s->len) >= ((size_t)s->malloced)) {    string_build_mkspace(s, 1, mag); -  s->known_shift = MAXIMUM((size_t)mag, s->known_shift); +  s->known_shift = MAXIMUM(mag, s->known_shift);    }    i = s->s->len++;    low_set_index(s->s,i,ch);    /* Ensure NUL-termination */    s->s->str[s->s->len << s->s->size_shift] = 0;   }         PMOD_EXPORT void string_builder_binary_strcat(struct string_builder *s,    const char *str, ptrdiff_t len)
pike.git/src/stralloc.c:2166:   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,(size_t)str->size_shift); +  s->known_shift=MAXIMUM(s->known_shift,str->size_shift);    s->s->len+=str->len;    /* Ensure NUL-termination */    s->s->str[s->s->len << s->s->size_shift] = 0;   }      PMOD_EXPORT void string_builder_append_integer(struct string_builder *s,    LONGEST val,    unsigned int base,    int flags,    size_t min_width,
pike.git/src/stralloc.c:2617:      PMOD_EXPORT struct pike_string *finish_string_builder(struct string_builder *s)   {    /* Ensure NUL-termination */    low_set_index(s->s,s->s->len,0);    if (s->s->len <= SHORT_STRING_THRESHOLD) {    ptrdiff_t len = s->s->len;    s->s->len = s->malloced;    s->s = realloc_unlinked_string(s->s, len);    } -  if(s->known_shift == (size_t)s->s->size_shift) +  if(s->known_shift == 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);