From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dmta1014.nifty.com (mta-snd01011.nifty.com [106.153.227.43]) by sourceware.org (Postfix) with ESMTPS id BD1C93858D1E for ; Fri, 10 Nov 2023 16:33:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD1C93858D1E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD1C93858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=106.153.227.43 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699634031; cv=none; b=XV66jF8Ap5bH1EF3UHnBmy/5Qp9ErXQLFe5g3gAVrTWp2zEGn9dHxxdnSJeEnG5/wunZlfUxmwNiJM2mSfXzgKrQNgZQ0nhMI4vnvu2QWmK+Z/MEcx83pIZFsSncUIYhZ1L4Vyn9HVqKP1UZUHfc1M3i9h8MV/8CW1wMjEHt6Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699634031; c=relaxed/simple; bh=bzT+R1uq3lxqHWJv7tuoXTbinFo7hGQCxHhHHy2N+Bo=; h=Date:From:To:Subject:Message-Id:Mime-Version; b=U/LT6GEGzPlW7tjl3Byln2NCdnUfEfSWDz1ECCgwrvIfONwpLLl3snoaDC9w2PfqdiPxHOJAmbL1IcUt02dynl4KYrnuYcQssO9JxtA5T4B+qLBHQMK7W1uyYaXBo4RrGKcxDLbycRfNsv/8q8pcuL7Ws+1eqluT6pb/LTom0qE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from HP-Z230 by dmta1014.nifty.com with ESMTP id <20231110163347580.RIJK.14061.HP-Z230@nifty.com> for ; Sat, 11 Nov 2023 01:33:47 +0900 Date: Sat, 11 Nov 2023 01:33:48 +0900 From: Takashi Yano To: newlib@sourceware.org Subject: Re: [PATCH] newlib: libc: Fix bugs in the commit 3d94e07c49b5. Message-Id: <20231111013348.254fd41ffa12e375bfe70f52@nifty.ne.jp> In-Reply-To: References: <20231110113436.2022-1-takashi.yano@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,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 Fri, 10 Nov 2023 17:08:40 +0100 Corinna Vinschen wrote: > On Nov 10 16:17, Corinna Vinschen wrote: > > Didn't you forget ungetwc? > > > > But then again, I checked GLibC, and there's something weird: > > > > ungetc does not at all set or test the orientation. > > > > ungetwc sets the orientation to 1, but doesn't check it. > > > > Puzzeling. I wonder about the reasoning behind this. > > Apparently, ungetwc has been added only later. ungetc, OTOH, was > defined in a way which allowed to use it on wide-char oriented streams > as well. > > So the stance in GLibC is, for backward compatibility reasons, ungetc > can't and must not check or set the orientation at all. > > The fact that ungetwc doesn't test the orientation might be a bug in > glibc. We can follow suit (being "bug-compatible" :)), or we can test > the orientation. Given that using the correctly oriented functions is > ultimately the responsibility of the application, both ways to handle > this should be fine. I noticed that getchar/getwchar/gets etc. in newlib do not set orientation. For example, both getwchar() and getchar() success in the following code. #include #include int main() { wchar_t w; char c; w = getwchar(); ungetwc(w, stdin); c = getchar(); printf("%lc,%c\n", w, c); return 0; } Hmmmmm... -- Takashi Yano