зеркало из https://github.com/github/ruby.git
* string.c (tr_trans): get rid of segfaults when has mulitbytes but
source sets have no mulitbytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
221e6de720
Коммит
54c146d2c3
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Dec 9 11:29:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (tr_trans): get rid of segfaults when has mulitbytes but
|
||||||
|
source sets have no mulitbytes.
|
||||||
|
|
||||||
Sun Dec 9 04:01:28 2007 Tanaka Akira <akr@fsij.org>
|
Sun Dec 9 04:01:28 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* encoding.c (rb_enc_mbclen): return 1 if underlying implementation
|
* encoding.c (rb_enc_mbclen): return 1 if underlying implementation
|
||||||
|
|
|
@ -162,11 +162,3 @@ assert_equal 'true', %q{
|
||||||
s = "\xa3\xb0\xa3\xb1\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
s = "\xa3\xb0\xa3\xb1\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
||||||
s.squeeze == "\xa3\xb0\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
s.squeeze == "\xa3\xb0\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_normal_exit %q{
|
|
||||||
"\x81\x41".force_encoding("shift_jis").tr("A", "B")
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_normal_exit %q{
|
|
||||||
"\x81\x41".force_encoding("shift_jis").tr_s("A", "B")
|
|
||||||
}
|
|
||||||
|
|
4
string.c
4
string.c
|
@ -3466,7 +3466,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
|
||||||
v = trans[c] >= 0 ? trans[c] : Qnil;
|
v = trans[c] >= 0 ? trans[c] : Qnil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v = rb_hash_aref(hash, INT2NUM(c));
|
v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
|
||||||
}
|
}
|
||||||
if (!NIL_P(v)) {
|
if (!NIL_P(v)) {
|
||||||
if (!cflag) {
|
if (!cflag) {
|
||||||
|
@ -3531,7 +3531,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
|
||||||
v = trans[c] >= 0 ? trans[c] : Qnil;
|
v = trans[c] >= 0 ? trans[c] : Qnil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v = rb_hash_aref(hash, INT2NUM(c));
|
v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
|
||||||
}
|
}
|
||||||
if (!NIL_P(v)) {
|
if (!NIL_P(v)) {
|
||||||
if (!cflag) {
|
if (!cflag) {
|
||||||
|
|
|
@ -483,4 +483,10 @@ class TestM17N < Test::Unit::TestCase
|
||||||
assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\\xc2\\xa0/})) }
|
assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\\xc2\\xa0/})) }
|
||||||
assert_nothing_raised { eval(u(%{/\\u{6666}#{}\\xc2\\xa0/})) }
|
assert_nothing_raised { eval(u(%{/\\u{6666}#{}\\xc2\\xa0/})) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_tr
|
||||||
|
s = "\x81\x41".force_encoding("shift_jis")
|
||||||
|
assert_equal(s.tr("A", "B"), s)
|
||||||
|
assert_equal(s.tr_s("A", "B"), s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче