From: Vincent Pit Date: Sat, 2 May 2009 22:21:36 +0000 (+0200) Subject: Don't hardcode the package name as the hints key X-Git-Tag: v0.12~9 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=3b757f7116ccdc022577b2d5f177556c78bcfeb8 Don't hardcode the package name as the hints key --- diff --git a/indirect.xs b/indirect.xs index 2c1f089..e0362f0 100644 --- a/indirect.xs +++ b/indirect.xs @@ -6,6 +6,11 @@ #include "perl.h" #include "XSUB.h" +#define __PACKAGE__ "indirect" +#define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1) + +/* --- Compatibility wrappers ---------------------------------------------- */ + #ifndef SvPV_const # define SvPV_const SvPV #endif @@ -70,11 +75,12 @@ STATIC IV indirect_hint(pTHX) { #if I_HAS_PERL(5, 10, 0) id = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash, NULL, - "indirect", 8, + __PACKAGE__, __PACKAGE_LEN__, 0, indirect_hash); #else - SV **val = hv_fetch(GvHV(PL_hintgv), "indirect", 8, indirect_hash); + SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, + indirect_hash); if (!val) return 0; id = *val; @@ -363,8 +369,10 @@ PROTOTYPES: DISABLE BOOT: { if (!indirect_initialized++) { - PERL_HASH(indirect_hash, "indirect", 8); indirect_map = ptable_new(); + + PERL_HASH(indirect_hash, __PACKAGE__, __PACKAGE_LEN__); + indirect_old_ck_const = PL_check[OP_CONST]; PL_check[OP_CONST] = MEMBER_TO_FPTR(indirect_ck_const); indirect_old_ck_rv2sv = PL_check[OP_RV2SV]; diff --git a/lib/indirect.pm b/lib/indirect.pm index 5686fbc..51b69d1 100644 --- a/lib/indirect.pm +++ b/lib/indirect.pm @@ -57,13 +57,13 @@ BEGIN { } sub import { - $^H{indirect} = undef; + $^H{+(__PACKAGE__)} = undef; } sub unimport { (undef, my $type) = @_; $^H |= 0x00020000; - $^H{indirect} = (defined $type and $type eq ':fatal') ? 2 : 1; + $^H{+(__PACKAGE__)} = (defined $type and $type eq ':fatal') ? 2 : 1; } =head1 CAVEATS