From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mta-snd-w03.biglobe.ne.jp (mta-snd-w03.biglobe.ne.jp [27.86.113.19]) by sourceware.org (Postfix) with ESMTPS id 5B5703858403 for ; Mon, 25 Mar 2024 07:45:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B5703858403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kba.biglobe.ne.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kba.biglobe.ne.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5B5703858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=27.86.113.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711352750; cv=none; b=TU6INsSSradX49REy8z/Bv17BUFuoRLB423C+VD54d7wMsMCFCiAWifGs5YgvSvNNWHHZ9AQl+HuDkVMOoizB3L7u9kgPm6NYIrboSZtjxEQFr2OpBr1kFQiOJUZgwtcfI4loc/7YL86IHS78WA3a/7/b10xCbeHTLTCSXAL3+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711352750; c=relaxed/simple; bh=zTR5UImW5TzY/BdDjOjTKjVdN4qy9bF2TOYzjzV4gDk=; h=From:Mime-Version:Subject:Message-Id:Date:To; b=GryQT9jDWtonDNIbA/4rCgOj7anhf9nOtOwIY7IL9A9bamFJwBeBOy2PyM46zbv2yiJS7Ve+DEqSM3ZJnoSTglFOU5PjaM3vuHD/k3PYT2UNoDPB3dteqQe3bbqmkm566lBPllBXHWxdF8mzFWbt5cO79UuzS2DxxRvT5gD/Awg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail.biglobe.ne.jp by mta-snd-w03.biglobe.ne.jp with ESMTP id <20240325074544110.VMAJ.60167.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Mon, 25 Mar 2024 16:45:44 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: wctomb() accepts out-of-range character in C-locale Message-Id: Date: Mon, 25 Mar 2024 16:45:33 +0900 To: newlib@sourceware.org X-Mailer: Apple Mail (2.3731.700.6) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,HEXHASH_WORD,KAM_ASCII_DIVIDERS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Dear newlib developers, (this is the first time I post to this list) On recent Cygwin, the following C code output '1' (i.e., wide character 0x80 can be converted into a valid single-byte character in C-locale): --------------------------------------- #include #include #include int main() { char buf[MB_CUR_MAX]; setlocale(LC_ALL, "C"); printf("%d\n", wctomb(buf, 0x80)); return 0; } --------------------------------------- On Linux it outputs '-1'. It seems this is due to the following commit: ------------------------------------------------ commit 8a4318943875cd922601d34e54ce8a83ad2e733c Author: Corinna Vinschen Date: Mon Jul 31 12:44:16 2023 +0200 Revert "* libc/stdlib/mbtowc_r.c (__ascii_mbtowc): Disallow = conversion of" This reverts commit 2b77087a48ea56e77fca5aeab478c922f6473d7c. For some reason lost in time, commit 2b77087a48ea5 introduced Cygwin-specific code treating single byte characters outside the portable character set as illegal chars. However, Cygwin was always alone with this over-correct behaviour and it leads to stuff like gnulib replacing functions defined in Cygwin with their own implementation just due to that. ------------------------------------------------ Probably the function __ascii_wctomb() is used not only in C-locale but also in some other locales, and the commit is for "fixing" some problems in these locales? But a wide character >=3D 0x80 can't be converted into a valid character in C-loccale (7bit), I think.=