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.204 2006/03/10 18:53:24 grubba Exp $ + || $Id: stralloc.c,v 1.205 2006/03/11 12:30:40 grubba 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:1393:      /* does not take locale into account */   PMOD_EXPORT ptrdiff_t generic_quick_binary_strcmp(const char *a,    ptrdiff_t alen, int asize,    const char *b,    ptrdiff_t blen, int bsize)   {    if(!asize && !bsize)    {    int tmp; +  /* FIXME: Does MEMCMP() guarantee that the characters +  * are compared as unsigned? +  * /grubba 2006-03-11 +  */    if(alen > blen)    {    tmp=MEMCMP(a, b, blen);    if(tmp) return tmp;    return 1;    }else if(alen < blen){    tmp=MEMCMP(a, b, alen);    if(tmp) return tmp;    return -1;    }else{    return MEMCMP(a, b, alen);    }    }else{ -  INT32 pos; +  ptrdiff_t pos;    for(pos=0;pos< MINIMUM(alen,blen) ;pos++)    { -  INT32 ac=generic_extract(a,asize,pos); -  INT32 bc=generic_extract(b,bsize,pos); +  p_wchar2 ac=generic_extract(a,asize,pos); +  p_wchar2 bc=generic_extract(b,bsize,pos);    if(ac != bc) {    if (ac < bc) return -1;    return 1;    }    }    return alen-blen;    }   }      /* Does not take locale into account
pike.git/src/stralloc.c:1439:    const char *b,    ptrdiff_t blen, int bsize)   {    ptrdiff_t pos;    ptrdiff_t len = MINIMUM(alen, blen);    switch(TWO_SIZES(asize, bsize)) {   #define CASE(AZ, BZ) \    case TWO_SIZES(AZ, BZ): { \    PIKE_CONCAT(p_wchar, AZ) *a_arr = \    (PIKE_CONCAT(p_wchar, AZ) *)a; \ -  PIKE_CONCAT(p_wchar, AZ) *b_arr = \ -  (PIKE_CONCAT(p_wchar, AZ) *)b; \ +  PIKE_CONCAT(p_wchar, BZ) *b_arr = \ +  (PIKE_CONCAT(p_wchar, BZ) *)b; \    for (pos=0; pos<len; pos++) { \    if (a_arr[pos] == b_arr[pos]) \    continue; \    if (a_arr[pos] < b_arr[pos]) \    return ~pos; \    return pos+1; \    } \    } break    CASE(0,0);    CASE(0,1);