summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-19 17:02:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-19 17:02:29 +0000
commit77629d2cbe4931e3033ae73cef2e9adf6c1c0373 (patch)
tree9b75e0c5b7cffd99cebf28cb557f458b5bbfc974 /re.c
parenta927483326e54e6a4e9387009af0b57f38636497 (diff)
* 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
Diffstat (limited to 're.c')
-rw-r--r--re.c3
1 files changed, 2 insertions, 1 deletions
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;
}