summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-06 03:09:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-06 03:09:03 +0000
commit6b7b84edc7168786408b0757e2eb53728d1b71a6 (patch)
tree299c41408ef82854a829327d1f8d5c4cc8cf6a8c /re.c
parent53118356b53259b456aabc11fb1212d965251fc4 (diff)
new exception model
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/re.c b/re.c
index daf285708c..d4455c349b 100644
--- a/re.c
+++ b/re.c
@@ -411,37 +411,38 @@ reg_prepare_re(reg)
}
int
-reg_search(reg, str, start, regs)
+reg_search(reg, str, start, reverse)
VALUE reg, str;
- int start;
- struct re_registers *regs;
+ int start, reverse;
{
int result;
int casefold = RTEST(ignorecase);
VALUE match = 0;
- struct re_registers *regs0 = 0;
+ struct re_registers *regs = 0;
+ int range;
int need_recompile = 0;
if (start > RSTRING(str)->len) return -1;
reg_prepare_re(reg);
- if (regs == (struct re_registers*)-1) {
- regs = 0;
+ if (matchcache) {
+ match = matchcache;
+ matchcache = 0;
}
else {
- if (matchcache) {
- match = matchcache;
- matchcache = 0;
- }
- else {
- match = match_alloc();
- }
- regs0 = RMATCH(match)->regs;
+ match = match_alloc();
}
+ regs = RMATCH(match)->regs;
+ if (reverse) {
+ range = -start;
+ }
+ else {
+ range = RSTRING(str)->len-start;
+ }
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
- start,RSTRING(str)->len-start,regs0);
+ start, range, regs);
kcode_reset_option();
if (start == -2) {
@@ -456,7 +457,6 @@ reg_search(reg, str, start, regs)
RMATCH(match)->str = str_new4(str);
backref_set(match);
}
- if (regs && regs0) re_copy_registers(regs, regs0);
return result;
}
@@ -725,7 +725,7 @@ reg_match(re, str)
{
int start;
- if (TYPE(str) != T_STRING) return FALSE;
+ str = str_to_str(str);
start = reg_search(re, str, 0, 0);
if (start < 0) {
return FALSE;