Re: Remaining dependency on setlocale() - Mailing list pgsql-hackers

From Joe Conway
Subject Re: Remaining dependency on setlocale()
Date
Msg-id dee77989-b941-49b1-9533-c7f9fa8ab32f@joeconway.com
Whole thread Raw
In response to Re: Remaining dependency on setlocale()  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Remaining dependency on setlocale()
List pgsql-hackers
On 8/7/24 03:07, Thomas Munro wrote:
> How far can we get by using more _l() functions?  For example, [1]
> shows a use of strftime() that I think can be converted to
> strftime_l() so that it doesn't depend on setlocale().  Since POSIX
> doesn't specify every obvious _l function, we might need to provide
> any missing wrappers that save/restore thread-locally with
> uselocale().  Windows doesn't have uselocale(), but it generally
> doesn't need such wrappers because it does have most of the obvious
> _l() functions.

Most of the strtoX functions have an _l variant, but one to watch is 
atoi, which is defined with a hardcoded call to strtol, at least with glibc:

8<----------
/* Convert a string to an int.  */
int
atoi (const char *nptr)
{
   return (int) strtol (nptr, (char **) NULL, 10);
}
8<----------

I guess in many/most places we use atoi we don't care, but maybe it 
matters for some?

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: "Vitaly Davydov"
Date:
Subject: Re: Fsync (flush) all inserted WAL records
Next
From: Daniel Gustafsson
Date:
Subject: Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?