]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Don't hardcode the package name as the hints key
authorVincent Pit <vince@profvince.com>
Sat, 2 May 2009 22:21:36 +0000 (00:21 +0200)
committerVincent Pit <vince@profvince.com>
Sat, 2 May 2009 22:21:36 +0000 (00:21 +0200)
indirect.xs
lib/indirect.pm

index 2c1f089cb7b2802bcf56ff8a9a82b56386379455..e0362f03ab0f34f74babc6204e527abeb334d802 100644 (file)
@@ -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];
index 5686fbceca6cb6d03f91853e6cc2ccc7def55c2c..51b69d15205bbd2f72a545a2b7c9fe8c12555bd1 100644 (file)
@@ -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