]> Savannah Git Hosting - gnulib.git/commitdiff
localename: Add support for musl libc.
authorBruno Haible <bruno@clisp.org>
Sat, 24 Feb 2018 11:59:59 +0000 (12:59 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 24 Feb 2018 11:59:59 +0000 (12:59 +0100)
* m4/localename.m4 (gl_LOCALENAME): Check for <langinfo.h>.
* lib/localename.c (gl_locale_name_thread_unsafe): Use NL_LOCALE_NAME
on Linux platforms which define NL_LOCALE_NAME.

ChangeLog
lib/localename.c
m4/localename.m4

index 0c1ebc057e6d4c0e1c5384975366b387a6e85ca5..58d9971414c26061c6c64985f36c9e344cc873d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-02-24  Bruno Haible  <bruno@clisp.org>
+
+       localename: Add support for musl libc.
+       * m4/localename.m4 (gl_LOCALENAME): Check for <langinfo.h>.
+       * lib/localename.c (gl_locale_name_thread_unsafe): Use NL_LOCALE_NAME
+       on Linux platforms which define NL_LOCALE_NAME.
+
 2018-02-24  Bruno Haible  <bruno@clisp.org>
 
        mbrtowc tests: Don't make assumptions about the charset the C locale.
index 2133cbc7ccb2e2bc2040697f26e0922578151122..74c8ee0011df75a3716a017c7f541f8546104efb 100644 (file)
@@ -40,7 +40,7 @@
 # if defined __APPLE__ && defined __MACH__
 #  include <xlocale.h>
 # endif
-# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || defined __CYGWIN__
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || (defined __linux__ && HAVE_LANGINFO_H) || defined __CYGWIN__
 #  include <langinfo.h>
 # endif
 # if !defined IN_LIBINTL
@@ -2703,6 +2703,9 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
              nl_langinfo (_NL_LOCALE_NAME (category)).  */
           name = thread_locale->__names[category];
         return name;
+#  elif defined __linux__ && HAVE_LANGINFO_H && defined NL_LOCALE_NAME
+        /* musl libc */
+        return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale);
 #  elif (defined __FreeBSD__ || defined __DragonFly__) || (defined __APPLE__ && defined __MACH__)
         /* FreeBSD, Mac OS X */
         int mask;
index 0ac4529a0608f827b66b9009e7f11ffffa2acb98..a0e136754e9ef7b4aa9238f53ba1a0a44484864b 100644 (file)
@@ -1,4 +1,4 @@
-# localename.m4 serial 2
+# localename.m4 serial 3
 dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_LOCALENAME],
 [
   AC_REQUIRE([gt_LC_MESSAGES])
   AC_REQUIRE([gt_INTL_MACOSX])
+  AC_CHECK_HEADERS_ONCE([langinfo.h])
   AC_CHECK_FUNCS([setlocale uselocale])
   dnl Solaris 12 provides getlocalename_l, while Illumos doesn't have
   dnl it nor the equivalent.