diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/Zle/computil.c | 18 |
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index 2f0ff9666..defb28bf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index fab854736..5ecc4b6be 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -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; |