diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-14 06:21:38 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-14 06:21:38 +0000 |
commit | 7bb210b3035d2a28bcbdaec1570b019fac951ebb (patch) | |
tree | 90e93e2e180a7bbe1a78ee716eabb8dee86651eb /re.c | |
parent | fbcbf1b8fd32a75f13905385720719de841ec25a (diff) |
* re.c (rb_reg_match): should clear $~ if operand is nil.
* re.c (rb_reg_match2): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -943,7 +943,10 @@ rb_reg_match(re, str) { int start; - if (NIL_P(str)) return Qnil; + if (NIL_P(str)) { + rb_backref_set(Qnil); + return Qnil; + } str = rb_str_to_str(str); start = rb_reg_search(re, str, 0, 0); if (start < 0) { @@ -959,8 +962,10 @@ rb_reg_match2(re) int start; VALUE line = rb_lastline_get(); - if (TYPE(line) != T_STRING) + if (TYPE(line) != T_STRING) { + rb_backref_set(Qnil); return Qnil; + } start = rb_reg_search(re, line, 0, 0); if (start < 0) { |