To:
[email protected]
Subject: Patch 6.1a.035
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 6.1a.035
Problem: multi-byte: When using ":sh" in the GUI, typed and displayed
multi-byte characters are not handled correctly.
Solution: Deal with multi-byte characters to and from the shell. (Yasuhiro
Matsumoto) Also handle UTF-8 composing characters.
Files: src/os_unix.c
*** ../vim61a.034/src/os_unix.c Thu Feb 21 19:07:10 2002
--- src/os_unix.c Wed Mar 6 21:24:14 2002
***************
*** 3328,3335 ****
{
#define BUFLEN 100 /* length for buffer, pseudo tty limit is 128 */
char_u buffer[BUFLEN + 1];
char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
! int ta_len = 0; /* valid chars in ta_buf[] */
int len;
int p_more_save;
int old_State;
--- 3328,3338 ----
{
#define BUFLEN 100 /* length for buffer, pseudo tty limit is 128 */
char_u buffer[BUFLEN + 1];
+ #ifdef FEAT_MBYTE
+ int buffer_off = 0; /* valid bytes in buffer[] */
+ #endif
char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
! int ta_len = 0; /* valid bytes in ta_buf[] */
int len;
int p_more_save;
int old_State;
***************
*** 3432,3437 ****
--- 3435,3444 ----
}
else if (ta_buf[i] == '\r')
ta_buf[i] = '\n';
+ #ifdef FEAT_MBYTE
+ if (has_mbyte)
+ i += (*mb_ptr2len_check)(ta_buf + i) - 1;
+ #endif
}
/*
***************
*** 3441,3450 ****
--- 3448,3468 ----
if (pty_master_fd < 0)
{
for (i = ta_len; i < ta_len + len; ++i)
+ {
if (ta_buf[i] == '\n' || ta_buf[i] == '\b')
msg_putchar(ta_buf[i]);
+ #ifdef FEAT_MBYTE
+ else if (has_mbyte)
+ {
+ int l = (*mb_ptr2len_check)(ta_buf + i);
+
+ msg_outtrans_len(ta_buf + i, l);
+ i += l - 1;
+ }
+ #endif
else
msg_outtrans_len(ta_buf + i, 1);
+ }
windgoto(msg_row, msg_col);
out_flush();
}
***************
*** 3478,3489 ****
*/
while (RealWaitForChar(fromshell_fd, 10L, NULL))
{
! len = read(fromshell_fd, (char *)buffer,
! (size_t)BUFLEN);
if (len <= 0) /* end of file or error */
goto finished;
buffer[len] = NUL;
! msg_puts(buffer);
windgoto(msg_row, msg_col);
cursor_on();
out_flush();
--- 3496,3562 ----
*/
while (RealWaitForChar(fromshell_fd, 10L, NULL))
{
! len = read(fromshell_fd, (char *)buffer
! #ifdef FEAT_MBYTE
! + buffer_off, (size_t)(BUFLEN - buffer_off)
! #else
! , (size_t)BUFLEN
! #endif
! );
if (len <= 0) /* end of file or error */
goto finished;
+ #ifdef FEAT_MBYTE
+ len += buffer_off;
buffer[len] = NUL;
! if (has_mbyte)
! {
! int l;
! char_u *p;
!
! /* Check if the last character in buffer[] is
! * incomplete, keep these bytes for the next
! * round. */
! for (p = buffer; p < buffer + len; p += l)
! {
! if (enc_utf8) /* exclude composing chars */
! l = utf_ptr2len_check(p);
! else
! l = (*mb_ptr2len_check)(p);
! if (l == 0)
! l = 1; /* NUL byte? */
! else if (MB_BYTE2LEN(*p) != l)
! break;
! }
! if (p == buffer) /* no complete character */
! {
! /* avoid getting stuck at an illegal byte */
! if (len >= 12)
! ++p;
! else
! {
! buffer_off = len;
! continue;
! }
! }
! c = *p;
! *p = NUL;
! msg_puts(buffer);
! if (p < buffer + len)
! {
! *p = c;
! buffer_off = (buffer + len) - p;
! mch_memmove(buffer, p, buffer_off);
! continue;
! }
! buffer_off = 0;
! }
! else
! #endif
! {
! buffer[len] = NUL;
! msg_puts(buffer);
! }
!
windgoto(msg_row, msg_col);
cursor_on();
out_flush();
*** ../vim61a.034/src/version.c Thu Mar 7 20:12:24 2002
--- src/version.c Thu Mar 7 20:13:29 2002
***************
*** 608,609 ****
--- 608,611 ----
{ /* Add new patch number below this line */
+ /**/
+ 35,
/**/
--
hundred-and-one symptoms of being an internet addict:
182. You may not know what is happening in the world, but you know
every bit of net-gossip there is.
/// Bram Moolenaar --
[email protected] --
http://www.moolenaar.net \\\
/// Creator of Vim --
http://vim.sf.net --
ftp://ftp.vim.org/pub/vim \\\
\\\ Project leader for A-A-P --
http://www.a-a-p.org ///
\\\ Help me helping AIDS orphans in Uganda -
http://iccf-holland.org ///