diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-05 06:27:46 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-05 06:27:46 +0000 |
commit | 2435fd1be140e474bdfe38414ea54495b1e94069 (patch) | |
tree | 10ca84671a319b56d0cb0646a51d5115cb0e1289 /re.c | |
parent | 3ab2a0817242879124cebbfbb5b1390ae8e39112 (diff) |
* marshal.c: backport from 1.7 marshal.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -652,7 +652,11 @@ rb_reg_nth_defined(nth, match) { if (NIL_P(match)) return Qnil; if (nth >= RMATCH(match)->regs->num_regs) { - return Qfalse; + return Qnil; + } + if (nth < 0) { + nth += RMATCH(match)->regs->num_regs; + if (nth <= 0) return Qnil; } if (RMATCH(match)->BEG(nth) == -1) return Qfalse; return Qtrue; @@ -670,6 +674,10 @@ rb_reg_nth_match(nth, match) if (nth >= RMATCH(match)->regs->num_regs) { return Qnil; } + if (nth < 0) { + nth += RMATCH(match)->regs->num_regs; + if (nth <= 0) return Qnil; + } start = RMATCH(match)->BEG(nth); if (start == -1) return Qnil; end = RMATCH(match)->END(nth); @@ -1145,7 +1153,7 @@ rb_reg_clone(re) clone->ptr = 0; clone->len = 0; clone->str = 0; rb_reg_initialize(clone, RREGEXP(re)->str, RREGEXP(re)->len, rb_reg_options(re)); - return (VALUE)re; + return (VALUE)clone; } VALUE |