summaryrefslogtreecommitdiff
path: root/Src/Zle/complist.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2006-01-11 20:12:09 +0000
committerWayne Davison <wayned@users.sourceforge.net>2006-01-11 20:12:09 +0000
commit4b831f02df13e71460b2327607ae3bc4d3ae04d8 (patch)
tree475a022e8513f702543970318a286eb19061c459 /Src/Zle/complist.c
parent4c3edda1f13060d85fd34425bf39b974f0ab59d7 (diff)
downloadzsh-4b831f02df13e71460b2327607ae3bc4d3ae04d8.tar.gz
zsh-4b831f02df13e71460b2327607ae3bc4d3ae04d8.zip
Tweaked the code to handle mbrtowc() converting '\0' the same way as
the other callers do. Also, changed the variable name to 'cnt'.
Diffstat (limited to 'Src/Zle/complist.c')
-rw-r--r--Src/Zle/complist.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 973df8ed4..5afd78115 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -589,31 +589,40 @@ clnicezputs(Listcols colors, char *s, int ml)
initiscol(colors);
while (umleft > 0) {
- size_t ret = mbrtowc(&cc, uptr, umleft, &ps);
+ size_t cnt = mbrtowc(&cc, uptr, umleft, &ps);
- if (ret == 0 || ret == (size_t)-1 || ret == (size_t)-2) {
- /* This handles a '\0' in the input (which is a real char
- * to us, not a terminator) and byte values that aren't
- * valid wide-character sequences. */
+ switch (cnt) {
+ case (size_t)-2:
+ case (size_t)-1:
+ /* This handles byte values that aren't valid wide-character
+ * sequences. */
sptr = nicechar(STOUC(*uptr));
/* everything here is ASCII... */
width = strlen(sptr);
wptr = sptr + width;
- ret = 1;
- /* Get ps out of its undefined state when ret < 0. */
+ cnt = 1;
+ /* Get ps out of its undefined state. */
memset(&ps, 0, sizeof ps);
- } else
+ break;
+ case 0:
+ /* This handles a '\0' in the input (which is a real char
+ * to us, not a terminator). */
+ cnt = 1;
+ /* FALL THROUGH */
+ default:
sptr = wcs_nicechar(cc, &width, &wptr);
+ break;
+ }
- umleft -= ret;
- uptr += ret;
+ umleft -= cnt;
+ uptr += cnt;
if (colors) {
/*
* The code for the colo[u]ri[s/z]ation is obscure (surprised?)
* but if we do it for every input character, as we do in
* the simple case, we shouldn't go too far wrong.
*/
- while (ret--)
+ while (cnt--)
doiscol(colors, i++);
}