[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use of thread-unsafe localeconv in vasprintf
From: |
Bruno Haible |
Subject: |
Re: use of thread-unsafe localeconv in vasprintf |
Date: |
Tue, 27 Mar 2007 13:58:25 +0200 |
User-agent: |
KMail/1.5.4 |
Simon Josefsson wrote:
> Actually, nl_langinfo is documented to need not be thread-safe:
>
> http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
And the same page lists also ecvt(), fcvt(), gcvt() as not being thread-safe.
Argh.
> Btw, can we use the system's native sprintf to get the locale-aware
> decimal point in a thread-safe way? sprintf is guaranteed to be
> thread-safe, I believe.
Yes, I finally had the same idea. How about this? We don't care much about
efficiency at this point in the code.
Bruno
*** lib/vasnprintf.c 26 Mar 2007 02:15:46 -0000 1.36
--- lib/vasnprintf.c 27 Mar 2007 11:55:11 -0000
***************
*** 511,521 ****
|| mantissa > 0.0L || precision > 0)
{
const char *point;
! /* Prefer nl_langinfo() over localeconv(),
! since the latter is not multithread-
! safe. */
! # if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
# else
point = localeconv () -> decimal_point;
# endif
--- 511,527 ----
|| mantissa > 0.0L || precision > 0)
{
const char *point;
! /* Determine the decimal-point character in a
! multithread-safe way. We know nl_langinfo
! is multithread-safe on glibc systems,
! otherwise use sprintf, since localeconv()
! is rarely multithread-safe. */
! # if HAVE_NL_LANGINFO && __GLIBC__
! point = nl_langinfo (RADIXCHAR);
! # elif 1
! char pointbuf[5];
! sprintf (pointbuf, "%#.0f", 1.0);
! point = &pointbuf[1];
# else
point = localeconv () -> decimal_point;
# endif
***************
*** 668,678 ****
|| mantissa > 0.0 || precision > 0)
{
const char *point;
! /* Prefer nl_langinfo() over localeconv(),
! since the latter is not multithread-
! safe. */
! # if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
# else
point = localeconv () -> decimal_point;
# endif
--- 674,690 ----
|| mantissa > 0.0 || precision > 0)
{
const char *point;
! /* Determine the decimal-point character in a
! multithread-safe way. We know nl_langinfo
! is multithread-safe on glibc systems,
! otherwise use sprintf, since localeconv()
! is rarely multithread-safe. */
! # if HAVE_NL_LANGINFO && __GLIBC__
! point = nl_langinfo (RADIXCHAR);
! # elif 1
! char pointbuf[5];
! sprintf (pointbuf, "%#.0f", 1.0);
! point = &pointbuf[1];
# else
point = localeconv () -> decimal_point;
# endif
- use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/17
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/22
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/22
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/25
- Re: use of thread-unsafe localeconv in vasprintf, Ralf Wildenhues, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Eric Blake, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Eric Blake, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/27
- Re: use of thread-unsafe localeconv in vasprintf,
Bruno Haible <=
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/27
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/27