Deprecate sv_compile_2op()
authorNicholas Clark <nick@ccl4.org>
Wed, 24 Nov 2010 17:56:39 +0000 (17:56 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 24 Nov 2010 17:56:39 +0000 (17:56 +0000)
It attempted to provide an API to compile code down to an optree, but failed
to bind correctly to lexicals in the enclosing scope. It's not possible to
fix this problem within the constraints of its parameters and return value.

Searches suggest +that nothing on CPAN is using it, so removing it should have
zero impact.

embed.fnc
pod/perldelta.pod
pp_ctl.c
proto.h
regcomp.c

index 4c5f0ed..edab49d 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1174,7 +1174,9 @@ Apd       |I32    |sv_cmp_locale_flags    |NULLOK SV *const sv1 \
 Amd    |char*  |sv_collxfrm    |NN SV *const sv|NN STRLEN *const nxp
 Apd    |char*  |sv_collxfrm_flags      |NN SV *const sv|NN STRLEN *const nxp|I32 const flags
 #endif
-Ap     |OP*    |sv_compile_2op |NN SV *sv|NN OP **startop \
+po     |OP*    |sv_compile_2op_is_broken|NN SV *sv|NN OP **startop \
+                               |NN const char *code|NN PAD **padp
+ApD    |OP*    |sv_compile_2op |NN SV *sv|NN OP **startop \
                                |NN const char *code|NN PAD **padp
 Apd    |int    |getcwd_sv      |NN SV* sv
 Apd    |void   |sv_dec         |NULLOK SV *const sv
index b1da9b8..624e4f5 100644 (file)
@@ -53,6 +53,15 @@ listed as an updated module in the L</Modules and Pragmata> section.
 
 [ List each deprecation as a =head2 entry ]
 
+=head2 C<sv_compile_2op> is now deprecated
+
+The C<sv_compile_2op> is now deprecated, and will be removed. Searches suggest
+that nothing on CPAN is using it, so this should have zero impact.
+
+It attempted to provide an API to compile code down to an optree, but failed
+to bind correctly to lexicals in the enclosing scope. It's not possible to
+fix this problem within the constraints of its parameters and return value.
+
 =head1 Performance Enhancements
 
 XXX Changes which enhance performance without changing behaviour go here. There
index 3e6e46c..54e7c25 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2982,6 +2982,8 @@ S_docatch(pTHX_ OP *o)
    called more than once, and is only used by regcomp.c, for (?{}) blocks.
 
    Currently it is not used outside the core code. Best if it stays that way.
+
+   Hence it's now deprecated, and will be removed.
 */
 OP *
 Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
@@ -2989,6 +2991,16 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
 /* startop op_free() this to undo. */
 /* code Short string id of the caller. */
 {
+    PERL_ARGS_ASSERT_SV_COMPILE_2OP;
+    return Perl_sv_compile_2op_is_broken(aTHX_ sv, startop, code, padp);
+}
+
+/* Don't use this. It will go away without warning once the regexp engine is
+   refactored not to use it.  */
+OP *
+Perl_sv_compile_2op_is_broken(pTHX_ SV *sv, OP **startop, const char *code,
+                             PAD **padp)
+{
     dVAR; dSP;                         /* Make POPBLOCK work. */
     PERL_CONTEXT *cx;
     SV **newsp;
@@ -3003,7 +3015,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
     STRLEN len;
     bool need_catch;
 
-    PERL_ARGS_ASSERT_SV_COMPILE_2OP;
+    PERL_ARGS_ASSERT_SV_COMPILE_2OP_IS_BROKEN;
 
     ENTER_with_name("eval");
     lex_start(sv, NULL, 0);
diff --git a/proto.h b/proto.h
index 194d7ab..6b3fe77 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -4020,6 +4020,7 @@ PERL_CALLCONV I32 Perl_sv_cmp_flags(pTHX_ SV *const sv1, SV *const sv2, const U3
 PERL_CALLCONV I32      Perl_sv_cmp_locale(pTHX_ SV *const sv1, SV *const sv2);
 PERL_CALLCONV I32      Perl_sv_cmp_locale_flags(pTHX_ SV *const sv1, SV *const sv2, const U32 flags);
 PERL_CALLCONV OP*      Perl_sv_compile_2op(pTHX_ SV *sv, OP **startop, const char *code, PAD **padp)
+                       __attribute__deprecated__
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2)
                        __attribute__nonnull__(pTHX_3)
@@ -4027,6 +4028,14 @@ PERL_CALLCONV OP*        Perl_sv_compile_2op(pTHX_ SV *sv, OP **startop, const char *co
 #define PERL_ARGS_ASSERT_SV_COMPILE_2OP        \
        assert(sv); assert(startop); assert(code); assert(padp)
 
+PERL_CALLCONV OP*      Perl_sv_compile_2op_is_broken(pTHX_ SV *sv, OP **startop, const char *code, PAD **padp)
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_2)
+                       __attribute__nonnull__(pTHX_3)
+                       __attribute__nonnull__(pTHX_4);
+#define PERL_ARGS_ASSERT_SV_COMPILE_2OP_IS_BROKEN      \
+       assert(sv); assert(startop); assert(code); assert(padp)
+
 PERL_CALLCONV void     Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
index f01d545..07834a0 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6074,7 +6074,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
 
                    ENTER;
                    Perl_save_re_context(aTHX);
-                   rop = sv_compile_2op(sv, &sop, "re", &pad);
+                   rop = Perl_sv_compile_2op_is_broken(aTHX_ sv, &sop, "re", &pad);
                    sop->op_private |= OPpREFCOUNTED;
                    /* re_dup will OpREFCNT_inc */
                    OpREFCNT_set(sop, 1);