Fix p5-Text-Xslate on Perl 5.8.5
authorNicolas R <atoomic@cpan.org>
Tue, 1 Oct 2019 15:01:30 +0000 (09:01 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 11 Oct 2019 20:19:28 +0000 (14:19 -0600)
Fixes #140

This is a patch from @pali, to fix the
failure seen by @skaji on p5-Text-Xslate.

(cherry picked from commit 923705f8512cc1f17b01de6008d52f865f63b856)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/parts/inc/Sv_set

index 97533a6..2e2b0d5 100644 (file)
@@ -25,15 +25,15 @@ sv_setsv_flags
 #if ( { VERSION >= 5.7.3 } && { VERSION < 5.8.7 } ) || ( { VERSION >= 5.9.0 } && { VERSION < 5.9.2 } )
 #undef sv_setsv_flags
 #define SV_NOSTEAL 16
-#define sv_setsv_flags(dstr, sstr, flags)                                \
-  STMT_START {                                                           \
-    if (((flags) & SV_NOSTEAL) && (SvFLAGS((sstr)) & SVs_TEMP)) {        \
-      SvTEMP_off((sstr));                                                \
-      Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL);  \
-      SvTEMP_on((sstr));                                                 \
-    } else {                                                             \
-      Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL);  \
-    }                                                                    \
+#define sv_setsv_flags(dstr, sstr, flags)                                          \
+  STMT_START {                                                                     \
+    if (((flags) & SV_NOSTEAL) && (sstr) && (SvFLAGS((SV *)(sstr)) & SVs_TEMP)) {  \
+      SvTEMP_off((SV *)(sstr));                                                    \
+      Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL);            \
+      SvTEMP_on((SV *)(sstr));                                                     \
+    } else {                                                                       \
+      Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL);            \
+    }                                                                              \
   } STMT_END
 #endif
 
@@ -160,6 +160,18 @@ newSVsv_nomg(sv)
 
 #endif
 
+void
+sv_setsv_compile_test(sv)
+        SV *sv
+        CODE:
+                sv_setsv(sv, NULL);
+#ifdef sv_setsv_flags
+                sv_setsv_flags(sv, NULL, 0);
+#ifdef SV_NOSTEAL
+                sv_setsv_flags(sv, NULL, SV_NOSTEAL);
+#endif
+#endif
+
 =tests plan => 15
 
 my $foo = 5;