summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
commit115eb4595cea72226ec8acd357e7c403e2c4b04a (patch)
treec050f1ee16f730fc7dbc89586e09b33a23196485 /re.c
parent9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (diff)
990209
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/re.c b/re.c
index 5f176bb719..7cf085adc9 100644
--- a/re.c
+++ b/re.c
@@ -392,6 +392,21 @@ match_clone(orig)
return (VALUE)match;
}
+#define MATCH_BUSY FL_USER2
+
+void
+rb_match_busy(match, busy)
+ VALUE match;
+ int busy;
+{
+ if (busy) {
+ FL_SET(match, MATCH_BUSY);
+ }
+ else {
+ FL_UNSET(match, MATCH_BUSY);
+ }
+}
+
int ruby_ignorecase;
static int may_need_recompile;
static VALUE matchcache;
@@ -462,7 +477,7 @@ rb_reg_search(reg, str, start, reverse)
#else
match = rb_backref_get();
#endif
- if (NIL_P(match)) {
+ if (NIL_P(match) || FL_TEST(match, MATCH_BUSY)) {
if (matchcache) {
match = matchcache;
matchcache = 0;
@@ -481,7 +496,6 @@ rb_reg_search(reg, str, start, reverse)
}
result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
start, range, regs);
-
if (FL_TEST(reg, KCODE_FIXED))
kcode_reset_option();
@@ -1102,7 +1116,10 @@ ignorecase_setter(val)
static VALUE
match_getter()
{
- return match_clone(rb_backref_get());
+ VALUE match = rb_backref_get();
+
+ if (NIL_P(match)) return Qnil;
+ return match_clone(match);
}
static void