mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: ell1e <kittens@wobble.ninja>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Would it to be possible to get strtoll_l?
Date: Wed, 30 Sep 2020 22:35:29 -0400	[thread overview]
Message-ID: <20201001023528.GM17637@brightrain.aerifal.cx> (raw)
In-Reply-To: <47f2d2dc-0f18-5d86-8206-1196502b60e0@wobble.ninja>

On Thu, Oct 01, 2020 at 02:34:47AM +0200, ell1e wrote:
> Hi everyone,
> 
> I'm working on a project and since the global state setlocale() seems to
> be a bit of a mess to rely on, I'm using the *_l() string functions
> instead. However, musl libc appears to lack strtoll_l() right now, so
> I'm wondering if that'll be added any time soon?

The portable way to do this is just calling uselocale() rather than
passing the locale_t to individual *_l functions. You can even
implement a fallback strtoll_l as:

localt_t old = uselocale(l);
result = strtoll(a,b,c);
uselocale(old);

It's slightly more efficient if you keep the uselocale across multiple
calls, but not that big a deal; uselocale is an extremely light
operation.

But is there a reason you don't just want plain strtoll? C allows that
"additional locale-specific subject sequence forms may be accepted" in
locales other than the C locale, but does not permit standard
sequences to be interpreted differently, and in practice I'm not aware
of implementations that do anything funny here.

Rich

  reply	other threads:[~2020-10-01  2:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  0:34 ell1e
2020-10-01  2:35 ` Rich Felker [this message]
2020-10-01  4:36   ` ell1e
2020-10-01  5:24     ` Ellie
2020-10-01  8:08       ` Ellie
2020-10-01 15:47         ` Rich Felker
2020-10-07 13:44           ` ell1e
2020-10-07 13:52             ` Ellie
2020-10-07 14:58               ` 罗勇刚(Yonggang Luo)
2020-10-07 15:41             ` Ariadne Conill
2020-10-07 19:37             ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001023528.GM17637@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=kittens@wobble.ninja \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).