This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl.h: Move #define to earlier in the file
authorKarl Williamson <khw@cpan.org>
Mon, 17 Jul 2017 19:27:59 +0000 (13:27 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 17 Jul 2017 19:37:02 +0000 (13:37 -0600)
I don't know when this bug got introduced (and am not taking the time
to find out), but a symbol was defined after other code tested if it was
defined, so that always failed, and the alternative implementation got
compiled.  I do know that the intended implementation was used at some
point, as I ended up fixing several bugs in it.

perl.h

diff --git a/perl.h b/perl.h
index 97a5ba3..01f8960 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5883,6 +5883,20 @@ typedef struct am_table_short AMTS;
 #ifdef USE_LOCALE
 /* These locale things are all subject to change */
 
+#  if      defined(USE_ITHREADS)                \
+      &&   defined(HAS_NEWLOCALE)               \
+      &&   defined(LC_ALL_MASK)                 \
+      &&   defined(HAS_FREELOCALE)              \
+      &&   defined(HAS_USELOCALE)               \
+      && ! defined(NO_THREAD_SAFE_USELOCALE)
+
+    /* The code is written for simplicity to assume that any platform advanced
+     * enough to have the Posix 2008 locale functions has LC_ALL.  The test
+     * above makes sure that assumption is valid */
+
+#    define USE_THREAD_SAFE_LOCALE
+#  endif
+
 #   define LOCALE_INIT   MUTEX_INIT(&PL_locale_mutex)
 
 #   ifdef USE_THREAD_SAFE_LOCALE
@@ -5987,20 +6001,6 @@ typedef struct am_table_short AMTS;
 
 #   endif   /* PERL_CORE or PERL_IN_XSUB_RE */
 
-#if      defined(USE_ITHREADS)              \
-    &&   defined(HAS_NEWLOCALE)             \
-    &&   defined(LC_ALL_MASK)               \
-    &&   defined(HAS_FREELOCALE)            \
-    &&   defined(HAS_USELOCALE)             \
-    && ! defined(NO_THREAD_SAFE_USELOCALE)
-
-    /* The code is written for simplicity to assume that any platform advanced
-     * enough to have the Posix 2008 locale functions has LC_ALL.  The test
-     * above makes sure that assumption is valid */
-
-#   define USE_THREAD_SAFE_LOCALE
-#endif
-
 #else   /* No locale usage */
 #   define LOCALE_INIT
 #   define LOCALE_TERM