From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14649 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf doesn't respect locale Date: Wed, 11 Sep 2019 14:53:36 +0200 Organization: inria.fr Message-ID: <20190911145336.08554c4e@inria.fr> References: <20190909175452.GO9017@brightrain.aerifal.cx> <20190910163143.GI22009@port70.net> <20190910184312.GJ22009@port70.net> <539924f1-6cdb-0652-e9bf-4c5e6922823d@adelielinux.org> <20190911100159.GK22009@port70.net> <20190911120722.6ed0b3fb@inria.fr> <20190911114437.GS9017@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/Wx12pQE_1g_lsrXFVgXNIw9"; protocol="application/pgp-signature"; micalg=pgp-sha1 Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="235429"; mail-complaints-to="usenet@blaine.gmane.org" Cc: musl@lists.openwall.com Original-X-From: musl-return-14665-gllmg-musl=m.gmane.org@lists.openwall.com Wed Sep 11 14:54:18 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1i828X-000z62-PT for gllmg-musl@m.gmane.org; Wed, 11 Sep 2019 14:54:17 +0200 Original-Received: (qmail 30359 invoked by uid 550); 11 Sep 2019 12:54:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30338 invoked from network); 11 Sep 2019 12:54:14 -0000 X-IronPort-AV: E=Sophos;i="5.64,493,1559512800"; d="scan'208";a="401255330" In-Reply-To: <20190911114437.GS9017@brightrain.aerifal.cx> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ Xref: news.gmane.org gmane.linux.lib.musl.general:14649 Archived-At: --Sig_/Wx12pQE_1g_lsrXFVgXNIw9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello Rich, On Wed, 11 Sep 2019 07:44:37 -0400 Rich Felker wrote: > On Wed, Sep 11, 2019 at 12:07:22PM +0200, Jens Gustedt wrote: > > I think that WG14 would be happy to hear any suggestions how we > > could get out of this trap, a proposal for C2x would even be > > better. =20 >=20 > The obvious solution is a modifier character to printf/scanf format > strings that applies to numeric conversions and means "always > format/interpret this as if in the C locale". However this is hard to > test for at build time unless there's a macro declaring its > availability, so ideally WG14 would also adopt the sort of > fine-grained feature availability macros some of us have been > proposing for extensions. If such a proposal would be made, it would have to be based on a reference implementation in the field. Would musl be willing to be such a reference implementation? In addition, I would think that it should not switch off all locale feature but should leave the encoding properties such as UTF-8 functional. > An alternative/additional solution, which I actually might like > better, is having a function which sets a thread-local flag to treat > certain locale properties (at least the problematic LC_NUMERIC ones) > as if the current locale were "C". This is weaker than the uselocale > API from POSIX, but doesn't have the problems with the possibility of > failure (likely with no way to make forward progress) like it does, > and more importantly, would avoid *breaking* m17n/i18n functionality > by turning off other unrelated, non-problematic locale features. > Application or library code could then just set/restore this flag > around *printf/*scanf/strto*/etc calls, or could set it and leave it > if they never want to see ',' again. Interesting. Would this be difficult to implement in musl? (I guess not) Would you be willing to write this up? Once we'd have that in musl (even before having it in C2x) it could be easier for ourselves to convice us to have full locale support. Thanks Jens --=20 :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS ::: :: ::::::::::::::: office Strasbourg : +33 368854536 :: :: :::::::::::::::::::::: gsm France : +33 651400183 :: :: ::::::::::::::: gsm international : +49 15737185122 :: :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt :: --Sig_/Wx12pQE_1g_lsrXFVgXNIw9 Content-Type: application/pgp-signature Content-Description: Digitale Signatur von OpenPGP -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSN9stI2OFN1pLljN0P0+hp2tU34gUCXXjuUQAKCRAP0+hp2tU3 4kZTAJ4xsdpcHQQXkqMgC+MIncVLhb1uIACfYCTNGm+5saUitDcJfqYSOH3VmF4= =igzA -----END PGP SIGNATURE----- --Sig_/Wx12pQE_1g_lsrXFVgXNIw9--