summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 04:42:29 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-02 04:42:29 +0000
commit6f3225f69890da5ed192d191d01462e03cfd6735 (patch)
treec725a5310415fe928f3e31baadf538ba91153e1d /win32
parent7eadd51dfe2631b11cbfc1ea20a4bec4f21faa20 (diff)
* win32/win32.c (rb_w32_read): workaround for console reading troubles.
fixed [ruby-core:33511] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 3e1da087b9..8bf9aecfcb 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -5045,6 +5045,7 @@ rb_w32_read(int fd, void *buf, size_t size)
MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));
if (!size || _osfile(fd) & FEOFLAG) {
+ _set_osflags(fd, _osfile(fd) & ~FEOFLAG);
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
return 0;
}
@@ -5055,7 +5056,7 @@ rb_w32_read(int fd, void *buf, size_t size)
/* get rid of console reading bug */
if (isconsole) {
if (start)
- len = 1;
+ len = min(16*1024, size);
else {
len = 0;
start = 1;
@@ -5151,11 +5152,14 @@ rb_w32_read(int fd, void *buf, size_t size)
}
ret += read;
- if (read == len) {
+ if (read >= len) {
buf = (char *)buf + len;
- if (size > 0)
+ if (!(isconsole && len == 1 && *((char *)buf - 1) == '\n') && size > 0)
goto retry;
}
+ if (read == 0)
+ _set_osflags(fd, _osfile(fd) | FEOFLAG);
+
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));