Subject: | [PATCH] Fix for 5.17.4 |
This is not completely future-proof, as it treats pads as AVs still, but I am honestly starting to
run out of energy for this pad stuff. :-)
Subject: | open_XqW1AweH.txt |
diff -rup Sub-Mutate-0.004-YliM3H/lib/Sub/Mutate.xs Sub-Mutate-0.004-0McnN2/lib/Sub/Mutate.xs
--- Sub-Mutate-0.004-YliM3H/lib/Sub/Mutate.xs 2011-10-27 14:21:48.000000000 -0700
+++ Sub-Mutate-0.004-0McnN2/lib/Sub/Mutate.xs 2012-10-23 20:40:52.000000000 -0700
@@ -55,6 +55,18 @@ static void THX_sv_unbless(pTHX_ SV *sv)
(!sv_is_glob(sv) && !sv_is_regexp(sv) && \
(SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK|SVp_IOK|SVp_NOK|SVp_POK)))
+#ifdef PadARRAY
+# define NEWPADAPI
+#else
+typedef AV PADNAMELIST;
+# if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION)
+typedef AV PADLIST;
+typedef AV PAD;
+# endif
+# define PadlistARRAY(pl) ((PAD **)AvARRAY(pl))
+# define PadlistNAMES(pl) (*PadlistARRAY(pl))
+#endif
+
/*
* when_sub_bodied() mechanism:
*
@@ -100,29 +112,35 @@ static SV *whenbodied_running;
static HV *stash_whenbodied;
#define new_minimal_padlist() THX_new_minimal_padlist(aTHX)
-static AV *THX_new_minimal_padlist(pTHX)
+static PADLIST *THX_new_minimal_padlist(pTHX)
{
- AV *padlist, *pad;
+ PADLIST *padlist;
+ PAD *pad;
pad = newAV();
av_store(pad, 0, &PL_sv_undef);
+#ifdef NEWPADAPI
+ Newxz(padlist, 1, PADLIST);
+ Newx(PadlistARRAY(padlist), 2, PAD *);
+#else
padlist = newAV();
AvREAL_off(padlist);
av_extend(padlist, 1);
- av_store(padlist, 0, (SV*)newAV());
- av_store(padlist, 1, (SV*)pad);
+#endif
+ PadlistNAMES(padlist) = (PADNAMELIST *)newAV();
+ PadlistARRAY(padlist)[1] = pad;
return padlist;
}
#define cv_find_whenbodied(sub) THX_cv_find_whenbodied(aTHX_ sub)
static AV *THX_cv_find_whenbodied(pTHX_ CV *sub)
{
- AV *padlist;
+ PADLIST *padlist;
AV *argav;
I32 pos;
if(CvDEPTH(sub) != 0) return NULL;
padlist = CvPADLIST(sub);
if(!padlist) return NULL;
- argav = (AV*)safe_av_fetch((AV*)*av_fetch(padlist, 1, 0), 0);
+ argav = (AV*)safe_av_fetch((AV*)PadlistARRAY(padlist)[1], 0);
if(SvTYPE((SV*)argav) != SVt_PVAV) return NULL;
for(pos = av_len(argav); pos >= 0; pos--) {
SV *v = safe_av_fetch(argav, pos);
@@ -136,12 +154,13 @@ static AV *THX_cv_find_whenbodied(pTHX_
#define cv_force_whenbodied(sub) THX_cv_force_whenbodied(aTHX_ sub)
static AV *THX_cv_force_whenbodied(pTHX_ CV *sub)
{
- AV *padlist;
- AV *pad, *argav, *wb;
+ PADLIST *padlist;
+ PAD *pad;
+ AV *argav, *wb;
I32 pos;
padlist = CvPADLIST(sub);
if(!padlist) goto create_padlist;
- pad = (AV*)*av_fetch(padlist, 1, 0);
+ pad = PadlistARRAY(padlist)[1];
argav = (AV*)safe_av_fetch(pad, 0);
if(SvTYPE((SV*)argav) != SVt_PVAV) goto create_argav;
for(pos = av_len(argav); pos >= 0; pos--) {