pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:212:    *! @note    *! This function is provided for backward compatibility with    *! code written for Pike up and including version 7.4.    *!    *! This function is byte-order dependant.    *!    *! @seealso    *! @[hash()], @[hash_7_0]    */    - /*! @namespace 7.4:: -  */ -  +    #define MK_HASHMEM(NAME, TYPE) ATTRIBUTE((const)) \    static INLINE size_t NAME(const TYPE *str, ptrdiff_t len, ptrdiff_t maxn) \    { \    size_t ret,c; \    \    ret = len*92873743; \    \    len = MINIMUM(maxn,len); \    for(; len>=0; len--) \    { \
pike.git/src/builtin_functions.c:236:    ret ^= ( ret << 4 ) + c ; \    ret &= 0x7fffffff; \    } \    return ret; \    }      MK_HASHMEM(simple_hashmem, unsigned char)   MK_HASHMEM(simple_hashmem1, p_wchar1)   MK_HASHMEM(simple_hashmem2, p_wchar2)    - /*! @decl int hash(string s) -  *! @decl int hash(string s, int max) + /*! @decl int hash_7_4(string s) +  *! @decl int hash_7_4(string s, int max)    *!    *! Return an integer derived from the string @[s]. The same string    *! will always hash to the same value, also between processes.    *!    *! If @[max] is given, the result will be >= 0 and < @[max],    *! otherwise the result will be >= 0 and <= 0x7fffffff.    *!    *! @note    *! This function is provided for backward compatibility reasons.    *!
pike.git/src/builtin_functions.c:281:       if(!Pike_sp[1-args].u.integer)    PIKE_ERROR("7.4::hash", "Modulo by zero.\n", Pike_sp, args);       i%=(unsigned INT32)Pike_sp[1-args].u.integer;    }    pop_n_elems(args);    push_int64(i);   }    - /*! @endnamespace -  */ -  +    ATTRIBUTE((const)) static INLINE size_t hashstr(const unsigned char *str, ptrdiff_t maxn)   {    size_t ret,c;       if(!(ret=str++[0]))    return ret;    for(; maxn>=0; maxn--)    {    c=str++[0];    if(!c) break;
pike.git/src/builtin_functions.c:374:    *! The difference only affects wide strings.    *!    *! The hash algorithm was also changed in Pike 7.1. If you want a hash    *! that is compatible with Pike 7.0 and earlier, use @[7.0::hash()].    *!    *! @note    *! This hash function differs from the one provided by @[hash_value()],    *! in that @[hash_value()] returns a process specific value.    *!    *! @seealso -  *! @[hash_7_0()], @[7.4::hash()], @[hash_value] +  *! @[hash_7_0()], @[hash_7_4()], @[hash_value]    */   PMOD_EXPORT void f_hash(INT32 args)   {    size_t i = 0;    struct pike_string *s;       if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("hash",1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)