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 /regexp.h | |
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 'regexp.h')
-rw-r--r-- | regexp.h | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -181,6 +181,41 @@ typedef struct regexp_engine { #define RXf_HASH_REGNAMES 0x0800 #define RXf_HASH_REGNAMES_COUNT 0x1000 +/* +=head1 REGEXP Functions + +=for apidoc Am|REGEXP *|SvRX|SV *sv + +Convenience macro to get the REGEXP from a SV. This is approximately +equivalent to the following snippet: + + if (SvMAGICAL(sv)) + mg_get(sv); + if (SvROK(sv) && + (tmpsv = (SV*)SvRV(sv)) && + SvTYPE(tmpsv) == SVt_PVMG && + (tmpmg = mg_find(tmpsv, PERL_MAGIC_qr))) + { + return (REGEXP *)tmpmg->mg_obj; + } + +NULL will be returned if a REGEXP* is not found. + +=for apidoc Am|bool|SvRXOK|SV* sv + +Returns a boolean indicating whether the SV contains qr magic +(PERL_MAGIC_qr). + +If you want to do something with the REGEXP* later use SvRX instead +and check for NULL. + +=cut +*/ + +#define SvRX(sv) (Perl_get_re_arg(aTHX_ sv)) +#define SvRXOK(sv) (Perl_get_re_arg(aTHX_ sv) ? TRUE : FALSE) + + /* Flags stored in regexp->extflags * These are used by code external to the regexp engine * |