summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-17 20:15:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-10-11 11:34:01 -0700
commitce564926c8abd1767ca661f4c3592516064183b4 (patch)
treef7cd0125f41b19e836b64c039542c78459771d27
parent5d5357c423129e0bb5a1ed4783451ee219258182 (diff)
downloadcygnal-ce564926c8abd1767ca661f4c3592516064183b4.tar.gz
cygnal-ce564926c8abd1767ca661f4c3592516064183b4.tar.bz2
cygnal-ce564926c8abd1767ca661f4c3592516064183b4.zip
Arrange for text mode on stdin, stdout and stderr.
* newlib/libc/stdio/findfp.c (__sinit): Add the Cygwin-specific __SCLE (stream convert line endings) flag when calling the std function to initializing the reent structure's _stdin, _stdout and _stderr members.
-rw-r--r--newlib/libc/stdio/findfp.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 896be99e9..abe53fa07 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -294,6 +294,26 @@ __sinit (struct _reent *s)
stderr_init (s->_stderr);
#endif /* _REENT_GLOBAL_STDIO_STREAMS */
+ /* Cygnal: __SCLE is added to all descriptors to make
+ enable line-ending conversion. */
+ std (s->_stdin, __SRD | __SCLE, 0);
+
+ /* On platforms that have true file system I/O, we can verify
+ whether stdout is an interactive terminal or not, as part of
+ __smakebuf on first use of the stream. For all other platforms,
+ we will default to line buffered mode here. Technically, POSIX
+ requires both stdin and stdout to be line-buffered, but tradition
+ leaves stdin alone on systems without fcntl. */
+#ifdef HAVE_FCNTL
+ std (s->_stdout, __SWR | __SCLE, 1);
+#else
+ std (s->_stdout, __SWR | __SLBF | __SCLE, 1);
+#endif
+
+ /* POSIX requires stderr to be opened for reading and writing, even
+ when the underlying fd 2 is write-only. */
+ std (s->_stderr, __SRW | __SNBF | __SCLE, 2);
+
s->__sdidinit = 1;
__sinit_lock_release ();