diff --git a/ChangeLog b/ChangeLog index f901ab7904..4a210a0825 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 17 11:01:35 2008 Nobuyoshi Nakada + + * string.c (rb_str_hash): gets rid of collisions between differen + encoding strings. [ruby-core:20526] + Wed Dec 17 09:50:19 2008 Yuki Sonoda (Yugui) * test/ruby/test_metaclass.rb: removed codes for my debugging. diff --git a/string.c b/string.c index f940966753..d34a1e861c 100644 --- a/string.c +++ b/string.c @@ -2014,7 +2014,11 @@ rb_memhash(const void *ptr, long len) int rb_str_hash(VALUE str) { - return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)); + int e = ENCODING_GET(str); + if (e) { + if (rb_enc_str_asciionly_p(str)) e = 0; + } + return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)) ^ e; } int