* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
-/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
- gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
\f
#endif
-scm_bits_t
+unsigned long
scm_string_hash (const unsigned char *str, size_t len)
{
if (len > 5)
{
size_t i = 5;
- scm_bits_t h = 264;
+ unsigned long h = 264;
while (i--)
h = (h << 8) + (unsigned) str[h % len];
return h;
else
{
size_t i = len;
- scm_bits_t h = 0;
+ unsigned long h = 0;
while (i)
h = (h << 8) + (unsigned) str[--i];
return h;
/* Dirk:FIXME:: scm_hasher could be made static. */
-scm_bits_t
-scm_hasher (SCM obj, scm_bits_t n, size_t d)
+unsigned long
+scm_hasher(SCM obj, unsigned long n, size_t d)
{
switch (SCM_ITAG3 (obj)) {
case scm_tc3_int_1:
return SCM_INUM(obj) % n; /* SCM_INUMP(obj) */
case scm_tc3_imm24:
if (SCM_CHARP(obj))
- return (scm_ubits_t) (scm_downcase(SCM_CHAR(obj))) % n;
+ return (unsigned)(scm_downcase(SCM_CHAR(obj))) % n;
switch (SCM_UNPACK (obj)) {
#ifndef SICP
- case SCM_EOL:
+ case SCM_UNPACK(SCM_EOL):
d = 256;
break;
#endif
- case SCM_BOOL_T:
+ case SCM_UNPACK(SCM_BOOL_T):
d = 257;
break;
- case SCM_BOOL_F:
+ case SCM_UNPACK(SCM_BOOL_F):
d = 258;
break;
- case SCM_EOF_VAL:
+ case SCM_UNPACK(SCM_EOF_VAL):
d = 259;
break;
default:
obj = scm_number_to_string (obj, SCM_MAKINUM (10));
}
case scm_tc7_string:
- case scm_tc7_substring:
return scm_string_hash (SCM_STRING_UCHARS (obj), SCM_STRING_LENGTH (obj)) % n;
case scm_tc7_symbol:
return SCM_SYMBOL_HASH (obj) % n;
case scm_tc7_vector:
{
size_t len = SCM_VECTOR_LENGTH(obj);
- SCM *data = SCM_VELTS(obj);
+ SCM const *data = SCM_VELTS(obj);
if (len > 5)
{
size_t i = d/2;
- scm_bits_t h = 1;
+ unsigned long h = 1;
while (i--) h = ((h << 8) + (scm_hasher (data[h % len], n, 2))) % n;
return h;
}
else
{
size_t i = len;
- scm_bits_t h = (n)-1;
+ unsigned long h = (n)-1;
while (i--) h = ((h << 8) + (scm_hasher (data[i], n, d/len))) % n;
return h;
}
\f
-scm_bits_t
-scm_ihashq (SCM obj, scm_bits_t n)
+unsigned long
+scm_ihashq (SCM obj, unsigned long n)
{
return (SCM_UNPACK (obj) >> 1) % n;
}
\f
-scm_bits_t
-scm_ihashv (SCM obj, scm_bits_t n)
+unsigned long
+scm_ihashv (SCM obj, unsigned long n)
{
if (SCM_CHARP(obj))
- return ((scm_ubits_t)(scm_downcase(SCM_CHAR(obj)))) % n; /* downcase!?!! */
+ return ((unsigned long) (scm_downcase (SCM_CHAR (obj)))) % n; /* downcase!?!! */
if (SCM_NUMP(obj))
- return (scm_bits_t) scm_hasher(obj, n, 10);
+ return (unsigned long) scm_hasher(obj, n, 10);
else
return SCM_UNPACK (obj) % n;
}
\f
-scm_bits_t
-scm_ihash (SCM obj, scm_bits_t n)
+unsigned long
+scm_ihash (SCM obj, unsigned long n)
{
- return (scm_bits_t) scm_hasher (obj, n, 10);
+ return (unsigned long) scm_hasher (obj, n, 10);
}
SCM_DEFINE (scm_hash, "hash", 2, 0, 0,
void
scm_init_hash ()
{
-#ifndef SCM_MAGIC_SNARFER
#include "libguile/hash.x"
-#endif
}