forked from aniani/vim
patch 9.0.0394: Cygwin: multibyte characters may be broken in terminal window
Problem: Cygwin: multibyte characters may be broken in terminal window. Solution: Adjust how to read and write on the channel. (Ken Takata, closes #11063)
This commit is contained in:
@@ -3589,6 +3589,24 @@ channel_free_all(void)
|
|||||||
// Buffer size for reading incoming messages.
|
// Buffer size for reading incoming messages.
|
||||||
#define MAXMSGSIZE 4096
|
#define MAXMSGSIZE 4096
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if there are remaining data that should be written for "in_part".
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
is_channel_write_remaining(chanpart_T *in_part)
|
||||||
|
{
|
||||||
|
buf_T *buf = in_part->ch_bufref.br_buf;
|
||||||
|
|
||||||
|
if (in_part->ch_writeque.wq_next != NULL)
|
||||||
|
return TRUE;
|
||||||
|
if (buf == NULL)
|
||||||
|
return FALSE;
|
||||||
|
return in_part->ch_buf_append
|
||||||
|
? (in_part->ch_buf_bot < buf->b_ml.ml_line_count)
|
||||||
|
: (in_part->ch_buf_top <= in_part->ch_buf_bot
|
||||||
|
&& in_part->ch_buf_top <= buf->b_ml.ml_line_count);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(HAVE_SELECT)
|
#if defined(HAVE_SELECT)
|
||||||
/*
|
/*
|
||||||
* Add write fds where we are waiting for writing to be possible.
|
* Add write fds where we are waiting for writing to be possible.
|
||||||
@@ -3604,8 +3622,7 @@ channel_fill_wfds(int maxfd_arg, fd_set *wfds)
|
|||||||
chanpart_T *in_part = &ch->ch_part[PART_IN];
|
chanpart_T *in_part = &ch->ch_part[PART_IN];
|
||||||
|
|
||||||
if (in_part->ch_fd != INVALID_FD
|
if (in_part->ch_fd != INVALID_FD
|
||||||
&& (in_part->ch_bufref.br_buf != NULL
|
&& is_channel_write_remaining(in_part))
|
||||||
|| in_part->ch_writeque.wq_next != NULL))
|
|
||||||
{
|
{
|
||||||
FD_SET((int)in_part->ch_fd, wfds);
|
FD_SET((int)in_part->ch_fd, wfds);
|
||||||
if ((int)in_part->ch_fd >= maxfd)
|
if ((int)in_part->ch_fd >= maxfd)
|
||||||
@@ -3629,8 +3646,7 @@ channel_fill_poll_write(int nfd_in, struct pollfd *fds)
|
|||||||
chanpart_T *in_part = &ch->ch_part[PART_IN];
|
chanpart_T *in_part = &ch->ch_part[PART_IN];
|
||||||
|
|
||||||
if (in_part->ch_fd != INVALID_FD
|
if (in_part->ch_fd != INVALID_FD
|
||||||
&& (in_part->ch_bufref.br_buf != NULL
|
&& is_channel_write_remaining(in_part))
|
||||||
|| in_part->ch_writeque.wq_next != NULL))
|
|
||||||
{
|
{
|
||||||
in_part->ch_poll_idx = nfd;
|
in_part->ch_poll_idx = nfd;
|
||||||
fds[nfd].fd = in_part->ch_fd;
|
fds[nfd].fd = in_part->ch_fd;
|
||||||
@@ -3865,8 +3881,6 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
|
|||||||
// Store the read message in the queue.
|
// Store the read message in the queue.
|
||||||
channel_save(channel, part, buf, len, FALSE, "RECV ");
|
channel_save(channel, part, buf, len, FALSE, "RECV ");
|
||||||
readlen += len;
|
readlen += len;
|
||||||
if (len < MAXMSGSIZE)
|
|
||||||
break; // did read everything that's available
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reading a disconnection (readlen == 0), or an error.
|
// Reading a disconnection (readlen == 0), or an error.
|
||||||
|
@@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
394,
|
||||||
/**/
|
/**/
|
||||||
393,
|
393,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user