diff options
author | luislavena <luislavena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-04 01:10:06 +0000 |
---|---|---|
committer | luislavena <luislavena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-04 01:10:06 +0000 |
commit | f9a6a1dd0c687dfc6e63e5d20bc3812416def301 (patch) | |
tree | 2f77668d636ebbc6fd4deeb05dae91d97f71b38c /win32/win32.c | |
parent | 4a1cfe70dc31f9be8a12908d85b51297d61b8eae (diff) | |
download | ruby-f9a6a1dd0c687dfc6e63e5d20bc3812416def301.tar.gz |
Introduce NEED_READCONV and NEED_WRITECONV to replace universal newline decorator
Use CRLF only when required to improve file reading and writing under Windows.
Patch by Hiroshi Shirosaki. [ruby-core:40706] [Feature #5562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/win32/win32.c b/win32/win32.c index 3ab696d59b..67a392e863 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2252,28 +2252,19 @@ init_stdhandle(void) int keep = 0; #define open_null(fd) \ (((nullfd < 0) ? \ - (nullfd = open("NUL", O_RDWR|O_BINARY)) : 0), \ + (nullfd = open("NUL", O_RDWR)) : 0), \ ((nullfd == (fd)) ? (keep = 1) : dup2(nullfd, fd)), \ (fd)) if (fileno(stdin) < 0) { stdin->_file = open_null(0); } - else { - setmode(fileno(stdin), O_BINARY); - } if (fileno(stdout) < 0) { stdout->_file = open_null(1); } - else { - setmode(fileno(stdout), O_BINARY); - } if (fileno(stderr) < 0) { stderr->_file = open_null(2); } - else { - setmode(fileno(stderr), O_BINARY); - } if (nullfd >= 0 && !keep) close(nullfd); setvbuf(stderr, NULL, _IONBF, 0); } @@ -5614,7 +5605,8 @@ rb_w32_write(int fd, const void *buf, size_t size) return -1; } - if (_osfile(fd) & FTEXT) { + if ((_osfile(fd) & FTEXT) && + (!(_osfile(fd) & FPIPE) || fd == fileno(stdout) || fd == fileno(stderr))) { return _write(fd, buf, size); } |