diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-17 20:15:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-11-17 12:13:27 -0800 |
commit | c6004c5bb9fa95209707ede066334b01ef4c61e6 (patch) | |
tree | c5ff1800bc9202389ab092098a5837bdef654799 /newlib | |
parent | 64d32af4244110a157efb7cfc906fc5f1a49b0e8 (diff) | |
download | cygnal-c6004c5bb9fa95209707ede066334b01ef4c61e6.tar.gz cygnal-c6004c5bb9fa95209707ede066334b01ef4c61e6.tar.bz2 cygnal-c6004c5bb9fa95209707ede066334b01ef4c61e6.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.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 737bde102..9d7764009 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -293,6 +293,26 @@ _DEFUN(__sinit, (s), stderr_init (s->_stderr); #endif + /* 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 (); |