diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-10-13 13:19:29 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-10-13 13:19:29 +0000 |
commit | cc81bba1e34b4a7a357b6a7e6ec1d4eede4ffa61 (patch) | |
tree | 822d9fa5a49b0fda14697073c3687b8641bf7c51 /Src | |
parent | cca66ab341ffa330908aa6ea8da03e991aa6903c (diff) | |
download | zsh-cc81bba1e34b4a7a357b6a7e6ec1d4eede4ffa61.tar.gz zsh-cc81bba1e34b4a7a357b6a7e6ec1d4eede4ffa61.tar.xz zsh-cc81bba1e34b4a7a357b6a7e6ec1d4eede4ffa61.zip |
21870: bad INULL() definition
21869: multibyte characters in %-substitutions, invalid multibyte characters in completion listings
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/complist.c | 2 | ||||
-rw-r--r-- | Src/prompt.c | 41 | ||||
-rw-r--r-- | Src/zsh.h | 2 |
3 files changed, 43 insertions, 2 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index b13932e24..e0ee806bb 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -599,7 +599,7 @@ clnicezputs(Listcols colors, char *s, int ml) * an input NULL, which we want to be a real character * rather than terminator. */ - sptr = nicechar(*s); + sptr = nicechar(*uptr); /* everything here is ASCII... */ width = strlen(sptr); wptr = sptr + width; diff --git a/Src/prompt.c b/Src/prompt.c index 8bd1ad9de..69b76aa24 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -736,6 +736,46 @@ addbufspc(int need) void stradd(char *d) { +#ifdef ZLE_UNICODE_SUPPORT + char *ums, *ups; + int upslen; + mbstate_t ps; + + memset(&ps, 0, sizeof(ps)); + ums = ztrdup(d); + ups = unmetafy(ums, &upslen); + + /* + * We now have a raw string of possibly multibyte characters. + * Read each character one by one. + */ + while (upslen > 0) { + wchar_t cc; + char *pc; + int ret = mbrtowc(&cc, ups, upslen, &ps); + + if (ret <= 0) + { + /* Bad character. Take the next byte on its own. */ + pc = nicechar(*ups); + ret = 1; + } else { + /* Take full wide character in one go */ + pc = wcs_nicechar(cc, NULL, NULL); + } + /* Keep output as metafied string. */ + addbufspc(strlen(pc)); + + upslen -= ret; + ups += ret; + + /* Put printed representation into the buffer */ + while (*pc) + *bp++ = *pc++; + } + + free(ums); +#else char *ps, *pc; addbufspc(niceztrlen(d)); /* This loop puts the nice representation of the string into the prompt * @@ -743,6 +783,7 @@ stradd(char *d) for(ps=d; *ps; ps++) for(pc=nicechar(*ps == Meta ? STOUC(*++ps)^32 : STOUC(*ps)); *pc; pc++) *bp++ = *pc; +#endif } /* tsetcap(), among other things, can write a termcap string into the buffer. */ diff --git a/Src/zsh.h b/Src/zsh.h index 19cfe216d..3db3aa3d4 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -163,7 +163,7 @@ struct mathfunc { */ #define Nularg ((char) 0x9c) -#define INULL(x) (((x) & 0xf8) == 0x98) +#define INULL(x) ((x) >= Snull && (x) <= Nularg) /* * Take care to update the use of IMETA appropriately when adding |