summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hv.c14
-rw-r--r--hv.h3
-rw-r--r--toke.c10
3 files changed, 17 insertions, 10 deletions
diff --git a/hv.c b/hv.c
index 7d5843811e..1c5e6bc776 100644
--- a/hv.c
+++ b/hv.c
@@ -2995,7 +2995,7 @@ Perl_refcounted_he_fetch_pvn(pTHX_ const struct refcounted_he *chain,
U8 utf8_flag;
PERL_ARGS_ASSERT_REFCOUNTED_HE_FETCH_PVN;
- if (flags & ~REFCOUNTED_HE_KEY_UTF8)
+ if (flags & ~(REFCOUNTED_HE_KEY_UTF8|REFCOUNTED_HE_EXISTS))
Perl_croak(aTHX_ "panic: refcounted_he_fetch_pvn bad flags %"UVxf,
(UV)flags);
if (!chain)
@@ -3047,9 +3047,15 @@ Perl_refcounted_he_fetch_pvn(pTHX_ const struct refcounted_he *chain,
utf8_flag == (HEK_FLAGS(chain->refcounted_he_hek) & HVhek_UTF8)
#endif
)
- return sv_2mortal(refcounted_he_value(chain));
- }
- return &PL_sv_placeholder;
+ return
+ flags & REFCOUNTED_HE_EXISTS
+ ? (chain->refcounted_he_data[0] & HVrhek_typemask)
+ == HVrhek_delete
+ ? NULL
+ : &PL_sv_yes
+ : sv_2mortal(refcounted_he_value(chain));
+ }
+ return flags & REFCOUNTED_HE_EXISTS ? NULL : &PL_sv_placeholder;
}
/*
diff --git a/hv.h b/hv.h
index e45460a8c0..05245d58a7 100644
--- a/hv.h
+++ b/hv.h
@@ -509,6 +509,9 @@ struct refcounted_he;
/* flags for the refcounted_he API */
#define REFCOUNTED_HE_KEY_UTF8 0x00000001
+#ifdef PERL_CORE
+# define REFCOUNTED_HE_EXISTS 0x00000002
+#endif
#ifdef PERL_CORE
diff --git a/toke.c b/toke.c
index 643928ddae..286eb96f9a 100644
--- a/toke.c
+++ b/toke.c
@@ -613,13 +613,11 @@ Perl_feature_is_enabled(pTHX_ const char *const name, STRLEN namelen,
memcpy(&he_name[8 + 2*negate], name, namelen);
return
- (
- cop_hints_fetch_pvn(
- PL_curcop, he_name, 8 + 2*negate + namelen, 0, 0
- )
- != &PL_sv_placeholder
+ !cop_hints_fetch_pvn(
+ PL_curcop, he_name, 8 + 2*negate + namelen, 0,
+ REFCOUNTED_HE_EXISTS
)
- != negate;
+ != !negate;
}
/*