From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) by sourceware.org (Postfix) with ESMTPS id 122343858D20 for ; Wed, 15 Nov 2023 22:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 122343858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=Shaw.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=shaw.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 122343858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=3.97.99.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700088801; cv=none; b=UkpdfwziSUSEYi4/9C9JultlZmhxZcobU2XW2sVesfvVt5XhbB5HhEgVYsT8rFlAHaVLLtsoaq1iFVPmI913sdZ7k4AdNXkDhFWu6lezzcnDdDpsZ83WQbH1kKKjPNe0jlX39/mqvNAcfaEFA67kBvo0+JKdoJ6x45BNkhnIj3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700088801; c=relaxed/simple; bh=fKHVaJVm6oeqt0LVGdTS1aHSV66RGf+XIhrqK8U/3f8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=iBKh6RYjrpsM60y6JQCseLftcRQDzQ4cUQ4W4uHYEug+D4Sf1f2Nn2Hlu/mYvLPpy9TXgfmzWjd/nrFTezulCMdl0H3T04FnPrFDyF14+u82wxhZpeTqFCbThDJu05RTXtOWAIZ2owV6LBJQLojdrzoRytd3aQ18/16A/b4kEIg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from shw-obgw-4002a.ext.cloudfilter.net ([10.228.9.250]) by cmsmtp with ESMTPS id 3Bc6r5okLB0n03Ol5rhxR3; Wed, 15 Nov 2023 22:53:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1700088799; bh=fKHVaJVm6oeqt0LVGdTS1aHSV66RGf+XIhrqK8U/3f8=; h=Date:Reply-To:Subject:To:References:From:In-Reply-To; b=YfA46Gh4UUYjAnIdjgt/d+u05gcRlVysbDCKHcfN/is6KmT6FXsBwLqjf7uv0kVLf FrfH/XplN0L0X+nOrY/MPV1ISiu85rbGZ12lf31Pu2rdelZj6zEunfSO0YDIMbuG73 RghxdYzcNBI2YH0hhkzp/3/2myV+OW5XO2a4z1DeOX0i60fvlbMEPHbs1YwwrByKda PfrnT3ZSqifAc8oeah3jpYxAfOELbIpmf3gYRkEzIdT4PRSQbslgJBv2wGbGznyape iiZCiLeCFIbAyIFBW42t91aIc8zUiGUdjIyAKFo43UbET6TK3+gU0vYSwlDBG3ZAnF KOwIpzzukGh0g== Received: from [10.0.0.5] ([184.64.102.149]) by cmsmtp with ESMTP id 3Ol4rjGhtnCF03Ol4raJqa; Wed, 15 Nov 2023 22:53:19 +0000 X-Authority-Analysis: v=2.4 cv=MPFzJeVl c=1 sm=1 tr=0 ts=65554bdf a=DxHlV3/gbUaP7LOF0QAmaA==:117 a=DxHlV3/gbUaP7LOF0QAmaA==:17 a=IkcTkHD0fZMA:10 a=YoZCbblH0v4RBnYUscwA:9 a=QEXdDO2ut3YA:10 Message-ID: <90208356-726d-4718-9666-3ae94faf5f1b@Shaw.ca> Date: Wed, 15 Nov 2023 15:53:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: newlib@sourceware.org Subject: Re: [PATCH v2] newlib: libc: Fix bugs in the commit 3d94e07c49b5. To: newlib@sourceware.org References: <20231110160947.1518-1-takashi.yano@nifty.ne.jp> Content-Language: en-CA From: Brian Inglis Organization: Inglis In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfJxNtFk0SUczssCkJ01UeUObfYAm1HeKuk/LslJFRBOEEq669HIHTwNCswnh/RqoyQLWAztQ0O2mW+uEIUElOurZ7eW4Q/jYBk1GA24+u9bdPDpci6Mv 4zOpjnovH/CTr5ZstAf1/jBxK4VdBb+PXZ4NsrP7UMjkqosEdtUv9XBCY8GgNnw9VjFft5Mc1u907Q== X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,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: On 2023-11-15 09:31, Corinna Vinschen wrote: > Also, as in GLibC, do not set orientation in ungetc, and only set, but > do not check orientation in ungetwc. Function ungetwc is a wide character input/output function, as ungetc is a byte input/output function, as per N3096 C202X CD2 2023-04 7.23 Input/output 7.23.1 Introduction #6: "6 The input/output functions are given the following collective terms: — The wide character input functions — those functions described in 7.31 that perform input into wide characters and wide strings: fgetwc, fgetws, getwc, getwchar, fwscanf, wscanf, vfwscanf, and vwscanf. — The wide character output functions — those functions described in 7.31 that perform output from wide characters and wide strings: fputwc, fputws, putwc, putwchar, fwprintf, wprintf, vfwprintf, and vwprintf. — The wide character input/output functions — the union of the ungetwc function, the wide character input functions, and the wide character output functions. — The byte input/output functions — those functions described in this subclause that perform input/output: fgetc, fgets, fprintf, fputc, fputs, fread, fscanf, fwrite, getc, getchar, printf, putc, putchar, puts, scanf, ungetc, vfprintf, vfscanf, vprintf, and vscanf." and POSIX 202X Draft 3 concurs in 3.417 and 3.56. All functions of incorrect orientation are invalid once orientation is set, so in ungetwc and ungetc, orientation should be checked, as in any of the input and output functions named, and return W/EOF if the the stream is the opposite orientation, as normal operation is not successful, as per the function definitions, and C202X CD2 7.23.2 Streams #4-5: "4 Each stream has an orientation. After a stream is associated with an external file, but before any operations are performed on it, the stream is unoriented. Once a wide character input/output function has been applied to an unoriented stream, the stream becomes a wide-oriented stream. Similarly, once a byte input/output function has been applied to an unoriented stream, the stream becomes a byte-oriented stream. Only a call to the freopen function or the fwide function can otherwise alter the orientation of a stream. (A successful call to freopen removes any orientation.) 5 Byte input/output functions shall not be applied to a wide-oriented stream and wide character input/output functions shall not be applied to a byte-oriented stream." and POSIX 202X D3 concurs in 2.5.2 Stream Orientation and Encoding Rules. In C202X CD2 Annex J Portability issues J.2 Undefined behavior specifies: "(149) A byte input/output function is applied to a wide-oriented stream, or a wide character input/output function is applied to a byte-oriented stream (7.23.2)." -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry