when doing tab completion partial inserts in UTFMODE, honour multibyte character boundaries (LP: #909025)

This commit is contained in:
tg 2011-12-29 23:36:10 +00:00
parent 4af399bd8d
commit bb51eee63c
1 changed files with 5 additions and 1 deletions

6
edit.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.225 2011/12/11 18:07:45 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.226 2011/12/29 23:36:10 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -624,6 +624,10 @@ x_longest_prefix(int nwords, char * const * words)
prefix_len = j;
break;
}
/* false for nwords==1 as 0 = words[0][prefix_len] then */
if (UTFMODE && prefix_len && (words[0][prefix_len] & 0xC0) == 0x80)
while (prefix_len && (words[0][prefix_len] & 0xC0) != 0xC0)
--prefix_len;
return (prefix_len);
}