Skip to content

Commit 5903aaf

Browse files
k-takatabrammool
authored andcommitted
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)
1 parent a9480db commit 5903aaf

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/channel.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,6 +3589,24 @@ channel_free_all(void)
35893589
// Buffer size for reading incoming messages.
35903590
#define MAXMSGSIZE 4096
35913591

3592+
/*
3593+
* Check if there are remaining data that should be written for "in_part".
3594+
*/
3595+
static int
3596+
is_channel_write_remaining(chanpart_T *in_part)
3597+
{
3598+
buf_T *buf = in_part->ch_bufref.br_buf;
3599+
3600+
if (in_part->ch_writeque.wq_next != NULL)
3601+
return TRUE;
3602+
if (buf == NULL)
3603+
return FALSE;
3604+
return in_part->ch_buf_append
3605+
? (in_part->ch_buf_bot < buf->b_ml.ml_line_count)
3606+
: (in_part->ch_buf_top <= in_part->ch_buf_bot
3607+
&& in_part->ch_buf_top <= buf->b_ml.ml_line_count);
3608+
}
3609+
35923610
#if defined(HAVE_SELECT)
35933611
/*
35943612
* 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)
36043622
chanpart_T *in_part = &ch->ch_part[PART_IN];
36053623

36063624
if (in_part->ch_fd != INVALID_FD
3607-
&& (in_part->ch_bufref.br_buf != NULL
3608-
|| in_part->ch_writeque.wq_next != NULL))
3625+
&& is_channel_write_remaining(in_part))
36093626
{
36103627
FD_SET((int)in_part->ch_fd, wfds);
36113628
if ((int)in_part->ch_fd >= maxfd)
@@ -3629,8 +3646,7 @@ channel_fill_poll_write(int nfd_in, struct pollfd *fds)
36293646
chanpart_T *in_part = &ch->ch_part[PART_IN];
36303647

36313648
if (in_part->ch_fd != INVALID_FD
3632-
&& (in_part->ch_bufref.br_buf != NULL
3633-
|| in_part->ch_writeque.wq_next != NULL))
3649+
&& is_channel_write_remaining(in_part))
36343650
{
36353651
in_part->ch_poll_idx = nfd;
36363652
fds[nfd].fd = in_part->ch_fd;
@@ -3865,8 +3881,6 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
38653881
// Store the read message in the queue.
38663882
channel_save(channel, part, buf, len, FALSE, "RECV ");
38673883
readlen += len;
3868-
if (len < MAXMSGSIZE)
3869-
break; // did read everything that's available
38703884
}
38713885

38723886
// Reading a disconnection (readlen == 0), or an error.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
394,
706708
/**/
707709
393,
708710
/**/

0 commit comments

Comments
 (0)