summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--Src/Zle/complist.c2
-rw-r--r--Src/prompt.c41
-rw-r--r--Src/zsh.h2
4 files changed, 53 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3806ac2cc..17c439a18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
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