public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tristan Partin <[email protected]>
To: Peter Eisentraut <[email protected]>
To: Thomas Munro <[email protected]>
Cc: [email protected]
Subject: Re: Make uselocale protection more consistent
Date: Mon, 03 Jul 2023 09:49:21 -0500
Message-ID: <CTSMCH8UIGRM.Y7K2SSPBYWC4@gonk> (raw)
In-Reply-To: <[email protected]>
References: <CTNITWIN1G6L.CFIPH8SYNQQW@gonk>
<[email protected]>
<CA+hUKGKkfh3wSC-J2eXd4kb499MCJZCCyiL61-mk641uzTBBAA@mail.gmail.com>
<CTSKHGN8BPUK.14RF8P15GN4ZM@gonk>
<[email protected]>
On Mon Jul 3, 2023 at 9:21 AM CDT, Peter Eisentraut wrote:
> On 03.07.23 15:21, Tristan Partin wrote:
> >>> I think it would be better to keep HAVE_LOCALE_T as encompassing any of
> >>> the various locale_t-using functions, rather than using HAVE_USELOCALE
> >>> as a proxy for them. Otherwise you create weird situations like having
> >>> #ifdef HAVE_WCSTOMBS_L inside #ifdef HAVE_USELOCALE, which doesn't make
> >>> sense, I think.
> >> I propose[1] that we get rid of HAVE_LOCALE_T completely and make
> >> "libc" provider support unconditional. It's standardised, and every
> >> target system has it, even Windows. But Windows doesn't have
> >> uselocale().
> >>
> >> [1]https://www.postgresql.org/message-id/flat/CA%2BhUKGL7CmmzeRhoirzjECmOdABVFTn8fo6gEOaFRF1Oxey6Hw%40m...
> > I think keeping HAVE_USELOCALE is important for the Windows case as
> > mentioned. I need it for my localization work where I am ripping out
> > setlocale() on non-Windows.
>
> The current code is structured
>
> #ifdef HAVE_LOCALE_T
> #ifdef HAVE_WCSTOMBS_L
> wcstombs_l(...);
> #else
> uselocale(...);
> #endif
> #else
> elog(ERROR);
> #endif
>
> If you just replace HAVE_LOCALE_T with HAVE_USELOCALE, then this would
> penalize a platform that has wcstombs_l(), but not uselocale(). I think
> the correct structure would be
>
> #if defined(HAVE_WCSTOMBS_L)
> wcstombs_l(...);
> #elif defined(HAVE_USELOCALE)
> uselocale(...);
> #else
> elog(ERROR);
> #endif
That makes sense to me. I gave it some more thought. Maybe it makes more
sense to just completely drop HAVE_USELOCALE as mentioned, and protect
calls to it with #ifdef WIN32 or whatever the macro is. HAVE_USELOCALE
might be more descriptive, but I don't really care that much either way.
--
Tristan Partin
Neon (https://neon.tech)
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Make uselocale protection more consistent
In-Reply-To: <CTSMCH8UIGRM.Y7K2SSPBYWC4@gonk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox