On Mon, 19 Aug 2024 at 10:34, Geoff Clare via austin-group-l at The
Open Group <austin-group-l@opengroup.org> wrote:
>
> Jonathan Wakely wrote, on 19 Aug 2024:
> >
> > On Fri, 16 Aug 2024 at 10:37, Corinna Vinschen via austin-group-l at
> > The Open Group <austin-group-l@opengroup.org> wrote:
> > >
> > > On Aug 16 16:53, Thomas Munro via austin-group-l at The Open Group wrote:
> > > > Hello,
> > > >
> > > > I am aware of two thread-safe localeconv() alternatives in the wild:
> > > >
> > > > 1.  glibc has nl_langinfo_l(DECIMAL_POINT, loc) for
> > > > localeconv()->decimal_point, and so on for every member of struct
> > > > lconv.
> > >
> > > nl_langinfo_l is also implemented in newlib and thus Cygwin since 2016.
> >
> > nl_langinfo_l is in POSIX, but glibc adds constants like DECIMAL_POINT
> > for all the lconv members. Those aren't required by POSIX, and don't
> > seem to be present in newlib.
>
> In glibc, DECIMAL_POINT is just a non-standard synonym for RADIXCHAR
> which is the langinfo.h constant POSIX requires for obtaining the decimal
> point character.  It has a similar non-standard synonym for THOUSEP:

Yes, and CURRENCY_SYMBOL is an alias for CRNCYSTR. But Glibc also
provides several nl_item constants which are not synonyms of standard
ones, e.g. POSITIVE_SIGN, INT_FRAC_DIGITS, INT_P_SIGN_POSN etc.

As Thomas said, this allows you to access every member of struct lconv
using nl_langinfo. The "redundant" synonyms like DECIMAL_POINT are
there for consistency, so you don't have to remember that
lconv::decimal_point must be accessed using RADIXCHAR instead of
DECIMAL_POINT.

>
> enum {
> [...]
>   __DECIMAL_POINT = _NL_ITEM (__LC_NUMERIC, 0),
> #ifdef __USE_GNU
> # define DECIMAL_POINT          __DECIMAL_POINT
> #endif
>   RADIXCHAR = __DECIMAL_POINT,
> #define RADIXCHAR               RADIXCHAR
>   __THOUSANDS_SEP,
> #ifdef __USE_GNU
> # define THOUSANDS_SEP          __THOUSANDS_SEP
> #endif
>   THOUSEP = __THOUSANDS_SEP,
> #define THOUSEP                 THOUSEP
> [...]
> };
>
> --
> Geoff Clare <g.cl...@opengroup.org>
> The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
>

  • Thread-safe equivale... Thomas Munro via austin-group-l at The Open Group
    • Re: Thread-safe... Corinna Vinschen via austin-group-l at The Open Group
      • Re: Thread-... Jonathan Wakely via austin-group-l at The Open Group
        • Re: Thr... Geoff Clare via austin-group-l at The Open Group
          • Re:... Jonathan Wakely via austin-group-l at The Open Group
            • ... Geoff Clare via austin-group-l at The Open Group
              • ... Jonathan Wakely via austin-group-l at The Open Group

Reply via email to