Subject: | [PATCH] Pad changes in 5.17.4-to-be |
This module no longer works with bleadperl. Attached is a patch, which also adds SvPADMY_on,
to avoid an assertion failure under debugging builds. For more information, see:
http://perl5.git.perl.org/perl.git/commitdiff/86b9d2936
http://perl5.git.perl.org/perl.git/commitdiff/35e035ccb
http://perl5.git.perl.org/perl.git/commitdiff/86d2498c0
Subject: | open_n5oR8Ffw.txt |
diff -rup Devel-LexAlias-0.04-7t2BtE/LexAlias.xs Devel-LexAlias-0.04-ApTscO/LexAlias.xs
--- Devel-LexAlias-0.04-7t2BtE/LexAlias.xs 2002-07-25 07:25:22.000000000 -0700
+++ Devel-LexAlias-0.04-ApTscO/LexAlias.xs 2012-08-28 12:01:35.000000000 -0700
@@ -4,6 +4,20 @@
#include "perl.h"
#include "XSUB.h"
+#ifndef PadARRAY
+typedef AV PADNAMELIST;
+typedef SV PADNAME;
+# if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION)
+typedef AV PAD;
+# endif
+# define PadlistARRAY(pl) ((PAD **)AvARRAY(pl))
+# define PadlistNAMES(pl) (*PadlistARRAY(pl))
+# define PadnamelistARRAY(pnl) ((PADNAME **)AvARRAY(pnl))
+# define PadnamelistMAX(pnl) AvFILLp(pnl)
+# define PadARRAY AvARRAY
+# define PadnamePV(pn) (SvPOKp(pn) ? SvPVX(pn) : NULL)
+#endif
+
/* cargo-culted from PadWalker */
MODULE = Devel::LexAlias PACKAGE = Devel::LexAlias
@@ -13,28 +27,24 @@ _lexalias(SV* cv_ref, char *name, SV* ne
CODE:
{
CV *cv = SvROK(cv_ref) ? (CV*) SvRV(cv_ref) : NULL;
- AV* padn = cv ? (AV*) AvARRAY(CvPADLIST(cv))[0] : PL_comppad_name;
- AV* padv = cv ? (AV*) AvARRAY(CvPADLIST(cv))[1] : PL_comppad;
+ PADNAMELIST* padn = cv ? PadlistNAMES(CvPADLIST(cv)) : PL_comppad_name;
+ PAD* padv = cv ? PadlistARRAY(CvPADLIST(cv))[1] : PL_comppad;
SV* new_sv;
I32 i;
if (!SvROK(new_rv)) croak("ref is not a reference");
new_sv = SvRV(new_rv);
- for (i = 0; i <= av_len(padn); ++i) {
- SV** name_ptr = av_fetch(padn, i, 0);
- if (name_ptr) {
- SV* name_sv = *name_ptr;
-
- if (SvPOKp(name_sv)) {
- char *name_str = SvPVX(name_sv);
-
+ for (i = 0; i <= PadnamelistMAX(padn); ++i) {
+ PADNAME *namesv = PadnamelistARRAY(padn)[i];
+ char *name_str;
+ if (namesv && (name_str = PadnamePV(namesv))) {
if (!strcmp(name, name_str)) {
- SV* old_sv = (SV*) av_fetch(padv, i, 0);
- av_store(padv, i, new_sv);
+ SvREFCNT_dec(PadARRAY(padv)[i]);
+ PadARRAY(padv)[i] = new_sv;
SvREFCNT_inc(new_sv);
+ SvPADMY_on(new_sv);
}
- }
}
}
}