summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-17 06:18:56 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-17 06:18:56 +0000
commitf19af096a5a45c0777420af4fe8baaaef21dfcb1 (patch)
tree7a6e53b81aedf8476894e24da03cc4374a3d90e2
parent2bd4cfc0ccd3701c96d499b3ec10c8ab26b0f31a (diff)
merges r20804 from trunk into ruby_1_9_1.
* string.c (rb_str_hash): gets rid of collisions between different encoding strings. [ruby-core:20526] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 582192402..998e90977 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Dec 17 11:01:35 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_hash): gets rid of collisions between differen
+ encoding strings. [ruby-core:20526]
+
Tue Dec 16 22:55:11 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* bin/testrb: set $0.
diff --git a/string.c b/string.c
index 1eac1bda3..e0efa0477 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