diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 20:09:03 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2006-01-11 20:09:03 +0000 |
commit | 4c3edda1f13060d85fd34425bf39b974f0ab59d7 (patch) | |
tree | d008c6613f2e20032676ad7c27a74dbf2bd86ea7 /Src | |
parent | 23bd860ef74da155745a4644d7d396e320eec913 (diff) | |
download | zsh-4c3edda1f13060d85fd34425bf39b974f0ab59d7.tar.gz zsh-4c3edda1f13060d85fd34425bf39b974f0ab59d7.tar.xz zsh-4c3edda1f13060d85fd34425bf39b974f0ab59d7.zip |
Decided to use a switch() in mb_niceformat().
Diffstat (limited to 'Src')
-rw-r--r-- | Src/utils.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Src/utils.c b/Src/utils.c index 0c808ca25..d90b128e9 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3473,19 +3473,24 @@ mb_niceformat(const char *s, FILE *stream, char **outstrp, int heap) while (umlen > 0) { size_t cnt = mbrtowc(&c, ptr, umlen, &ps); - if (cnt != (size_t)-1 && cnt != (size_t)-2) { - /* Careful: converting '\0' returns 0, but a '\0' is a - * real character for us, so we should consume 1 byte. */ - if (cnt == 0) - cnt = 1; - fmt = wcs_nicechar(c, &newl, NULL); - } else { + switch (cnt) { + case (size_t)-1: + case (size_t)-2: /* The byte didn't convert, so output it as a \M-... sequence. */ fmt = nicechar(STOUC(*ptr)); newl = strlen(fmt); cnt = 1; /* Get ps out of its undefined state. */ memset(&ps, 0, sizeof ps); + break; + case 0: + /* Careful: converting '\0' returns 0, but a '\0' is a + * real character for us, so we should consume 1 byte. */ + cnt = 1; + /* FALL THROUGH */ + default: + fmt = wcs_nicechar(c, &newl, NULL); + break; } umlen -= cnt; |