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=-3.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 28220 invoked from network); 28 Nov 2023 17:32:40 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 28 Nov 2023 17:32:40 -0000 Received: (qmail 1404 invoked by uid 550); 28 Nov 2023 17:32:36 -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 1366 invoked from network); 28 Nov 2023 17:32:36 -0000 X-Proofpoint-ORIG-GUID: X3yottPmSjwWTdCThVi38oDROKAGe6uU X-Proofpoint-GUID: X3yottPmSjwWTdCThVi38oDROKAGe6uU X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.619,18.0.997 definitions=2023-11-28_19:2023-11-27,2023-11-28 signatures=0 X-Proofpoint-Spam-Details: rule=interactive_user_notspam policy=interactive_user score=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311280140 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : content-type : content-transfer-encoding : mime-version : subject : date : references : to : in-reply-to : message-id; s=20180706; bh=pD3aS9qZ99nz7wQWJdsKJmTPG2OGOlLOpJrLfhZO+0s=; b=gCRVAtE8fTgEGjCUCcC/FiWbeLyoDF8lPdsqDWZY4aiDoQy5Ghhxa/2vf5hk8/Mf4+eL 8+GjtzokZo5M5uvWu3WKYrB3MAt0fDHffecVCd9OFNpc6tG8kjLQxE4C+nppj4j9qkDJ HVM6r4eSJv5Kulx7oN5gn8TgAuiuP2qQeMW01OI04n+c8DXUJ70Wta3gCKjPIorHvmSM VPMzDKjb64ML/Z4t9GLTthbgJCD3I4QlCF6meEl4GZlmr0BhrghV9/hp0Yxuy3aYERgn 9dbQ8WrGM4ibT21ILN36VgumGP3iY+9GRwvQsmb97UVwt99z2UPV0zVE5nCvHjXEkgvB tg== X-Va-A: X-Va-T-CD: cbd8b3b139ec4d8156d22914d8e9389c X-Va-E-CD: 938c8e4fd76e3e013edeb3d41379f883 X-Va-R-CD: 8a2faf3de2027b4a0bc7941d26d4bbde X-Va-ID: cd17a404-1b42-4aa9-8c89-5a6af8b304bd X-Va-CD: 0 X-V-A: X-V-T-CD: cbd8b3b139ec4d8156d22914d8e9389c X-V-E-CD: 938c8e4fd76e3e013edeb3d41379f883 X-V-R-CD: 8a2faf3de2027b4a0bc7941d26d4bbde X-V-ID: 659924b4-5ae1-4415-b863-a3fd1ae1c6cf X-V-CD: 0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.619,18.0.997 definitions=2023-11-28_19:2023-11-27,2023-11-28 signatures=0 From: Alastair Houghton Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable MIME-version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Date: Tue, 28 Nov 2023 17:32:14 +0000 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> To: musl@lists.openwall.com, Rich Felker In-reply-to: <3DD8D02A-0802-494E-B9E8-F00B457B86F6@apple.com> Message-id: <25283A51-7FB1-4CB1-9C26-DF06F69922BC@apple.com> X-Mailer: Apple Mail (2.3774.300.61.1.2) Subject: Re: [musl] setlocale() again > 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 = some progress on this front if possible. >=20 > Kind regards, >=20 > Alastair. Maybe I=E2=80=99ve missed a reply somewhere along the lines; here=E2=80=99= s 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 = find the locale specified in the environment. 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 have 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. (This is the same as current Glibc behaviour.) Kind regards, Alastair ---- snip ---- 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 { volatile int __locale_lock[1]; volatile int *const __locale_lockptr =3D __locale_lock; =20 -const struct __locale_map *__get_locale(int cat, const char *val) +const struct __locale_map *__get_locale(int cat, const char *locale) { static void *volatile loc_head; const struct __locale_map *p; @@ -39,6 +39,7 @@ const struct __locale_map *__get_locale(int cat, const = char *val) const char *path =3D 0, *z; char buf[256]; size_t l, n; + const char *val =3D locale; =20 if (!*val) { (val =3D getenv("LC_ALL")) && *val || @@ -92,18 +93,9 @@ const struct __locale_map *__get_locale(int cat, = const char *val) } } =20 - /* If no locale definition was found, make a locale map - * object anyway to store the name, which is kept for the - * sake of being able to do message translations at the - * application level. */ - if (!new && (new =3D malloc(sizeof *new))) { - new->map =3D __c_dot_utf8.map; - new->map_size =3D __c_dot_utf8.map_size; - memcpy(new->name, val, n); - new->name[n] =3D 0; - new->next =3D loc_head; - loc_head =3D new; - } + /* If no locale definition was found, and we specified a + * locale name of "", return the C.UTF-8 locale. */ + if (!new && !*locale) new =3D (void *)&__c_dot_utf8; =20 /* For LC_CTYPE, never return a null pointer unless the * requested name was "C" or "POSIX". */