8000 win32.c: limit write size on console · github/ruby@73ae3e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 73ae3e9

Browse files
committed
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 440f442 commit 73ae3e9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

win32/win32.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6822,6 +6822,10 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
68226822
}
68236823
}
68246824

6825+
/* get rid of console writing bug; assume WriteConsole and WriteFile
6826+
* on a console share the same limit. */
6827+
static const long MAXSIZE_CONSOLE_WRITING = 31366;
6828+
68256829
/* License: Ruby's */
68266830
static long
68276831
constat_parse(HANDLE h, struct constat *s, const WCHAR **ptrp, long *lenp)
@@ -6876,7 +6880,7 @@ constat_parse(HANDLE h, struct constat *s, const WCHAR **ptrp, long *lenp)
68766880
}
68776881
rest = 0;
68786882
}
6879-
else {
6883+
else if ((rest = *lenp - len) < MAXSIZE_CONSOLE_WRITING) {
68806884
continue;
68816885
}
68826886
*ptrp = ptr;
@@ -7138,8 +7142,7 @@ rb_w32_write(int fd, const void *buf, size_t size)
71387142

71397143
ret = 0;
71407144
retry:
7141-
/* get rid of console writing bug */
7142-
len = (_osfile(fd) & FDEV) ? min(32 * 1024, size) : size;
7145+
len = (_osfile(fd) & FDEV) ? min(MAXSIZE_CONSOLE_WRITING, size) : size;
71437146
size -= len;
71447147
retry2:
71457148

0 commit comments

Comments
 (0)
0