diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-11-20 22:47:52 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-11-20 22:59:13 +0300 |
commit | c190063f9658153988d735a333a7a3c7aeadc001 (patch) | |
tree | 2c6e5b794485d4677c93971d6808e6294e13713a /newlib/libc/stdio/rget.c | |
parent | 09119463a1445be498f8a6ce3834d462361c7dd3 (diff) |
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>
Diffstat (limited to 'newlib/libc/stdio/rget.c')
-rw-r--r-- | newlib/libc/stdio/rget.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/newlib/libc/stdio/rget.c b/newlib/libc/stdio/rget.c index a9a0d2f2f..38e8b5dd1 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); + /* 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--; |