back out change#1111 and add alternative patch:
Ilya Zakharevich [Wed, 10 Jun 1998 11:38:58 +0000 (07:38 -0400)]
Message-Id: <199806101538.LAA07293@monk.mps.ohio-state.edu>
Subject: Re: PATCH for study/foo/

p4raw-link: @1111 on //depot/perl: 20e9db593ef4f0b3ec4e4dbedd03ab5782525eaf

p4raw-id: //depot/perl@1114

pp.c
sv.c

diff --git a/pp.c b/pp.c
index c65ed1c..aeaca4c 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -604,11 +604,8 @@ PP(pp_study)
     if(unop->op_first && unop->op_first->op_type == OP_PUSHRE) {
        PMOP *pm = (PMOP *)unop->op_first;
        SV *rv = sv_newmortal();
-       REGEXP *re = pm->op_pmregexp;
-
        sv = newSVrv(rv, "Regexp");
-       sv_setpvn(sv,re->precomp,re->prelen);
-       sv_magic(sv,(SV*)ReREFCNT_inc(re),'r',0,0);
+       sv_magic(sv,(SV*)ReREFCNT_inc(pm->op_pmregexp),'r',0,0);
        RETURNX(PUSHs(rv));
     }
 
diff --git a/sv.c b/sv.c
index f098efa..8c7d9c2 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1696,7 +1696,21 @@ sv_2pv(register SV *sv, STRLEN *lp)
            if (!sv)
                s = "NULLREF";
            else {
+               MAGIC *mg;
+               
                switch (SvTYPE(sv)) {
+               case SVt_PVMG:
+                   if ( ((SvFLAGS(sv) &
+                          (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG)) 
+                         == (SVs_OBJECT|SVs_RMG))
+                        && strEQ(s=HvNAME(SvSTASH(sv)), "Regexp")
+                        && (mg = mg_find(sv, 'r'))) {
+                       regexp *re = (regexp *)mg->mg_obj;
+
+                       *lp = re->prelen;
+                       return re->precomp;
+                   }
+                                       /* Fall through */
                case SVt_NULL:
                case SVt_IV:
                case SVt_NV:
@@ -1704,8 +1718,7 @@ sv_2pv(register SV *sv, STRLEN *lp)
                case SVt_PV:
                case SVt_PVIV:
                case SVt_PVNV:
-               case SVt_PVBM:
-               case SVt_PVMG:  s = "SCALAR";                   break;
+               case SVt_PVBM:  s = "SCALAR";                   break;
                case SVt_PVLV:  s = "LVALUE";                   break;
                case SVt_PVAV:  s = "ARRAY";                    break;
                case SVt_PVHV:  s = "HASH";                     break;