From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 1B6A83858C31; Mon, 20 Nov 2023 20:02:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B6A83858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700510531; bh=+2JKcsLeLxUb4JG2qWzjR3Yp8NIRi6knWKfuXpmNxy8=; h=From:To:Subject:Date:From; b=ZxE32zgkM7/eHjc/b3zMBPMbDKmbV1v8E6J8KpMBA6QL9+EwVAwlK5xQB/2JMXVwZ kwouRSoQZqKDxPCDn0xX9qDyDYqybHF6q6LGr1q0H+mbjsNuFuB7RZlLeGMAC2Mqg+ xaBIt6Jq2B7sgRPloZvhHWUTCosoIGcRGGQ2lPXs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] stdio: set and test stream orientation in low-level input function __srget_r X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 09119463a1445be498f8a6ce3834d462361c7dd3 X-Git-Newrev: c190063f9658153988d735a333a7a3c7aeadc001 Message-Id: <20231120200211.1B6A83858C31@sourceware.org> Date: Mon, 20 Nov 2023 20:02:11 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc190063f965= 8153988d735a333a7a3c7aeadc001 commit c190063f9658153988d735a333a7a3c7aeadc001 Author: Corinna Vinschen AuthorDate: Mon Nov 20 20:47:52 2023 +0100 Commit: Corinna Vinschen CommitDate: Mon Nov 20 20:59:13 2023 +0100 stdio: set and test stream orientation in low-level input function __sr= get_r =20 This allows to set and test orientation correctly if input is only using macros from stdio.h. Wide-char-oriented functions must call __srefill_r directly. =20 Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/stdio/rget.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/newlib/libc/stdio/rget.c b/newlib/libc/stdio/rget.c index a9a0d2f2f246..38e8b5dd1959 100644 --- a/newlib/libc/stdio/rget.c +++ b/newlib/libc/stdio/rget.c @@ -39,6 +39,11 @@ __srget_r (struct _reent *ptr, we call __srefill_r so we may access the true read buffer. */ CHECK_INIT(ptr, fp); =20 + /* Have to set and check orientation here, otherwise the macros in + stdio.h never set it. */ + if (ORIENT (fp, -1) !=3D -1) + return EOF; + if (__srefill_r (ptr, fp) =3D=3D 0) { fp->_r--;