mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-29 17:31:02 +01:00
22729: trunction in computil.c did't handle multibyte characters
This commit is contained in:
parent
b477e24aa2
commit
4f11c3b8e3
2 changed files with 19 additions and 2 deletions
|
|
@ -616,8 +616,22 @@ cd_get(char **params)
|
|||
memset(buf, ' ', cd_state.pre);
|
||||
memcpy(buf, str->str, str->len);
|
||||
strcpy(sufp, str->desc);
|
||||
if (strlen(buf) >= columns - 1)
|
||||
buf[columns - 1] = '\0';
|
||||
if (MB_METASTRWIDTH(buf) >= columns - 1) {
|
||||
char *termptr = buf;
|
||||
int w;
|
||||
MB_METACHARINIT();
|
||||
for (w = columns - 1; *termptr && w > 0; ) {
|
||||
convchar_t cchar;
|
||||
int cw;
|
||||
termptr += MB_METACHARLENCONV(termptr, &cchar);
|
||||
cw = WCWIDTH(cchar);
|
||||
if (cw >= 0)
|
||||
w -= cw;
|
||||
else
|
||||
w--;
|
||||
}
|
||||
*termptr = '\0';
|
||||
}
|
||||
*dp++ = ztrdup(buf);
|
||||
}
|
||||
*mp = *dp = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue