From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662473948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JOsaVDV2pGI81xSBg1Daf9r9J2wVbL845Ps1ksmRXUs=; b=fU9mNLB+/UTkWAL+hmdTUZZ7+BSogVOjN6pdnDVRp/zDUq/e3X7U4kBsWWY2wbsZUGJWPa j+MEGe1MhfqCd4JJkzAI1EfBLENoNxX3Vrm2o8vEo+01VGMFHopZyGWHXrxAbsutUoyh5m hFYYql7Eq2JcukW/YxiHO+NeLrGP+X8= 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) From: Florian Weimer To: =?utf-8?B?0L3QsNCx?= via Libc-alpha Cc: =?utf-8?B?0L3QsNCx?= 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-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * =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