Subject: | [PATCH] Fix for 5.17.4 |
See attachment.
Subject: | open_dTvDH6eC.txt |
diff -rup Sub-Filter-0.003-UMmAWy/lib/Sub/Filter.xs Sub-Filter-0.003-627dHk/lib/Sub/Filter.xs
--- Sub-Filter-0.003-UMmAWy/lib/Sub/Filter.xs 2010-11-21 01:59:34.000000000 -0800
+++ Sub-Filter-0.003-627dHk/lib/Sub/Filter.xs 2012-10-23 21:29:32.000000000 -0700
@@ -141,6 +141,18 @@ static void *THX_ptr_table_fetch(pTHX_ P
# define case_OP_ONCE_
#endif /* <5.10.0 */
+#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
+
#define canonise_retvalues(gimme) THX_canonise_retvalues(aTHX_ gimme)
static void THX_canonise_retvalues(pTHX_ I32 gimme)
{
@@ -162,25 +174,31 @@ static void THX_canonise_retvalues(pTHX_
}
#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), 4, PAD *);
+#else
padlist = newAV();
AvREAL_off(padlist);
- av_extend(padlist, 1);
- av_store(padlist, 0, (SV*)newAV());
- av_store(padlist, 1, (SV*)pad);
+ av_extend(padlist, 3);
+#endif
+ PadlistNAMES(padlist) = (PADNAMELIST *)newAV();
+ PadlistARRAY(padlist)[1] = pad;
return padlist;
}
static void xsfunc_runfilter(pTHX_ CV *wrappersub)
{
I32 gimme = GIMME_V;
- AV *padlist = CvPADLIST(wrappersub);
- CV *innersub = (CV*)*av_fetch(padlist, 2, 0);
- CV *filtersub = (CV*)*av_fetch(padlist, 3, 0);
+ PADLIST *padlist = CvPADLIST(wrappersub);
+ CV *innersub = (CV*)PadlistARRAY(padlist)[2];
+ CV *filtersub = (CV*)PadlistARRAY(padlist)[3];
dMARK; dORIGMARK;
PUSHMARK(MARK);
CvXSUB(innersub)(aTHX_ innersub);
@@ -210,9 +228,9 @@ static void THX_swap_cvs(pTHX_ CV *a, CV
static void THX_apply_retfilter_to_xsub(pTHX_ CV *target, CV *filter)
{
CV *wrapper = (CV*)newSV_type(SVt_PVCV);
- AV *padlist = CvPADLIST(wrapper) = new_minimal_padlist();
- av_store(padlist, 2, (SV*)wrapper);
- av_store(padlist, 3, SvREFCNT_inc((SV*)filter));
+ PADLIST *padlist = CvPADLIST(wrapper) = new_minimal_padlist();
+ PadlistARRAY(padlist)[2] = (PAD*)wrapper;
+ PadlistARRAY(padlist)[3] = (PAD*)SvREFCNT_inc((SV*)filter);
if(SvPOK(target))
sv_setpvn((SV*)wrapper, SvPVX(target), SvCUR(target));
if(SvOBJECT(target)) {