From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 17C821F54E for ; Tue, 6 Sep 2022 14:19:30 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kMRjABbG"; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF164384B12C for ; Tue, 6 Sep 2022 14:19:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF164384B12C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662473969; bh=JOsaVDV2pGI81xSBg1Daf9r9J2wVbL845Ps1ksmRXUs=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=kMRjABbGPAokn5qdJSUkfRPnb2+FTfHCRwdWEAl8cPqku6yc89crXCwROt2V5Sdp6 AOhFcAaawzYnZPY48kgpBANLtgxeXiaGzTUrlVd/7zl1lk7gexRhISuJA1mxzzW7Cf sZ8FoyNPkZHauhDAuROgo3zzvYm+UmVWELX0bRoE= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A9099383DB90 for ; Tue, 6 Sep 2022 14:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A9099383DB90 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-4WltHoZMNLmK8HJc3njUhQ-1; Tue, 06 Sep 2022 10:19:04 -0400 X-MC-Unique: 4WltHoZMNLmK8HJc3njUhQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26E3A3810782; Tue, 6 Sep 2022 14:19:04 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80CB52166B29; Tue, 6 Sep 2022 14:19:03 +0000 (UTC) To: =?utf-8?B?0L3QsNCx?= via Libc-alpha Subject: Re: [PATCH] POSIX locale covers every byte [BZ# 29511] References: <20220830181932.oggrz6f6itrpyi6g@tarta.nabijaczleweli.xyz> Date: Tue, 06 Sep 2022 16:19:01 +0200 In-Reply-To: <20220830181932.oggrz6f6itrpyi6g@tarta.nabijaczleweli.xyz> (=?utf-8?B?ItC90LDQsQ==?= via Libc-alpha"'s message of "Tue, 30 Aug 2022 20:19:32 +0200") Message-ID: <87a67c60x6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: =?utf-8?B?0L3QsNCx?= Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" * =D0=BD=D0=B0=D0=B1 via Libc-alpha: > This is a trivial patch, largely duplicating the extant ASCII code > > There are two user-facing changes: > * nl_langinfo(CODESET) is "POSIX" instead of "ANSI_X3.4-1968" > * mbrtowc() and friends return b if b <=3D 0x7F else +b > > Since Issue 7 TC 2/Issue 8, the C/POSIX locale, effectively: > (a) is 1-byte, stateless, and contains 256 characters > (b) which collate in byte order > (c) the first 128 characters are equivalent to ASCII (like previous) > cf. https://www.austingroupbugs.net/view.php?id=3D663 for a summary of > changes to the standard; > in short, this means that mbrtowc() must never fail and must return > b if b <=3D 0x7F else ab+c for all bytes b > where c is some constant >=3D0x80 > and a is a positive integer constant > > By strategically picking c=3D we land at the tail-end of the > Unicode Low Surrogate Area at DC00-DFFF, described as > > Isolated surrogate code points have no interpretation; > > consequently, no character code charts or names lists > > are provided for this range. > and match musl We don't match Python and its surrogateescape encoding (PEP 838). It maps invalid bytes in the 0x80=E2=80=A60xff range to U+DC80=E2=80=A6U+DCFF.= It may make more sense to align with that. What worries me is that this effectively closes the door for using UTF-8 (or some variant, such as Python's) with the C locale. I used to assume that POSIX allows that, but they now say this was just a mistake. Anyway, regarding mechanics, we'll need a new localedata/charmaps/POSIX charmap, I think. This charmap then can be tested against the gconv converter. You should put the new converters into a separate file (not iconv/gconv_simple.c), then the s390x version will use that automatically. > diff --git a/localedata/locales/POSIX b/localedata/locales/POSIX > index 7ec7f1c577..fc34a6abc1 100644 > --- a/localedata/locales/POSIX > +++ b/localedata/locales/POSIX > @@ -97,6 +97,20 @@ END LC_CTYPE > LC_COLLATE > % This is the POSIX Locale definition for the LC_COLLATE category. Isn't this just the C locale? We don't have a separate file for that. > diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c > index 0f0f55f9ed..f87099bcf5 100644 > --- a/wcsmbs/wcsmbsload.c > +++ b/wcsmbs/wcsmbsload.c > @@ -33,10 +33,10 @@ static const struct __gconv_step to_wc =3D > .__shlib_handle =3D NULL, > .__modname =3D NULL, > .__counter =3D INT_MAX, > - .__from_name =3D (char *) "ANSI_X3.4-1968//TRANSLIT", > + .__from_name =3D (char *) "POSIX", > .__to_name =3D (char *) "INTERNAL", > - .__fct =3D __gconv_transform_ascii_internal, > - .__btowc_fct =3D __gconv_btwoc_ascii, > + .__fct =3D __gconv_transform_posix_internal, > + .__btowc_fct =3D __gconv_btwoc_posix, > .__init_fct =3D NULL, > .__end_fct =3D NULL, > .__min_needed_from =3D 1, > @@ -53,8 +53,8 @@ static const struct __gconv_step to_mb =3D > .__modname =3D NULL, > .__counter =3D INT_MAX, > .__from_name =3D (char *) "INTERNAL", > - .__to_name =3D (char *) "ANSI_X3.4-1968//TRANSLIT", > - .__fct =3D __gconv_transform_internal_ascii, > + .__to_name =3D (char *) "POSIX", > + .__fct =3D __gconv_transform_internal_posix, > .__btowc_fct =3D NULL, > .__init_fct =3D NULL, > .__end_fct =3D NULL, This makes the comment on __wcsmbs_gconv_fcts_c in the same file obsolete. Thanks, Florian