Skip Menu |

This queue is for tickets about the Sub-Name CPAN distribution.

Report information
The Basics
Id: 65540
Status: stalled
Priority: 0/
Queue: Sub-Name

People
Owner: Nobody in particular
Requestors: chip [...] pobox.com
Cc: ribasushi [...] leporine.io
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.05
Fixed in: (no value)



Subject: delete old names for debugging purposes
When a subroutine is renamed, %DB::sub has new entries added but old ones not removed. That really messes up tab completion when code heavily uses Sub::Name, e.g. via Method::Signatures. diff --git Name.xs Name.xs index f6d7bc2..656ae8d 100644 --- Name.xs +++ Name.xs @@ -7,6 +7,11 @@ #include "perl.h" #include "XSUB.h" +/* 5.8.8 is the first version with this, apparently */ +#ifndef SvPVX_const +#define SvPVX_const(sv) ((const char *)SvPVX(sv)) +#endif + static MGVTBL subname_vtbl; #ifndef PERL_MAGIC_ext @@ -82,6 +87,19 @@ subname(name, sub) mg->mg_flags |= MGf_REFCOUNTED; mg->mg_obj = (SV *) gv; SvRMAGICAL_on(cv); + + if (PERLDB_SUBLINE && CvGV(cv) && isGV(CvGV(cv))) { + SV * const namesv = sv_newmortal(); + SV *infosv; + gv_efullname3(namesv, CvGV(cv), NULL); + infosv = hv_delete(GvHV(PL_DBsub), SvPVX_const(namesv), SvCUR(namesv), 0); + if (infosv) { + /* we use the gv's idea of its spelling, in case we call subname again on the same CV */ + gv_efullname3(namesv, gv, NULL); + (void)hv_store(GvHV(PL_DBsub), SvPVX_const(namesv), SvCUR(namesv), SvREFCNT_inc(infosv), 0); + } + } + CvANON_off(cv); #ifndef CvGV_set CvGV(cv) = gv;
FYI, this patch causes one of the tests proposed to be added in #50524 to fail.
On Mon Feb 07 21:02:29 2011, CHIPS wrote: Show quoted text
> When a subroutine is renamed, %DB::sub has new entries added but old > ones not removed. That really messes up tab completion when code > heavily uses Sub::Name, e.g. via Method::Signatures.
Chip, could you please check if the Sub::Name currently on CPAN (0.13) does solve the problem for you via https://github.com/karenetheridge/Sub-Name/commit/3967e628 Cheers!
I'm not sure if 0.13 is sufficient, or if more work needs to be done - can you take a look? If we need more, then we should look again at the proposed patch and get it to pass tests.