This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Copy MB_CUR_MAX to a local
authorKarl Williamson <khw@cpan.org>
Tue, 12 Sep 2023 03:28:34 +0000 (21:28 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 28 Sep 2023 14:55:51 +0000 (08:55 -0600)
This will be needed in a future commit.

locale.c

index 6ab5306..b03921f 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -3690,7 +3690,9 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
      * locale requires more than one byte, there are going to be BIG problems.
      * */
 
-    if (MB_CUR_MAX > 1 && ! PL_in_utf8_CTYPE_locale
+    const int mb_cur_max = MB_CUR_MAX;
+
+    if (mb_cur_max > 1 && ! PL_in_utf8_CTYPE_locale
 
             /* Some platforms return MB_CUR_MAX > 1 for even the "C" locale.
              * Just assume that the implementation for them (plus for POSIX) is
@@ -3700,7 +3702,7 @@ S_new_ctype(pTHX_ const char *newctype, bool force)
         && ! isNAME_C_OR_POSIX(newctype))
     {
         DEBUG_L(PerlIO_printf(Perl_debug_log,
-                            "Unsupported, MB_CUR_MAX=%d\n", (int) MB_CUR_MAX));
+                              "Unsupported, MB_CUR_MAX=%d\n", mb_cur_max));
 
         Perl_ck_warner_d(aTHX_ packWARN(WARN_LOCALE),
                          "Locale '%s' is unsupported, and may crash the"