* [PATCH] localename: Port to cygwin 2.6.
@ 2017-01-19 20:31 Eric Blake
2017-01-20 2:47 ` Eric Blake
0 siblings, 1 reply; 2+ messages in thread
From: Eric Blake @ 2017-01-19 20:31 UTC (permalink / raw)
To: bug-gnulib; +Cc: cygwin
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. I'm proposing a
patch to add NL_LOCALE_NAME() to Cygwin patterned after glibc's
extension of the same name, but we might as well work around it
in the meantime.
* lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
Cygwin.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
I won't actually push this to gnulib until I've sent the corresponding
newlib/Cygwin patch to add NL_LOCALE_NAME, and tweaked the commit
messages of both patches to refer to the appropriate mailing list
threads. But this was enough to get test-localename passing on
Cygwin again.
ChangeLog | 6 ++++++
lib/localename.c | 13 +++++++++++++
2 files changed, 19 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e4339fc..f0e23a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-19 Eric Blake <eblake@redhat.com>
+
+ localename: Port to cygwin 2.6.
+ * lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
+ Cygwin.
+
2017-01-17 Pádraig Brady <P@draigBrady.com>
parse-datetime: fix dependence on AC_PROG_SED
diff --git a/lib/localename.c b/lib/localename.c
index 33879e9..89ce889 100644
--- a/lib/localename.c
+++ b/lib/localename.c
@@ -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
--
2.9.3
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] localename: Port to cygwin 2.6.
2017-01-19 20:31 [PATCH] localename: Port to cygwin 2.6 Eric Blake
@ 2017-01-20 2:47 ` Eric Blake
0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2017-01-20 2:47 UTC (permalink / raw)
To: bug-gnulib; +Cc: cygwin
[-- Attachment #1.1: Type: text/plain, Size: 1191 bytes --]
On 01/19/2017 02:30 PM, Eric Blake wrote:
> 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. I'm proposing a
> patch to add NL_LOCALE_NAME() to Cygwin patterned after glibc's
> extension of the same name, but we might as well work around it
> in the meantime.
>
> * lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
> Cygwin.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>
> I won't actually push this to gnulib until I've sent the corresponding
> newlib/Cygwin patch to add NL_LOCALE_NAME, and tweaked the commit
> messages of both patches to refer to the appropriate mailing list
> threads. But this was enough to get test-localename passing on
> Cygwin again.
> +# ifdef NL_LOCALE_NAME
> + return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale);
Here's the proposed cygwin patch for adding NL_LOCALE_NAME():
https://sourceware.org/ml/newlib/2017/msg00071.html
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-20 2:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-19 20:31 [PATCH] localename: Port to cygwin 2.6 Eric Blake
2017-01-20 2:47 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).