From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 54f530bc for ; Thu, 16 Jan 2020 14:28:48 +0000 (UTC) Received: (qmail 7321 invoked by uid 550); 16 Jan 2020 14:28:47 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7303 invoked from network); 16 Jan 2020 14:28:46 -0000 Date: Thu, 16 Jan 2020 09:28:33 -0500 From: Rich Felker To: Abdessattar Sassi Cc: musl@lists.openwall.com Message-ID: <20200116142833.GN30412@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: Rich Felker Subject: Re: [musl] Implementation of built-in locale only allows for 'C.UTF-8' and fails with just 'C' 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