* [musl] Implementation of built-in locale only allows for 'C.UTF-8' and fails with just 'C'
@ 2020-01-16 13:53 Abdessattar Sassi
2020-01-16 14:28 ` Rich Felker
0 siblings, 1 reply; 2+ messages in thread
From: Abdessattar Sassi @ 2020-01-16 13:53 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
Hi,
I run into a problem compiling a C library into WASM using emscripten,
which in turn uses libmusl.
The library calls 'locale_t __newlocale(int mask, const char *name, locale_t
loc)' with name being "C".
the implementation in musl calls __get_locale() with val being "C":
https://github.com/emscripten-core/emscripten/blob/2bca083cbbd5a4133db61fbd74d04f7feecfa907/system/lib/libc/musl/src/locale/locale_map.c#L44
-- extracted from locale_map.c:
int builtin = (val[0]=='C' && !val[1])
> || !strcmp(val, "C.UTF-8")
> || !strcmp(val, "POSIX");
> if (builtin) {
> if (cat == LC_CTYPE && val[1]=='.')
> return (void *)&__c_dot_utf8;
> return 0;
> }
If I understand that code correctly, it will return 0 (fail) if the name is
just "C" and not "C.UTF-8".
Is this the intended behavior? (note that glibc and others do NOT require
the .UTF-8, a simple 'C' works just fine and many existing code relies on
that).
Thank you.
*Please Cc: me in reply.*
[-- Attachment #2: Type: text/html, Size: 4378 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [musl] Implementation of built-in locale only allows for 'C.UTF-8' and fails with just 'C'
2020-01-16 13:53 [musl] Implementation of built-in locale only allows for 'C.UTF-8' and fails with just 'C' Abdessattar Sassi
@ 2020-01-16 14:28 ` Rich Felker
0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-01-16 14:28 UTC (permalink / raw)
To: Abdessattar Sassi; +Cc: musl
On Thu, Jan 16, 2020 at 05:53:42PM +0400, Abdessattar Sassi wrote:
> Hi,
>
> I run into a problem compiling a C library into WASM using emscripten,
> which in turn uses libmusl.
>
> The library calls 'locale_t __newlocale(int mask, const char *name, locale_t
> loc)' with name being "C".
> the implementation in musl calls __get_locale() with val being "C":
>
> https://github.com/emscripten-core/emscripten/blob/2bca083cbbd5a4133db61fbd74d04f7feecfa907/system/lib/libc/musl/src/locale/locale_map.c#L44
> -- extracted from locale_map.c:
>
> int builtin = (val[0]=='C' && !val[1])
> > || !strcmp(val, "C.UTF-8")
> > || !strcmp(val, "POSIX");
> > if (builtin) {
> > if (cat == LC_CTYPE && val[1]=='.')
> > return (void *)&__c_dot_utf8;
> > return 0;
> > }
>
>
> If I understand that code correctly, it will return 0 (fail) if the name is
> just "C" and not "C.UTF-8".
>
> Is this the intended behavior? (note that glibc and others do NOT require
> the .UTF-8, a simple 'C' works just fine and many existing code relies on
> that).
>
> Thank you.
>
> *Please Cc: me in reply.*
__get_locale is not a public function; its internal contract is that
it returns 0 for the C locale. This is not an error condition. If
newlocale is failing then the problem is somewhere else. Do you have a
test case to reproduce the failure?
Rich
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-16 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 13:53 [musl] Implementation of built-in locale only allows for 'C.UTF-8' and fails with just 'C' Abdessattar Sassi
2020-01-16 14:28 ` Rich Felker
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).