]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Only enable the pragma during compile time
[perl/modules/indirect.git] / indirect.xs
index 01b4a77ab3494923b1b1297b39a662f9c3029744..45309ce648a1cf43b3b0cccd4a31b076d864a616 100644 (file)
@@ -351,6 +351,10 @@ STATIC U32 indirect_hash = 0;
 STATIC SV *indirect_hint(pTHX) {
 #define indirect_hint() indirect_hint(aTHX)
  SV *hint;
+
+ if (IN_PERL_RUNTIME)
+  return NULL;
+
 #if I_HAS_PERL(5, 9, 5)
  hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
                                        NULL,
@@ -358,11 +362,13 @@ STATIC SV *indirect_hint(pTHX) {
                                        0,
                                        indirect_hash);
 #else
- SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__,
+ {
+  SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__,
                                                                  indirect_hash);
- if (!val)
-  return 0;
- hint = *val;
+  if (!val)
+   return 0;
+  hint = *val;
+ }
 #endif
  return indirect_detag(hint);
 }
@@ -604,6 +610,16 @@ done:
 
 /* ... ck_entersub ......................................................... */
 
+STATIC int indirect_is_indirect(const indirect_op_info_t *moi, const indirect_op_info_t *ooi) {
+ if (moi->pos > ooi->pos)
+  return 0;
+
+ if (moi->pos == ooi->pos)
+  return moi->len == ooi->len && !memcmp(moi->buf, ooi->buf, moi->len);
+
+ return 1;
+}
+
 STATIC OP *(*indirect_old_ck_entersub)(pTHX_ OP *) = 0;
 
 STATIC OP *indirect_ck_entersub(pTHX_ OP *o) {
@@ -651,7 +667,7 @@ STATIC OP *indirect_ck_entersub(pTHX_ OP *o) {
   if (!(ooi && ooi->pos))
    goto done;
 
-  if (moi->pos < ooi->pos) {
+  if (indirect_is_indirect(moi, ooi)) {
    SV *file;
    dSP;