Change 32934 by [EMAIL PROTECTED] on 2008/01/10 00:32:20

        Subject: [PATCH] Move the reg_stringify logic to Perl_sv_2pv_flags
        From: [EMAIL PROTECTED] (Ævar Arnfjörð Bjarmason)
        Date: Wed, 09 Jan 2008 21:05:15 +0000
        Message-ID: <[EMAIL PROTECTED]>
        
        with two corrections.
        Plus remove reg_stringify from embed.fnc and regen.

Affected files ...

... //depot/perl/embed.fnc#556 edit
... //depot/perl/embed.h#740 edit
... //depot/perl/global.sym#351 edit
... //depot/perl/perl.h#818 edit
... //depot/perl/proto.h#890 edit
... //depot/perl/regcomp.c#648 edit
... //depot/perl/sv.c#1481 edit

Differences ...

==== //depot/perl/embed.fnc#556 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#555~32925~   2008-01-09 09:59:11.000000000 -0800
+++ perl/embed.fnc      2008-01-09 16:32:20.000000000 -0800
@@ -688,7 +688,6 @@
 Ap     |void   |pregfree2      |NN REGEXP* prog
 EXp    |REGEXP*|reg_temp_copy  |NN REGEXP* r
 Ap     |void   |regfree_internal|NULLOK REGEXP * const r
-Ap     |char * |reg_stringify  |NN MAGIC *mg|NULLOK STRLEN *lp|NULLOK U32 
*flags|NULLOK I32 *haseval
 #if defined(USE_ITHREADS)
 Ap     |void*  |regdupe_internal|NN REGEXP * const r|NN CLONE_PARAMS* param
 #endif

==== //depot/perl/embed.h#740 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#739~32838~     2008-01-05 03:30:31.000000000 -0800
+++ perl/embed.h        2008-01-09 16:32:20.000000000 -0800
@@ -687,7 +687,6 @@
 #define reg_temp_copy          Perl_reg_temp_copy
 #endif
 #define regfree_internal       Perl_regfree_internal
-#define reg_stringify          Perl_reg_stringify
 #if defined(USE_ITHREADS)
 #define regdupe_internal       Perl_regdupe_internal
 #endif
@@ -2979,7 +2978,6 @@
 #define reg_temp_copy(a)       Perl_reg_temp_copy(aTHX_ a)
 #endif
 #define regfree_internal(a)    Perl_regfree_internal(aTHX_ a)
-#define reg_stringify(a,b,c,d) Perl_reg_stringify(aTHX_ a,b,c,d)
 #if defined(USE_ITHREADS)
 #define regdupe_internal(a,b)  Perl_regdupe_internal(aTHX_ a,b)
 #endif

==== //depot/perl/global.sym#351 (text+w) ====
Index: perl/global.sym
--- perl/global.sym#350~32838~  2008-01-05 03:30:31.000000000 -0800
+++ perl/global.sym     2008-01-09 16:32:20.000000000 -0800
@@ -402,7 +402,6 @@
 Perl_pregfree2
 Perl_reg_temp_copy
 Perl_regfree_internal
-Perl_reg_stringify
 Perl_regdupe_internal
 Perl_pregcomp
 Perl_re_compile

==== //depot/perl/perl.h#818 (text) ====
Index: perl/perl.h
--- perl/perl.h#817~32861~      2008-01-05 14:33:12.000000000 -0800
+++ perl/perl.h 2008-01-09 16:32:20.000000000 -0800
@@ -209,10 +209,6 @@
 #define CALLREG_INTUIT_STRING(prog) \
     CALL_FPTR(RX_ENGINE(prog)->checkstr)(aTHX_ (prog))
 
-#define CALLREG_AS_STR(mg,lp,flags,haseval) \
-        Perl_reg_stringify(aTHX_ (mg), (lp), (flags), (haseval))
-#define CALLREG_STRINGIFY(mg,lp,flags) CALLREG_AS_STR(mg,lp,flags,0)
-
 #define CALLREGFREE(prog) \
     Perl_pregfree(aTHX_ (prog))
 

==== //depot/perl/proto.h#890 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#889~32925~     2008-01-09 09:59:11.000000000 -0800
+++ perl/proto.h        2008-01-09 16:32:20.000000000 -0800
@@ -1859,9 +1859,6 @@
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV void     Perl_regfree_internal(pTHX_ REGEXP * const r);
-PERL_CALLCONV char *   Perl_reg_stringify(pTHX_ MAGIC *mg, STRLEN *lp, U32 
*flags, I32 *haseval)
-                       __attribute__nonnull__(pTHX_1);
-
 #if defined(USE_ITHREADS)
 PERL_CALLCONV void*    Perl_regdupe_internal(pTHX_ REGEXP * const r, 
CLONE_PARAMS* param)
                        __attribute__nonnull__(pTHX_1)

==== //depot/perl/regcomp.c#648 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#647~32933~   2008-01-09 15:57:36.000000000 -0800
+++ perl/regcomp.c      2008-01-09 16:32:20.000000000 -0800
@@ -9569,48 +9569,8 @@
 
 #endif    /* USE_ITHREADS */
 
-/* 
-   reg_stringify() 
-   
-   converts a regexp embedded in a MAGIC struct to its stringified form, 
-   caching the converted form in the struct and returns the cached 
-   string. 
-
-   If lp is nonnull then it is used to return the length of the 
-   resulting string
-   
-   If flags is nonnull and the returned string contains UTF8 then 
-   (*flags & 1) will be true.
-   
-   If haseval is nonnull then it is used to return whether the pattern 
-   contains evals.
-   
-   Normally called via macro: 
-   
-        CALLREG_STRINGIFY(mg,&len,&utf8);
-        
-   And internally with
-   
-        CALLREG_AS_STR(mg,&lp,&flags,&haseval)        
-    
-   See sv_2pv_flags() in sv.c for an example of internal usage.
-    
- */
 #ifndef PERL_IN_XSUB_RE
 
-char *
-Perl_reg_stringify(pTHX_ MAGIC *mg, STRLEN *lp, U32 *flags, I32 *haseval ) {
-    dVAR;
-    const REGEXP * const re = (REGEXP *)mg->mg_obj;
-    if (haseval) 
-        *haseval = RX_SEEN_EVALS(re);
-    if (flags)    
-       *flags = RX_UTF8(re) ? 1 : 0;
-    if (lp)
-       *lp = RX_WRAPLEN(re);
-    return RX_WRAPPED(re);
-}
-
 /*
  - regnext - dig the "next" pointer out of a node
  */

==== //depot/perl/sv.c#1481 (text) ====
Index: perl/sv.c
--- perl/sv.c#1480~32918~       2008-01-09 07:34:42.000000000 -0800
+++ perl/sv.c   2008-01-09 16:32:20.000000000 -0800
@@ -2726,21 +2726,25 @@
                    len = 7;
                    retval = buffer = savepvn("NULLREF", len);
                } else if (SvTYPE(referent) == SVt_REGEXP) {
-                    char *str = NULL;
-                    I32 haseval = 0;
-                    U32 flags = 0;
-                   struct magic temp;
-                   /* FIXME - get rid of this cast away of const, or work out
-                      how to do it better.  */
-                   temp.mg_obj = (SV *)referent;
-                   assert(temp.mg_obj);
-                    (str) = CALLREG_AS_STR(&temp,lp,&flags,&haseval);
-                    if (flags & 1)
-                       SvUTF8_on(sv);
-                    else
-                       SvUTF8_off(sv);
-                    PL_reginterp_cnt += haseval;
-                   return str;
+                   const REGEXP * const re = (REGEXP *)referent;
+                   I32 seen_evals = 0;
+
+                   assert(re);
+                       
+                   /* If the regex is UTF-8 we want the containing scalar to
+                      have an UTF-8 flag too */
+                   if (RX_UTF8(re))
+                       SvUTF8_on(sv);
+                   else
+                       SvUTF8_off(sv); 
+
+                   if ((seen_evals = RX_SEEN_EVALS(re)))
+                       PL_reginterp_cnt += seen_evals;
+
+                   if (lp)
+                       *lp = RX_WRAPLEN(re);
+ 
+                   return RX_WRAPPED(re);
                } else {
                    const char *const typestr = sv_reftype(referent, 0);
                    const STRLEN typelen = strlen(typestr);
End of Patch.

Reply via email to