From 77629d2cbe4931e3033ae73cef2e9adf6c1c0373 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 19 Dec 2007 17:02:29 +0000 Subject: * string.c (rb_str_rindex_m): too much adjustment. * re.c (reg_match_pos): pos adjustment should be based on characters. * test/ruby/test_m17n.rb (TestM17N::test_str_insert): test updated to check negative offset behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- re.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 're.c') diff --git a/re.c b/re.c index db3f04ad04..15d5668e33 100644 --- a/re.c +++ b/re.c @@ -2146,7 +2146,8 @@ reg_match_pos(VALUE re, VALUE *strp, long pos) *strp = str = reg_operand(str, Qtrue); if (pos != 0) { if (pos < 0) { - pos += RSTRING_LEN(str); + VALUE l = rb_str_length(str); + pos += NUM2INT(l); if (pos < 0) { return pos; } -- cgit v1.2.3