summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-31 20:36:04 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-31 20:36:04 +0000
commitc4641d6a00c4ea3689867d74ae347c6505371af0 (patch)
treeda043b6cf9f08dc2504ebf8da16d5cbbfc4581e1
parent971f2bb7690cf673121b53cdf17b61ab90ee5eca (diff)
Can't use singlebyte optimization when the replacement is multibyte. [ruby-core:24612]
* string.c (tr_trans): can't use singlebyte optimization when the replacement is multibyte. [ruby-core:24612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5ce6a305d8e..9eac1dd169c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Aug 1 05:18:36 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (tr_trans): can't use singlebyte optimization when
+ the replacement is multibyte. [ruby-core:24612]
+
Fri Jul 31 18:01:34 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/securerandom.rb (SecureRandom.random_bytes): return string should
diff --git a/string.c b/string.c
index 34f35b8b29d..6e6db0053a4 100644
--- a/string.c
+++ b/string.c
@@ -4871,7 +4871,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
if (r == errc) r = trrepl.now;
if (c < 256) {
trans[c] = r;
- if (r > 255) singlebyte = 0;
+ if (r > 255 || (r > 127 && rb_enc_mbmaxlen(enc) != 1))
+ singlebyte = 0;
}
else {
if (!hash) hash = rb_hash_new();