summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avar@cpan.org>2007-06-18 03:33:34 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-06-18 07:39:35 +0000
commitf7e711955148e1ce710988aa3010c41ca8085a03 (patch)
treedf8b9e38f7bb7a6516c2fe1e64f21ee460b24037 /util.c
parent225593e1515f97126032fb4da0b1aafeb00e8e99 (diff)
downloadperl-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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/util.c b/util.c
index 058d0c22be..dffe6f4063 100644
--- a/util.c
+++ b/util.c
@@ -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