]> Savannah Git Hosting - gnulib.git/commitdiff
localename: port to cygwin 2.6
authorEric Blake <eblake@redhat.com>
Thu, 19 Jan 2017 20:26:30 +0000 (14:26 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 20 Jan 2017 15:29:39 +0000 (09:29 -0600)
Cygwin 2.6 introduced uselocale() and thread-local locales in general,
but lacks any way to get at the name of each portion of a locale_t
object short of peeking behind an opaque object.  Cygwin has just
been patched to add NL_LOCALE_NAME() patterned after glibc's
extension of the same name[1], but as that version of Cygwin has not
yet been released, we might as well work around it in the meantime.

[1] https://sourceware.org/ml/newlib/2017/msg00071.html

* lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
Cygwin.
* modules/localename (Depends-on): Add extensions, since
NL_LOCALE_NAME() is not visible without it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/localename.c
modules/localename

index e4339fc94883aa3df782e6b9d73039715dc69c65..41fbf4a31d8066fef198fcd0c7bc27c1a5a6c353 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-01-20  Eric Blake  <eblake@redhat.com>
+
+       localename: port to cygwin 2.6
+       * lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
+       Cygwin.
+       * modules/localename (Depends-on): Add extensions, since
+       NL_LOCALE_NAME() is not visible without it.
+
 2017-01-17  Pádraig Brady  <P@draigBrady.com>
 
        parse-datetime: fix dependence on AC_PROG_SED
index 33879e9df299c30a877f7a408e609ed0db2b8d70..89ce88974f0480bc7d96f0462c093f3459cc3292 100644 (file)
@@ -2734,6 +2734,19 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
 #  elif defined __sun && HAVE_GETLOCALENAME_L
         /* Solaris >= 12.  */
         return getlocalename_l (category, thread_locale);
+#  elif defined __CYGWIN__
+        /* Cygwin < 2.6 lacks uselocale and thread-local locales altogether.
+           Cygwin <= 2.6.1 lacks NL_LOCALE_NAME, requiring peeking inside
+           an opaque struct.  */
+#   ifdef NL_LOCALE_NAME
+        return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale);
+#   else
+        /* FIXME: Remove when we can assume new-enough Cygwin.  */
+        struct __locale_t {
+          char categories[7][32];
+        };
+        return ((struct __locale_t *) thread_locale)->categories[category];
+#   endif
 #  elif defined __ANDROID__
         return MB_CUR_MAX == 4 ? "C.UTF-8" : "C";
 #  endif
index 193c7bd754128523d094d7805a07c5024d1f9ef1..ec6cd1cc3b2e9d39bfa3a244f6e32769fcf7ad9e 100644 (file)
@@ -9,6 +9,7 @@ m4/intlmacosx.m4
 m4/lcmessage.m4
 
 Depends-on:
+extensions
 flexmember
 strdup
 lock