[前][次][番号順一覧][スレッド一覧]

ruby-changes:16085

From: usa <ko1@a...>
Date: Thu, 27 May 2010 22:40:10 +0900 (JST)
Subject: [ruby-changes:16085] Ruby:r28036 (ruby_1_9_2): merge from trunk (r28035)

usa	2010-05-27 22:39:52 +0900 (Thu, 27 May 2010)

  New Revision: 28036

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28036

  Log:
    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]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/win32/win32.c

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28035)
+++ ruby_1_9_2/ChangeLog	(revision 28036)
@@ -1,3 +1,10 @@
+Thu May 27 22:39:23 2010  NAKAMURA Usaku  <usa@r...>
+
+	* 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@r...>
 
 	* random.c (random_rand): add the result of random to the
Index: ruby_1_9_2/win32/win32.c
===================================================================
--- ruby_1_9_2/win32/win32.c	(revision 28035)
+++ ruby_1_9_2/win32/win32.c	(revision 28036)
@@ -5028,6 +5028,7 @@
     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 @@
 
     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 */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]