summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/re.c b/re.c
index 451b9b6208c..4ecc46eee5a 100644
--- a/re.c
+++ b/re.c
@@ -530,10 +530,11 @@ rb_reg_search(reg, str, pos, reverse)
}
regs = RMATCH(match)->regs;
- range = RSTRING(str)->len - pos;
if (reverse) {
- range = -range;
- pos = RSTRING(str)->len;
+ range = -pos;
+ }
+ else {
+ range = RSTRING(str)->len - pos;
}
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
pos, range, regs);