diff --git a/ChangeLog b/ChangeLog index c103715057..0b4f2d20c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat May 10 22:14:03 2008 Yukihiro Matsumoto + + * string.c (tr_trans): single '^' does not mean negation. + [ruby-dev:34632] + Sat May 10 18:11:18 2008 Yukihiro Matsumoto * string.c (rb_str_each_line): zero length record separator should diff --git a/string.c b/string.c index 3c8cdd3f0b..3bb6780e4b 100644 --- a/string.c +++ b/string.c @@ -4243,7 +4243,9 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag) enc = rb_enc_check(src, repl); } trsrc.p = RSTRING_PTR(src); trsrc.pend = trsrc.p + RSTRING_LEN(src); - if (RSTRING_LEN(str) > 1 && rb_enc_ascget(trsrc.p, trsrc.pend, &l, enc) == '^') { + if (RSTRING_LEN(str) > 1 && + rb_enc_ascget(trsrc.p, trsrc.pend, &l, enc) == '^' && + trsrc.p + l < trsrc.pend) { cflag = 1; trsrc.p += l; }