bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

localename: add support for musl libc


From: Bruno Haible
Subject: localename: add support for musl libc
Date: Sat, 24 Feb 2018 13:01:07 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-112-generic; KDE/5.18.0; x86_64; ; )

On Alpine Linux 3.7.0, which uses musl libc, I see this test failure:

FAIL: test-localename
=====================

../../gltests/test-localename.c:183: assertion 'strcmp (name, "fr_FR.UTF-8") == 
0' failed
FAIL test-localename (exit status: 134)

This patch fixes it.


2018-02-24  Bruno Haible  <address@hidden>

        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.

diff --git a/lib/localename.c b/lib/localename.c
index 2133cbc..74c8ee0 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -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;
diff --git a/m4/localename.m4 b/m4/localename.m4
index 0ac4529..a0e1367 100644
--- a/m4/localename.m4
+++ b/m4/localename.m4
@@ -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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]