develooper Front page | perl.perl5.porters | Postings from December 2010

[perl #80262] [PATCH] REGEXP are no longer accessed via magic, update API docs

Thread Previous
From:
David Leadbeater
Date:
December 6, 2010 00:58
Subject:
[perl #80262] [PATCH] REGEXP are no longer accessed via magic, update API docs
Message ID:
rt-3.6.HEAD-13564-1291588387-361.80262-75-0@perl.org
# New Ticket Created by  David Leadbeater 
# Please include the string:  [perl #80262]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=80262 >


From: David Leadbeater <dgl@dgl.cx>

The docs for SvRX and SvRXOK still refered to magic and the code snippet
was wrong.
---
 regexp.h |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/regexp.h b/regexp.h
index 5acdc5e..9bba272 100644
--- a/regexp.h
+++ b/regexp.h
@@ -190,20 +190,17 @@ 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;
-    }
+    if (SvROK(sv))
+        sv = MUTABLE_SV(SvRV(sv));
+    if (SvTYPE(sv) == SVt_REGEXP)
+        return (REGEXP*) sv;
 
 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).
+Returns a boolean indicating whether the SV (or the one it references)
+is a REGEXP.
 
 If you want to do something with the REGEXP* later use SvRX instead
 and check for NULL.
-- 
1.7.3.2


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About