To: vim_dev@googlegroups.com Subject: Patch 9.0.0394 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0394 Problem: Cygwin: multibyte characters may be broken in terminal window. Solution: Adjust how to read and write on the channel. (Ken Takata, closes #11063) Files: src/channel.c *** ../vim-9.0.0393/src/channel.c 2022-09-01 16:00:49.730496296 +0100 --- src/channel.c 2022-09-06 11:20:55.580107630 +0100 *************** *** 3589,3594 **** --- 3589,3612 ---- // Buffer size for reading incoming messages. #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) /* * Add write fds where we are waiting for writing to be possible. *************** *** 3604,3611 **** chanpart_T *in_part = &ch->ch_part[PART_IN]; if (in_part->ch_fd != INVALID_FD ! && (in_part->ch_bufref.br_buf != NULL ! || in_part->ch_writeque.wq_next != NULL)) { FD_SET((int)in_part->ch_fd, wfds); if ((int)in_part->ch_fd >= maxfd) --- 3622,3628 ---- chanpart_T *in_part = &ch->ch_part[PART_IN]; if (in_part->ch_fd != INVALID_FD ! && is_channel_write_remaining(in_part)) { FD_SET((int)in_part->ch_fd, wfds); if ((int)in_part->ch_fd >= maxfd) *************** *** 3629,3636 **** chanpart_T *in_part = &ch->ch_part[PART_IN]; if (in_part->ch_fd != INVALID_FD ! && (in_part->ch_bufref.br_buf != NULL ! || in_part->ch_writeque.wq_next != NULL)) { in_part->ch_poll_idx = nfd; fds[nfd].fd = in_part->ch_fd; --- 3646,3652 ---- chanpart_T *in_part = &ch->ch_part[PART_IN]; if (in_part->ch_fd != INVALID_FD ! && is_channel_write_remaining(in_part)) { in_part->ch_poll_idx = nfd; fds[nfd].fd = in_part->ch_fd; *************** *** 3865,3872 **** // Store the read message in the queue. channel_save(channel, part, buf, len, FALSE, "RECV "); readlen += len; - if (len < MAXMSGSIZE) - break; // did read everything that's available } // Reading a disconnection (readlen == 0), or an error. --- 3881,3886 ---- *** ../vim-9.0.0393/src/version.c 2022-09-06 10:56:15.605981108 +0100 --- src/version.c 2022-09-06 11:25:54.719269866 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 394, /**/ -- hundred-and-one symptoms of being an internet addict: 13. You refer to going to the bathroom as downloading. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///