]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - autovivification.xs
Handle non-numeric hints
[perl/modules/autovivification.git] / autovivification.xs
index cb81c0f95bfe27cc60ac3e5a0e85bb4ca2b21317..a8367a0a961e07b2f0b8665f4dec351e0c92e12d 100644 (file)
@@ -94,7 +94,18 @@ STATIC UV a_detag(pTHX_ const SV *hint) {
 #else /* A_WORKAROUND_REQUIRE_PROPAGATION */
 
 #define a_tag(B)   newSVuv(B)
-#define a_detag(H) (((H) && SvOK(H)) ? SvUVX(H) : 0)
+/* PVs fetched from the hints chain have their SvLEN set to zero, so get the UV
+ * from a copy. */
+#define a_detag(H) \
+ ((H)              \
+  ? (SvIOK(H)      \
+     ? SvUVX(H)    \
+     : (SvPOK(H)   \
+        ? sv_2uv(SvLEN(H) ? (H) : sv_mortalcopy(H)) \
+       : 0        \
+       )           \
+     )             \
+  : 0)
 
 #endif /* !A_WORKAROUND_REQUIRE_PROPAGATION */