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

ruby-changes:51879

From: nobu <ko1@a...>
Date: Sun, 29 Jul 2018 00:29:21 +0900 (JST)
Subject: [ruby-changes:51879] nobu:r64092 (trunk): win32.c: limit write size on console

nobu	2018-07-29 00:29:14 +0900 (Sun, 29 Jul 2018)

  New Revision: 64092

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64092

  Log:
    win32.c: limit write size on console
    
    * win32/win32.c (constat_parse): split long buffer and limit write
      size on a console, as well as rb_w32_write.
      [ruby-dev:50597] [Bug #14942]

  Modified files:
    trunk/win32/win32.c
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 64091)
+++ win32/win32.c	(revision 64092)
@@ -6822,6 +6822,10 @@ constat_apply(HANDLE handle, struct cons https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6822
     }
 }
 
+/* get rid of console writing bug; assume WriteConsole and WriteFile
+ * on a console share the same limit. */
+static const long MAXSIZE_CONSOLE_WRITING = 31366;
+
 /* License: Ruby's */
 static long
 constat_parse(HANDLE h, struct constat *s, const WCHAR **ptrp, long *lenp)
@@ -6876,7 +6880,7 @@ constat_parse(HANDLE h, struct constat * https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6880
 	    }
 	    rest = 0;
 	}
-	else {
+	else if ((rest = *lenp - len) < MAXSIZE_CONSOLE_WRITING) {
 	    continue;
 	}
 	*ptrp = ptr;
@@ -7138,8 +7142,7 @@ rb_w32_write(int fd, const void *buf, si https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7142
 
     ret = 0;
   retry:
-    /* get rid of console writing bug */
-    len = (_osfile(fd) & FDEV) ? min(32 * 1024, size) : size;
+    len = (_osfile(fd) & FDEV) ? min(MAXSIZE_CONSOLE_WRITING, size) : size;
     size -= len;
   retry2:
 

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

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