This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Tighten turkish locale tests on C99 platforms
authorKarl Williamson <khw@cpan.org>
Sun, 17 Feb 2019 05:01:44 +0000 (22:01 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 4 Mar 2019 20:01:37 +0000 (13:01 -0700)
C99 has wide character case changing.  If those are available, use them
to be surer we have a Turkic locale.

locale.c

index 3a2e49d..e2bb54e 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -53,6 +53,9 @@
 #ifdef I_WCHAR
 #  include <wchar.h>
 #endif
+#ifdef I_WCTYPE
+#  include <wctype.h>
+#endif
 
 /* If the environment says to, we can output debugging information during
  * initialization.  This is done before option parsing, and before any thread
@@ -1528,7 +1531,16 @@ S_new_ctype(pTHX_ const char *newctype)
         /* UTF-8 locales can have special handling for 'I' and 'i' if they are
          * Turkic.  Make sure these two are the only anomalies.  (We don't use
          * towupper and towlower because they aren't in C89.) */
+
+#if defined(HAS_TOWUPPER) && defined (HAS_TOWLOWER)
+
+        if (towupper('i') == 0x130 && towlower('I') == 0x131) {
+
+#else
+
         if (toupper('i') == 'i' && tolower('I') == 'I') {
+
+#endif
             check_for_problems = TRUE;
             maybe_utf8_turkic = TRUE;
         }