diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 20:12:09 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 20:12:09 +0000 |
commit | 4b831f02df13e71460b2327607ae3bc4d3ae04d8 (patch) | |
tree | 475a022e8513f702543970318a286eb19061c459 /Src/Zle | |
parent | 4c3edda1f13060d85fd34425bf39b974f0ab59d7 (diff) | |
download | zsh-4b831f02df13e71460b2327607ae3bc4d3ae04d8.tar.gz zsh-4b831f02df13e71460b2327607ae3bc4d3ae04d8.tar.xz 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')
-rw-r--r-- | Src/Zle/complist.c | 31 |
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++); } |