diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-10 10:03:48 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-10 10:03:48 +0000 |
commit | f6a9c859bec2801a99c26a09c8845c54401a62be (patch) | |
tree | 224567bfa749aefb2a00280c4f63f54404bd3f3a | |
parent | 32bfc874fa5325d34a5e51c91667360a125339b2 (diff) | |
download | ruby-f6a9c859bec2801a99c26a09c8845c54401a62be.tar.gz |
* re.c (rb_reg_match): should calculate offset by converted
operand. [ruby-cvs:21416]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | re.c | 10 |
2 files changed, 11 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Mon Dec 10 19:02:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org> + + * re.c (rb_reg_match): should calculate offset by converted + operand. [ruby-cvs:21416] + Mon Dec 10 18:28:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org> * lib/uri/common.rb (URI::REGEXP::PATTERN): typo in REG_NAME @@ -2124,13 +2124,15 @@ reg_operand(VALUE s, int check) } static long -rb_reg_match_pos(VALUE re, VALUE str, long pos) +reg_match_pos(VALUE re, VALUE *strp, long pos) { + VALUE str = *strp; + if (NIL_P(str)) { rb_backref_set(Qnil); return -1; } - str = reg_operand(str, Qtrue); + *strp = str = reg_operand(str, Qtrue); if (pos != 0) { if (pos < 0) { pos += RSTRING_LEN(str); @@ -2156,7 +2158,7 @@ rb_reg_match_pos(VALUE re, VALUE str, long pos) VALUE rb_reg_match(VALUE re, VALUE str) { - long pos = rb_reg_match_pos(re, str, 0); + long pos = reg_match_pos(re, &str, 0); if (pos < 0) return Qnil; pos = rb_str_sublen(str, pos); return LONG2FIX(pos); @@ -2270,7 +2272,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re) pos = 0; } - pos = rb_reg_match_pos(re, str, pos); + pos = reg_match_pos(re, &str, pos); if (pos < 0) { rb_backref_set(Qnil); return Qnil; |