Hashing of base strings has to be done using unsigned characters, to be compatible with extended strings.

This commit is contained in:
Juan Jose Garcia Ripoll 2008-10-26 17:46:59 +01:00
parent 19618912c8
commit 6fe9d192ad
2 changed files with 6 additions and 5 deletions

View file

@ -92,12 +92,14 @@ _hash_equal(int depth, cl_hashkey h, cl_object x)
x = x->symbol.name;
#ifdef ECL_UNICODE
case t_base_string:
return hash_base_string(x->base_string.self, x->base_string.fillp, h);
return hash_base_string((unsigned char *)x->base_string.self,
x->base_string.fillp, h);
case t_string:
return hash_full_string(x->base_string.self, x->base_string.fillp, h);
return hash_full_string(x->string.self, x->string.fillp, h);
#else
case t_base_string:
return hash_string(h, x->base_string.self, x->base_string.fillp);
return hash_string(h, (unsigned char *)x->base_string.self,
x->base_string.fillp);
#endif
case t_pathname:
h = _hash_equal(0, h, x->pathname.directory);

View file

@ -144,7 +144,7 @@ static cl_index hash_word(cl_index c, cl_index w)
return c;
}
static cl_index hash_base_string(const char *s, cl_index len, cl_index h)
static cl_index hash_base_string(const unsigned char *s, cl_index len, cl_index h)
{
cl_index a = GOLDEN_RATIO, b = GOLDEN_RATIO, i;
for (i = len; i >= 3; i -= 3) {
@ -179,4 +179,3 @@ static cl_index hash_full_string(const cl_object *s, cl_index len, cl_index h)
mix(a, b, h);
return h;
}