pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:254:    *! 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 with    *! code written for Pike up and including version 7.4.    *!    *! This function is byte-order dependant for wide strings.    *!    *! @seealso -  *! @[hash()], @[hash_7_0] +  *! @[hash_7_6()], @[hash_7_0]    */   static void f_hash_7_4(INT32 args)   {    size_t i = 0;    struct pike_string *s = Pike_sp[-args].u.string;       if(!args)    SIMPLE_WRONG_NUM_ARGS_ERROR("7.4::hash",1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)
pike.git/src/builtin_functions.c:350:       if(!Pike_sp[1-args].u.integer)    PIKE_ERROR("7.0::hash", "Modulo by zero.\n", Pike_sp, args);       i%=(unsigned INT32)Pike_sp[1-args].u.integer;    }    pop_n_elems(args);    push_int( i );   }    - /*! @decl int hash(string s) -  *! @decl int hash(string s, int max) + /*! @decl int hash_7_8(string s) +  *! @decl int hash_7_8(string s, int max)    *!    *! Return an integer derived from the string @[s]. The same string    *! always hashes to the same value, also between processes,    *! architectures, and Pike versions (see compatibility notes below,    *! though).    *!    *! If @[max] is given, the result will be >= 0 and < @[max],    *! otherwise the result will be >= 0 and <= 0x7fffffff.    *! -  +  *! @deprecated +  *! +  *! Use @[hash_value()] for in-process hashing (eg, for implementing +  *! @[lfun::_hash()]) or one of the cryptographic hash functions. +  *!    *! @note -  +  *! This function is really bad at hashing strings. Similar string +  *! often return similar hash values. +  *! +  *! It is especially bad for url:s, paths and similarly formatted +  *! strings. +  *! +  *! @note    *! The hash algorithm was changed in Pike 7.5. If you want a hash    *! that is compatible with Pike 7.4 and earlier, use @[hash_7_4()].    *! 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 @[hash_7_0()].    *!    *! @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()], @[hash_7_4()], @[hash_value]    */ - PMOD_EXPORT void f_hash(INT32 args) + PMOD_EXPORT void f_hash_7_8(INT32 args)   {    size_t i = 0;    struct pike_string *s;       if(!args)    SIMPLE_WRONG_NUM_ARGS_ERROR("hash",1);       if(TYPEOF(Pike_sp[-args]) != T_STRING)    SIMPLE_ARG_TYPE_ERROR("hash", 1, "string");   
pike.git/src/builtin_functions.c:430:    *! process only (the memory address is typically used as the basis    *! for the hash value).    *!    *! If the value is an object with an @[lfun::__hash], that function    *! is called and its result returned.    *!    *! @note    *! This is the hashing method used by mappings.    *!    *! @seealso -  *! @[hash()], @[lfun::__hash()] +  *! @[lfun::__hash()]    */   void f_hash_value(INT32 args)   {    unsigned INT32 h;       if(!args)    SIMPLE_WRONG_NUM_ARGS_ERROR("hash_value",1);       h = hash_svalue (Pike_sp - args);    pop_n_elems (args);
pike.git/src/builtin_functions.c:9357:    ADD_EFUN("callablep", f_callablep,tFunc(tMix,tInt01),OPT_TRY_OPTIMIZE);       /* function(string,string:int(0..1))|function(string,string*:array(string)) */    ADD_EFUN("glob",f_glob,    tOr3(tFunc(tStr tStr,tInt01),    tFunc(tArr(tStr) tStr,tStr),    tFunc(tOr(tStr,tArr(tStr)) tSetvar(1,tArr(tStr)),tVar(1))),    OPT_TRY_OPTIMIZE);       /* function(string,int|void:int) */ -  ADD_EFUN("hash",f_hash,tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE); +  ADD_EFUN("hash_7_8", f_hash_7_8, +  tAttr("deprecated",tFunc(tStr tOr(tInt,tVoid),tInt)),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_7_0",f_hash_7_0, -  tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE); +  tAttr("deprecated",tFunc(tStr tOr(tInt,tVoid),tInt)),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_7_4",f_hash_7_4, -  tFunc(tStr tOr(tInt,tVoid),tInt),OPT_TRY_OPTIMIZE); +  tAttr("deprecated",tFunc(tStr tOr(tInt,tVoid),tInt)),OPT_TRY_OPTIMIZE);       ADD_EFUN("hash_value",f_hash_value,tFunc(tMix,tInt),OPT_TRY_OPTIMIZE);       ADD_EFUN2("indices",f_indices,    tOr3(tFunc(tArray,tArr(tIntPos)),    tFunc(tOr3(tMap(tSetvar(1,tMix),tMix),    tSet(tSetvar(1,tMix)),    tNStr(tSetvar(1,tInt))),    tArr(tVar(1))),    tFunc(tOr(tObj,tPrg(tObj)),tArr(tStr))),