summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 99a20bb0ca..52de2cc63d 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -6822,6 +6822,10 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
}
}
+/* 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 *s, const WCHAR **ptrp, long *lenp)
}
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, size_t size)
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: