From: Yves Orton <demerphq@gmail.com>
Date: Sat, 4 Mar 2023 08:00:37 +0000 (+0100)
Subject: Upper.xs - in 5.37.6 cop_warnings became a char * (RCVP)
X-Git-Tag: rt146897
X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=370bfe152c9d352039f97df9a568719523536182;p=perl%2Fmodules%2FScope-Upper.git

Upper.xs - in 5.37.6 cop_warnings became a char * (RCVP)

It is actually a RCPV (RefCounted PV), so we can use RCPV_LEN() to
find its length.

Unfortunately there is not currently a way to "mortalize" a RCPV,
an oversight that I will correct in a future release of Perl. But
for now this should do.
---

diff --git a/Upper.xs b/Upper.xs
index 0c762de..7d994fc 100644
--- a/Upper.xs
+++ b/Upper.xs
@@ -3136,7 +3136,9 @@ PPCODE:
  /* warnings (9) */
  {
   SV *mask = NULL;
-#if XSH_HAS_PERL(5, 9, 4)
+#if XSH_HAS_PERL(5, 37, 6)
+  char *old_warnings = cop->cop_warnings;
+#elif XSH_HAS_PERL(5, 9, 4)
   STRLEN *old_warnings = cop->cop_warnings;
 #else
   SV *old_warnings = cop->cop_warnings;
@@ -3169,7 +3171,9 @@ context_info_warnings_on:
    if (!mask)
     mask = su_newmortal_pvn(WARN_ALLstring, WARNsize);
   } else {
-#if XSH_HAS_PERL(5, 9, 4)
+#if XSH_HAS_PERL(5, 37, 6)
+   mask = su_newmortal_pvn((char *) old_warnings, RCPV_LEN(old_warnings));
+#elif XSH_HAS_PERL(5, 9, 4)
    mask = su_newmortal_pvn((char *) (old_warnings + 1), old_warnings[0]);
 #else
    mask = sv_mortalcopy(old_warnings);