summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-27 13:39:52 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-27 13:39:52 +0000
commit1f3a98202ff02eddb7b553851c003854a1d29ee1 (patch)
treefb182a53bc01d8ba7413366dc0459e1dc4c67a0d
parent3417fdd41736a7382680c5d06c49d3a09708c356 (diff)
merge from trunk (r28035)
* win32/win32.c (rb_w32_read): call ReadFile() with len = 0 before reading really on console, because the first ReadFile() call after PeekConsoleInput() always returns broken data. (Windows's bug). [ruby-core:29018] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--win32/win32.c14
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 00ac51c615..3d689b30ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu May 27 22:39:23 2010 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_read): call ReadFile() with len = 0 before
+ reading really on console, because the first ReadFile() call after
+ PeekConsoleInput() always returns broken data. (Windows's bug).
+ [ruby-core:29018]
+
Wed May 26 20:19:22 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* random.c (random_rand): add the result of random to the
diff --git a/win32/win32.c b/win32/win32.c
index bd4aa3ce30..7f46622dd5 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -5028,6 +5028,7 @@ rb_w32_read(int fd, void *buf, size_t size)
size_t len;
size_t ret;
OVERLAPPED ol, *pol = NULL;
+ int start = 0;
if (is_socket(sock))
return rb_w32_recv(fd, buf, size, 0);
@@ -5050,8 +5051,17 @@ rb_w32_read(int fd, void *buf, size_t size)
ret = 0;
retry:
- /* get rid of console writing bug */
- len = (_osfile(fd) & FDEV) ? min(16 * 1024, size) : size;
+ /* get rid of console reading bug */
+ if (is_console(_osfhnd(fd))) {
+ if (start)
+ len = min(16 * 1024, size);
+ else {
+ len = 0;
+ start = 1;
+ }
+ }
+ else
+ len = size;
size -= len;
/* if have cancel_io, use Overlapped I/O */