aboutsummaryrefslogtreecommitdiffstats
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
parent7eadd51dfe2631b11cbfc1ea20a4bec4f21faa20 (diff)
downloadruby-6f3225f69890da5ed192d191d01462e03cfd6735.tar.gz
* 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
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c10
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a5d10ef60..742f758562 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 2 13:41:43 2010 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_read): workaround for console reading troubles.
+ fixed [ruby-core:33511]
+
Thu Dec 2 13:10:42 2010 NARUSE, Yui <naruse@ruby-lang.org>
* lib/uri/common.rb (URI.encode_www_form):
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));