This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Skip compiling fallback code on modern platforms
authorKarl Williamson <khw@cpan.org>
Fri, 11 Jul 2014 21:42:21 +0000 (15:42 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 12 Jul 2014 14:41:14 +0000 (08:41 -0600)
In the function that determines if a POSIX locale is UTF-8 or not, if
either nl_langinfo or MB_CUR_MAX are defined, it can reliably determine
the answer.  If they are not defined, it uses heuristics to figure
things out as best it can.  This code doesn't add value for those
platforms where one of the two symbols is defined, so can just be
ifdef'd out

locale.c

index e4e6650..ca138da 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -1158,7 +1158,9 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
 
   cant_use_nllanginfo:
 
-#endif /* HAS_NL_LANGINFO etc */
+#else   /* nl_langinfo should work if available, so don't bother compiling this
+           fallback code.  The final fallback of looking at the name is
+           compiled, and will be executed if nl_langinfo fails */
 
     /* nl_langinfo not available or failed somehow.  Next try looking at the
      * currency symbol to see if it disambiguates things.  Often that will be
@@ -1315,6 +1317,8 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
 
 #endif
 
+#endif /* the code that is compiled when no nl_langinfo */
+
     /* As a last resort, look at the locale name to see if it matches
      * qr/UTF -?  * 8 /ix, or some other common locale names.  This "name", the
      * return of setlocale(), is actually defined to be opaque, so we can't