From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79812 invoked by alias); 19 Jan 2017 20:31:14 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 79734 invoked by uid 89); 19 Jan 2017 20:31:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=U*eblake, sk:eblake, sk:eblake@, eblakeredhatcom X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 20:30:59 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8189C0567B5; Thu, 19 Jan 2017 20:30:59 +0000 (UTC) Received: from red.redhat.com (ovpn-117-52.rdu2.redhat.com [10.10.117.52]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0JKUwRj012347; Thu, 19 Jan 2017 15:30:59 -0500 From: Eric Blake To: bug-gnulib@gnu.org Cc: cygwin@cygwin.com Subject: [PATCH] localename: Port to cygwin 2.6. Date: Thu, 19 Jan 2017 20:31:00 -0000 Message-Id: <20170119203057.13986-1-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00259.txt.bz2 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 --- 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 + + localename: Port to cygwin 2.6. + * lib/localename.c (gl_locale_name_thread_unsafe): Add clause for + Cygwin. + 2017-01-17 Pádraig Brady 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