diff options
author | Ævar Arnfjörð Bjarmason <avar@cpan.org> | 2007-06-18 03:33:34 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-06-18 07:39:35 +0000 |
commit | f7e711955148e1ce710988aa3010c41ca8085a03 (patch) | |
tree | df8b9e38f7bb7a6516c2fe1e64f21ee460b24037 /util.c | |
parent | 225593e1515f97126032fb4da0b1aafeb00e8e99 (diff) | |
download | perl-f7e711955148e1ce710988aa3010c41ca8085a03.tar.gz |
SvRX() and SvRXOK() macros
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Message-ID: <51dd1af80706172033h1908aa0ge15698204e0b79ed@mail.gmail.com>
p4raw-id: //depot/perl@31409
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -5871,6 +5871,26 @@ Perl_my_dirfd(pTHX_ DIR * dir) { #endif } +REGEXP * +Perl_get_re_arg(pTHX_ SV *sv) { + SV *tmpsv; + MAGIC *mg; + + if (sv) { + if (SvMAGICAL(sv)) + mg_get(sv); + if (SvROK(sv) && + (tmpsv = (SV*)SvRV(sv)) && /* assign deliberate */ + SvTYPE(tmpsv) == SVt_PVMG && + (mg = mg_find(tmpsv, PERL_MAGIC_qr))) /* assign deliberate */ + { + return (REGEXP *)mg->mg_obj; + } + } + + return NULL; +} + /* * Local variables: * c-indentation-style: bsd |