-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 31/01/15 16:21, Alexander Pyhalov via illumos-discuss a écrit :
> Hello.
> I looked at coreutils testsuite. One of the tests failed, because it
> uses the following function to query thread locale:
>
> const char *
> gl_locale_name_thread_unsafe (int category, const char *categoryname)
> {
> # if HAVE_USELOCALE
> {
> locale_t thread_locale = uselocale (NULL);
> if (thread_locale != LC_GLOBAL_LOCALE)
> {
> # if __GLIBC__ >= 2 && !defined __UCLIBC__
> /* Work around an incorrect definition of the _NL_LOCALE_NAME
> macro in
> glibc < 2.12.
> See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>.
> */
> const char *name =
> nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
> if (name[0] == '\0')
> /* Fallback code for glibc < 2.4, which did not implement
> nl_langinfo (_NL_LOCALE_NAME (category)). */
> name = thread_locale->__names[category];
> return name;
> # elif defined __FreeBSD__ || (defined __APPLE__ && defined __MACH__)
> /* FreeBSD, Mac OS X */
> int mask;
>
> switch (category)
> {
> case LC_CTYPE:
> mask = LC_CTYPE_MASK;
> break;
> case LC_NUMERIC:
> mask = LC_NUMERIC_MASK;
> break;
> case LC_TIME:
> mask = LC_TIME_MASK;
> break;
> case LC_COLLATE:
> mask = LC_COLLATE_MASK;
> break;
> case LC_MONETARY:
> mask = LC_MONETARY_MASK;
> break;
> case LC_MESSAGES:
> mask = LC_MESSAGES_MASK;
> break;
> default: /* We shouldn't get here. */
> return "";
> }
> return querylocale (mask, thread_locale);
> # endif
> }
> }
> # endif
> return NULL;
> }
>
> As you see, on illumos it just returns NULL.
>
> Solaris 12 has getlocalename_l (category, thread_locale) function.
>
> Do we have some similar function?
>
> The following patch was proposed for Solaris:
>
>
>
> diff --git a/lib/localename.c b/lib/localename.c
> index 815171c..c6f326e 100644
> --- a/lib/localename.c
> +++ b/lib/localename.c
> @@ -42,6 +42,10 @@
> # if !defined IN_LIBINTL
> # include "glthread/lock.h"
> # endif
> +# if defined __sun
> +/* Solaris >= 12. */
> +extern char * getlocalename_l(int, locale_t);
> +# endif
> #endif
>
> #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
> @@ -2584,7 +2588,7 @@ get_lcid (const char *locale_name)
> #endif
>
>
> -#if HAVE_USELOCALE /* glibc or Mac OS X */
> +#if HAVE_USELOCALE /* glibc, Solaris >= 12 or Mac OS X */
>
> /* Simple hash set of strings. We don't want to drag in lots of hash
> table
> code here. */
> @@ -2723,6 +2727,9 @@ gl_locale_name_thread_unsafe (int category, const
> char *categoryname)
> return "";
> }
> return querylocale (mask, thread_locale);
> +# elif defined __sun
> + /* Solaris >= 12. */
> + return getlocalename_l (category, thread_locale);
> # endif
> }
> }
>
Sort of like https://www.illumos.org/issues/5346
I wonder if it would not be more useful to complete/implement as with
http://www.unix.com/man-page/freebsd/3/querylocale/ ...
apparently there are others such as MAC that have done so
(not sure the status of POSIX).
that is, xlocale.h, in part, is already in the gate.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJUzRUjAAoJECAB22fHtp27tssIAIflh5r1Qsu2yxvQ6iz2OFgg
eEzWgC+8PsUTFlsLRN0LSATBYB40uUsIiDMvcw2f2MH2Itxb64acZszQvvyAzWE+
oRmLaPJJbH8ySQ7S3B++yOJQMUHlSs5j1dH+aiBbkqaqrvXBvqHE8UJXchiQaD+1
iHczEs0mW64DKYr1bCZBQBdbcmdsudQt6v4KBZxApVIeIG7cfRkITfUwa4GBRksf
egwQ3n79uEm/foOKrTL40AHSlGHsmdJVMPAFvcYRVgGYXSG1wHhKA7JewzURMdgz
3A64XMxLFEu7QhtW13FmVU00ABQDPrAJGhacpCxJ/fJ1BJ3mBEA4tYNd/TDEneg=
=2yUk
-----END PGP SIGNATURE-----
-------------------------------------------
illumos-discuss
Archives: https://www.listbox.com/member/archive/182180/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182180/21175430-2e6923be
Modify Your Subscription:
https://www.listbox.com/member/?member_id=21175430&id_secret=21175430-6a77cda4
Powered by Listbox: http://www.listbox.com