diff options
author | b-r-o-c-k <brockmammen@gmail.com> | 2018-04-14 14:21:36 -0500 |
---|---|---|
committer | b-r-o-c-k <brockmammen@gmail.com> | 2018-04-14 14:21:36 -0500 |
commit | 387fbcd95cade4b0c037d18f404944676a59db09 (patch) | |
tree | f27c6fecbd40b2edd400ae612c77a30883c30512 /src/nvim/os/fileio.c | |
parent | ad999eaa775d7d4b0cacedb30c6ea3a0ee699a6f (diff) | |
download | rneovim-387fbcd95cade4b0c037d18f404944676a59db09.tar.gz rneovim-387fbcd95cade4b0c037d18f404944676a59db09.tar.bz2 rneovim-387fbcd95cade4b0c037d18f404944676a59db09.zip |
win: Fix reading from stdin
* Reading from stdin on Windows is fixed in the same way as it was in
#8267.
* The file_read function was returning without filling the
destination buffer when it was called with a non-blocking file
descriptor.
Diffstat (limited to 'src/nvim/os/fileio.c')
-rw-r--r-- | src/nvim/os/fileio.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 0ef9307a5a..ccf35fd57c 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -282,6 +282,7 @@ ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, char *buf = ret_buf; size_t read_remaining = size; RBuffer *const rv = fp->rv; + bool called_read = false; while (read_remaining) { const size_t rv_size = rbuffer_size(rv); if (rv_size > 0) { @@ -289,7 +290,9 @@ ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, buf += rsize; read_remaining -= rsize; } - if (fp->eof) { + if (fp->eof + // Allow only at most one os_read[v] call. + || (called_read && fp->non_blocking)) { break; } if (read_remaining) { @@ -343,10 +346,7 @@ ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, } } #endif - } - if (fp->non_blocking) { - // Allow only at most one os_read[v] call. - break; + called_read = true; } } return (ptrdiff_t)(size - read_remaining); |