mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 17:43:59 +02:00
merges r29980,r30017,r30018,r30019 and r30020 from trunk into ruby_1_9_2.
-- * win32/win32.c (rb_w32_read): read only 1 byte at once on console. workaround of Windows bug. see [ruby-core:33460]. this is not the final solution. -- * win32/win32.c (rb_w32_read): workaround for console reading troubles. fixed [ruby-core:33511] -- * win32/win32.c (rb_w32_read): rollback debug code of previous commit. -- * win32/win32.c (rb_w43_read): more fix. [ruby-core:33513] -- * ChangeLog: typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c9d697ab78
commit
a46abacacd
3 changed files with 27 additions and 6 deletions
|
@ -5056,6 +5056,7 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||
size_t len;
|
||||
size_t ret;
|
||||
OVERLAPPED ol, *pol = NULL;
|
||||
BOOL isconsole;
|
||||
int start = 0;
|
||||
|
||||
if (is_socket(sock))
|
||||
|
@ -5073,16 +5074,18 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||
MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));
|
||||
|
||||
if (!size || _osfile(fd) & FEOFLAG) {
|
||||
_set_osflags(fd, _osfile(fd) & ~FEOFLAG);
|
||||
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
isconsole = is_console(_osfhnd(fd));
|
||||
retry:
|
||||
/* get rid of console reading bug */
|
||||
if (is_console(_osfhnd(fd))) {
|
||||
if (isconsole) {
|
||||
if (start)
|
||||
len = min(16 * 1024, size);
|
||||
len = 1;
|
||||
else {
|
||||
len = 0;
|
||||
start = 1;
|
||||
|
@ -5178,11 +5181,14 @@ rb_w32_read(int fd, void *buf, size_t size)
|
|||
}
|
||||
|
||||
ret += read;
|
||||
if (read == len) {
|
||||
buf = (char *)buf + len;
|
||||
if (size > 0)
|
||||
if (read >= len) {
|
||||
buf = (char *)buf + read;
|
||||
if (!(isconsole && len == 1 && *((char *)buf - 1) == '\n') && size > 0)
|
||||
goto retry;
|
||||
}
|
||||
if (read == 0)
|
||||
_set_osflags(fd, _osfile(fd) | FEOFLAG);
|
||||
|
||||
|
||||
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue