From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HK_RANDOM_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13649 invoked from network); 28 Nov 2023 23:21:55 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 28 Nov 2023 23:21:55 -0000 Received: (qmail 23681 invoked by uid 550); 28 Nov 2023 23:21:51 -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 23645 invoked from network); 28 Nov 2023 23:21:51 -0000 Message-ID: <767ed1bd87af1ace778169536de1296a8138120b.camel@postmarketos.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postmarketos.org; s=donut; t=1701213698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sTTe+kSXZYDPG3t8dpSOu0o0ENMuGu0ifmwWNVyQVVQ=; b=UDjBOt70hPAlBSMHhNGf3pGS5oeG4NZOUCtO8jx6sv4XKN5MfyfJiJZjjGALzSLMe53eYz 7YEyZGr2yJruo17ZRTnpAulkbHu2g+ZRYb/mwlFMBY16JzVn/T/qGPbqSh4O8Zbb6CoPrs QSSg4FaxqGcH1km0RDB0dGtKXg9DyQ0= From: Pablo Correa Gomez To: Alastair Houghton , musl@lists.openwall.com, Rich Felker Date: Wed, 29 Nov 2023 00:21:37 +0100 In-Reply-To: <25283A51-7FB1-4CB1-9C26-DF06F69922BC@apple.com> References: <1390B046-C845-406F-8AED-620F2DD16BC0@apple.com> <20230810155115.GT4163@brightrain.aerifal.cx> <267261EB-1DFA-4072-89F0-B62F5DDE5F09@apple.com> <3DD8D02A-0802-494E-B9E8-F00B457B86F6@apple.com> <25283A51-7FB1-4CB1-9C26-DF06F69922BC@apple.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [musl] setlocale() again On mar, 2023-11-28 at 17:32 +0000, Alastair Houghton wrote: > > On 18 Sep 2023, at 15:18, Alastair Houghton > > wrote: > >=20 > > Hi all (Rich especially though :-)) > >=20 > > Has anyone had time to take a look at this? I=E2=80=99d like to make so= me > > progress on this front if possible. > >=20 > > Kind regards, > >=20 > > Alastair. >=20 >=20 > Maybe I=E2=80=99ve missed a reply somewhere along the lines; here=E2=80= =99s a > tentative patch that just does the simple thing of making > setlocale(LC_ALL, "") pick the C.UTF-8 locale if it=E2=80=99s unable to f= ind > the locale specified in the environment. Hi Alastair, >From the logic of the change, and from the postmarketOS perspective, would be fine be me if Rich does not commit this right before a release, as otherwise we would not have much time to inform and help less technical users get their localization back. Now is probably a great time, since the new alpine release is around the corner. However, this also increases the importance of musl-locales for localization to work at all. Before, its existence as a completely independent project was totally fine, users would not need it to get a localized system. However, after this change, that's no longer the case. So I wonder if Rich or the musl community in general would like to host/take care for it? Maybe even deciding on a standar locale path that does not need to be set through an environment variable, though keeping that as a fallback? I'd love to see that come together with this change. Best, Pablo. >=20 > This will mean that setlocale(LC_ALL, "non-existent locale") will > return NULL, which does have an impact on users if they don=E2=80=99t hav= e a > locale installed for Musl but *do* have locale data installed for > some other software; in that case, their other software won=E2=80=99t be > localized until they also install data for Musl. >=20 > (This is the same as current Glibc behaviour.) >=20 > Kind regards, >=20 > Alastair >=20 > ---- snip ---- >=20 > diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c > index da61f7fc..bd11f2ca 100644 > --- a/src/locale/locale_map.c > +++ b/src/locale/locale_map.c > @@ -31,7 +31,7 @@ static const char envvars[][12] =3D { > =C2=A0volatile int __locale_lock[1]; > =C2=A0volatile int *const __locale_lockptr =3D __locale_lock; > =C2=A0 > -const struct __locale_map *__get_locale(int cat, const char *val) > +const struct __locale_map *__get_locale(int cat, const char *locale) > =C2=A0{ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 static void *volatile loc_head= ; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct __locale_map *p; > @@ -39,6 +39,7 @@ const struct __locale_map *__get_locale(int cat, > const char *val) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *path =3D 0, *z; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char buf[256]; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size_t l, n; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *val =3D locale; > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!*val) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (val =3D getenv("LC_ALL")) && *val || > @@ -92,18 +93,9 @@ const struct __locale_map *__get_locale(int cat, > const char *val) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 } > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > =C2=A0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* If no locale definition was foun= d, make a locale map > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * object anyway to store the = name, which is kept for the > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * sake of being able to do me= ssage translations at the > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * application level. */ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!new && (new =3D malloc(sizeof = *new))) { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 new->map =3D __c_dot_utf8.map; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 new->map_size =3D __c_dot_utf8.map_size; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 memcpy(new->name, val, n); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 new->name[n] =3D 0; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 new->next =3D loc_head; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 loc_head =3D new; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* If no locale definition was foun= d, and we specified a > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * locale name of "", return t= he C.UTF-8 locale. */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!new && !*locale) new =3D (void= *)&__c_dot_utf8; > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* For LC_CTYPE, never return = a null pointer unless the > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * requested name was "C"= or "POSIX". */ >=20