[libcxx-commits] [PATCH] D122532: Do not use non-POSIX strtoll_l and strtoull_l
Yuriy Chernyshov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 28 13:12:43 PDT 2022
georgthegreat added a subscriber: dalias.
georgthegreat added a comment.
> this is only ever called with the "C" locale here, so then it should probably(?) be equivalent to just calling the plain strtoull
Unfortunately, it is not.
As I see in glibc sources, strtoll is implemented (through a extensive chain of weak_aliases and macro definitions) as follows:
INT
INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
int base, int group)
{
return INTERNAL (__strtol_l) (nptr, endptr, base, group, _NL_CURRENT_LOCALE);
}
with NL_CURRENT_LOCALE used for extracting the current locale from tls:
#define _NL_CURRENT_LOCALE (__libc_tsd_get (locale_t, LOCALE))
So this PR indeed changes to behavior to take current locale into account.
My whole research started from an attempt to remove a patch locally applied to our copy of musl.
@mstorsjo point regarding Arabic / Farsi locales (though I unable to test it) is a good point to ask what musl guys.
@dalias could you comment on the reasons for musl to have no `strto*_l` methods for integers?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122532/new/
https://reviews.llvm.org/D122532
More information about the libcxx-commits
mailing list