1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

21870: bad INULL() definition

21869: multibyte characters in %-substitutions, invalid multibyte
characters in completion listings
This commit is contained in:
Peter Stephenson 2005-10-13 13:19:29 +00:00
parent cca66ab341
commit cc81bba1e3
4 changed files with 53 additions and 2 deletions

View file

@ -1,3 +1,13 @@
2005-10-13 Peter Stephenson <pws@csr.com>
* Src/prompt.c, Src/complist.c: 21869: fix multibyte characters
in %-substitutions and output of invalid multibyte characters
in completion listings.
* 21870: Src/zsh.h: definition of INULL() in 21862/21863 was too
liberal, causing problems with output of certain characters
e.g. Cyrillic UTF-8.
2005-10-11 Peter Stephenson <pws@csr.com>
* 21862/21863: Src/glob.c, Src/lex.c, Src/pattern.c, Src/subst.c,

View file

@ -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;

View file

@ -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. */

View file

@ -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