Re: Thread-safe nl_langinfo() and localeconv()

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Thomas Munro <thomas.munro@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-29T14:08:06Z
Lists: pgsql-hackers
Hi,

On 2025-03-28 09:13:54 +0100, Peter Eisentraut wrote:
> On 27.03.25 11:16, Peter Eisentraut wrote:
> > > Patch 0002 also looks okay, except that the error handling could be
> > > unified with existing code, as I had previously pointed out.  Patch
> > > 0005 fixes that.
> > 
> > I plan to commit this one next, after the above had a bit of time to stew.
> 
> also done

My compiler complains with:

[20/1982 42   1%] Compiling C object src/port/libpgport_shlib.a.p/pg_localeconv_r.c.o
../../../../../home/andres/src/postgresql/src/port/pg_localeconv_r.c:63:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
   63 | const static struct lconv_member_info table[] = {
      | ^~~~~

This is the only such warning in the postgres tree.  I'll go and fix that.

Greetings,

Andres Freund



Commits

  1. Fix "‘static’ is not at beginning of declaration" warning

  2. Use thread-safe strftime_l() instead of strftime().

  3. Provide thread-safe pg_localeconv_r().

  4. Harmonize MinGW CODESET lookup with MSVC.

  5. Include <xlocale.h> for macOS, take II.

  6. Use thread-safe nl_langinfo_l(), not nl_langinfo().

  7. All POSIX systems have langinfo.h and CODESET.