stdio: set and test stream orientation in low-level input function __srget_r

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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-11-20 20:47:52 +01:00
parent 09119463a1
commit c190063f96
1 changed files with 5 additions and 0 deletions

View File

@ -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);
/* Have to set and check orientation here, otherwise the macros in
stdio.h never set it. */
if (ORIENT (fp, -1) != -1)
return EOF;
if (__srefill_r (ptr, fp) == 0)
{
fp->_r--;