diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-12-28 09:59:06 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-12-28 09:59:06 +0000 |
commit | 5c35adbb8fc4c988807097c4d379e2485ada5865 (patch) | |
tree | 68cb0d31f61fbabefe05d3673ae29eefe3550118 /regexec.c | |
parent | 662f1f9e0a1bbee45e1e02386151364c8517604e (diff) | |
download | perl-5c35adbb8fc4c988807097c4d379e2485ada5865.tar.gz |
First class regexps.
p4raw-id: //depot/perl@32751
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -3707,12 +3707,21 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) { /* extract RE object from returned value; compiling if * necessary */ - MAGIC *mg = NULL; - const SV *sv; - if(SvROK(ret) && SvSMAGICAL(sv = SvRV(ret))) - mg = mg_find(sv, PERL_MAGIC_qr); - else if (SvSMAGICAL(ret)) { + re = NULL; + + if (SvROK(ret)) { + const SV *const sv = SvRV(ret); + + if (SvTYPE(sv) == SVt_REGEXP) { + re = ((struct xregexp *)SvANY(sv))->xrx_regexp; + } else if (SvSMAGICAL(sv)) { + mg = mg_find(sv, PERL_MAGIC_qr); + assert(mg); + } + } else if (SvTYPE(ret) == SVt_REGEXP) { + re = ((struct xregexp *)SvANY(ret))->xrx_regexp; + } else if (SvSMAGICAL(ret)) { if (SvGMAGICAL(ret)) { /* I don't believe that there is ever qr magic here. */ @@ -3730,8 +3739,11 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) } if (mg) { - re = reg_temp_copy((regexp *)mg->mg_obj); /*XXX:dmq*/ + re = (regexp *)mg->mg_obj; /*XXX:dmq*/ + assert(re); } + if (re) + re = reg_temp_copy(re); else { U32 pm_flags = 0; const I32 osize = PL_regsize; |