mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 15:01:21 +02:00
22729: trunction in computil.c did't handle multibyte characters
This commit is contained in:
parent
b477e24aa2
commit
4f11c3b8e3
@ -1,5 +1,8 @@
|
||||
2006-09-17 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 22729: Src/Zle/computil.c: truncation of description didn't
|
||||
handle multibyte characters.
|
||||
|
||||
* 22727: Src/init.c, Src/Zle/zle_main.c: "use 'exit' to exit"
|
||||
was suboptimal.
|
||||
|
||||
|
@ -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…
Reference in New Issue
Block a user