Skip Menu |
 

This queue is for tickets about the Devel-Declare CPAN distribution.

Report information
The Basics
Id: 99102
Status: resolved
Priority: 0/
Queue: Devel-Declare

People
Owner: ether [...] cpan.org
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.006017



Subject: [PATCH] Fix for 5.21.4
Download (untitled) / with headers
text/plain 454b
Here is a patch, but it is pretty ugly. I added cv_name to perl 5.21.4 to try to avoid this ternary mess, but it does not meet Devel::Declare’s needs, as it includes the package name. Do you think perhaps I should extend cv_name to take an extra parameter and let the latter choose whether the package is included? In that case, you could hold off on applying the patch, unless you want it to work with every dev version of perl. What do you think?
Subject: open_s1NmRrb1.txt
Download open_s1NmRrb1.txt
text/plain 2.2k
--- Devel-Declare-0.006016-G6Ji81-orig/Declare.xs 2014-09-23 22:41:09.000000000 -0700 +++ Devel-Declare-0.006016-G6Ji81/Declare.xs 2014-09-23 23:16:25.000000000 -0700 @@ -283,11 +283,22 @@ static void call_done_declare(pTHX) { static int dd_handle_const(pTHX_ char *name); +#ifdef CvNAMED +# define Gv_or_CvNAME(g) (isGV(g) \ + ? GvNAME(g) \ + : CvNAMED(SvRV(g)) \ + ? HEK_KEY(CvNAME_HEK((CV *)SvRV(g))) \ + : GvNAME(CvGV(SvRV(g)))) +#else +# define Gv_or_CvNAME(g) GvNAME(g) +#endif + /* replacement PL_check rv2cv entry */ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void *user_data) { OP* kid; int dd_flags; + char *gvname; PERL_UNUSED_VAR(user_data); @@ -304,11 +315,17 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void if (kid->op_type != OP_GV) /* not a GV so ignore */ return o; + if (!isGV(kGVOP_gv) + && (!SvROK(kGVOP_gv) || SvTYPE(SvRV(kGVOP_gv)) != SVt_PVCV)) + return o; + + gvname = Gv_or_CvNAME(kGVOP_gv); + if (DD_DEBUG_TRACE) { - printf("Checking GV %s -> %s\n", HvNAME(GvSTASH(kGVOP_gv)), GvNAME(kGVOP_gv)); + printf("Checking GV %s -> %s\n", HvNAME(GvSTASH(kGVOP_gv)), gvname); } - dd_flags = dd_is_declarator(aTHX_ GvNAME(kGVOP_gv)); + dd_flags = dd_is_declarator(aTHX_ gvname); if (dd_flags == -1) return o; @@ -320,23 +337,23 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void #if DD_CONST_VIA_RV2CV if (PL_expect != XOPERATOR) { - if (!dd_handle_const(aTHX_ GvNAME(kGVOP_gv))) + if (!dd_handle_const(aTHX_ Gv_or_CvNAME(kGVOP_gv))) return o; CopLINE(PL_curcop) = PL_copline; /* The parser behaviour that we're simulating depends on what comes after the declarator. */ - if (*skipspace(PL_bufptr + strlen(GvNAME(kGVOP_gv))) != '(') { + if (*skipspace(PL_bufptr + strlen(gvname)) != '(') { if (in_declare) { call_done_declare(aTHX); } else { - dd_linestr_callback(aTHX_ "rv2cv", GvNAME(kGVOP_gv)); + dd_linestr_callback(aTHX_ "rv2cv", gvname); } } return o; } #endif /* DD_CONST_VIA_RV2CV */ - dd_linestr_callback(aTHX_ "rv2cv", GvNAME(kGVOP_gv)); + dd_linestr_callback(aTHX_ "rv2cv", gvname); return o; }
Download (untitled) / with headers
text/plain 701b
On Wed Sep 24 02:17:02 2014, SPROUT wrote: Show quoted text
> Here is a patch, but it is pretty ugly. I added cv_name to perl > 5.21.4 to try to avoid this ternary mess, but it does not meet > Devel::Declare’s needs, as it includes the package name. > > Do you think perhaps I should extend cv_name to take an extra > parameter and let the latter choose whether the package is included? > > In that case, you could hold off on applying the patch, unless you > want it to work with every dev version of perl. > > What do you think?
Here is a new patch, using 5.21.5’s shiny new version of the cv_name interface. It also includes the 5.21.4 code. I leave it to use as to whether the former should be left in.
Subject: new-patch.text
Download new-patch.text
text/plain 2.4k
--- Devel-Declare-0.006016-s60Pb8-orig/Declare.xs 2014-02-02 18:39:25.000000000 -0800 +++ Devel-Declare-0.006016-s60Pb8/Declare.xs 2014-09-24 08:32:44.000000000 -0700 @@ -283,11 +283,26 @@ static void call_done_declare(pTHX) { static int dd_handle_const(pTHX_ char *name); +#ifdef CV_NAME_NOTQUAL /* 5.21.5 */ +# define Gv_or_CvNAME(g) (isGV(g) \ + ? GvNAME(g) \ + : SvPV_nolen(cv_name((CV *)SvRV(g), NULL, CV_NAME_NOTQUAL))) +#elif defined(CvNAMED) /* 5.21.4 */ +# define Gv_or_CvNAME(g) (isGV(g) \ + ? GvNAME(g) \ + : CvNAMED(SvRV(g)) \ + ? HEK_KEY(CvNAME_HEK((CV *)SvRV(g))) \ + : GvNAME(CvGV(SvRV(g)))) +#else +# define Gv_or_CvNAME(g) GvNAME(g) +#endif + /* replacement PL_check rv2cv entry */ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void *user_data) { OP* kid; int dd_flags; + char *gvname; PERL_UNUSED_VAR(user_data); @@ -304,11 +319,17 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void if (kid->op_type != OP_GV) /* not a GV so ignore */ return o; + if (!isGV(kGVOP_gv) + && (!SvROK(kGVOP_gv) || SvTYPE(SvRV(kGVOP_gv)) != SVt_PVCV)) + return o; + + gvname = Gv_or_CvNAME(kGVOP_gv); + if (DD_DEBUG_TRACE) { - printf("Checking GV %s -> %s\n", HvNAME(GvSTASH(kGVOP_gv)), GvNAME(kGVOP_gv)); + printf("Checking GV %s -> %s\n", HvNAME(GvSTASH(kGVOP_gv)), gvname); } - dd_flags = dd_is_declarator(aTHX_ GvNAME(kGVOP_gv)); + dd_flags = dd_is_declarator(aTHX_ gvname); if (dd_flags == -1) return o; @@ -320,23 +341,23 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o, void #if DD_CONST_VIA_RV2CV if (PL_expect != XOPERATOR) { - if (!dd_handle_const(aTHX_ GvNAME(kGVOP_gv))) + if (!dd_handle_const(aTHX_ Gv_or_CvNAME(kGVOP_gv))) return o; CopLINE(PL_curcop) = PL_copline; /* The parser behaviour that we're simulating depends on what comes after the declarator. */ - if (*skipspace(PL_bufptr + strlen(GvNAME(kGVOP_gv))) != '(') { + if (*skipspace(PL_bufptr + strlen(gvname)) != '(') { if (in_declare) { call_done_declare(aTHX); } else { - dd_linestr_callback(aTHX_ "rv2cv", GvNAME(kGVOP_gv)); + dd_linestr_callback(aTHX_ "rv2cv", gvname); } } return o; } #endif /* DD_CONST_VIA_RV2CV */ - dd_linestr_callback(aTHX_ "rv2cv", GvNAME(kGVOP_gv)); + dd_linestr_callback(aTHX_ "rv2cv", gvname); return o; }
Download (untitled) / with headers
text/plain 480b
On 2014-09-24 08:35:54, SPROUT wrote: Show quoted text
> Here is a new patch, using 5.21.5’s shiny new version of the cv_name > interface. > > It also includes the 5.21.4 code. I leave it to use as to whether the > former should > be left in.
Brilliant, I will review/apply/release in ~9 hours or so! (At first glance, I'd say 5.21.4 functionality should go in, for now, so as to unblock smokers on 5.21.4, but could easily come out again next month when 5.21.5 is out.) thank you so much!
Download (untitled) / with headers
text/plain 663b
On Wed Sep 24 12:16:47 2014, ETHER wrote: Show quoted text
> On 2014-09-24 08:35:54, SPROUT wrote: >
> > Here is a new patch, using 5.21.5’s shiny new version of the cv_name > > interface. > > > > It also includes the 5.21.4 code. I leave it to use as to whether > > the > > former should > > be left in.
> > Brilliant, I will review/apply/release in ~9 hours or so! > > (At first glance, I'd say 5.21.4 functionality should go in, for now, > so as to unblock smokers on 5.21.4, but could easily come out again > next month when 5.21.5 is out.) > > thank you so much!
You’re welcome. BTW, how did you end up maintaining every prominent CPAN module I’ve heard of? :-)
Download (untitled) / with headers
text/plain 651b
0.006017 has been released: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Devel-Declare.git On 2014-09-24 16:03:53, SPROUT wrote: Show quoted text
> On Wed Sep 24 12:16:47 2014, ETHER wrote:
> > Brilliant, I will review/apply/release in ~9 hours or so! > > > > (At first glance, I'd say 5.21.4 functionality should go in, for now, > > so as to unblock smokers on 5.21.4, but could easily come out again > > next month when 5.21.5 is out.) > > > > thank you so much!
> > You’re welcome. BTW, how did you end up maintaining every prominent > CPAN module I’ve heard of? :-)
I'm the first person the various authors found who didn't say no, I guess! :)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.