From 4c3edda1f13060d85fd34425bf39b974f0ab59d7 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 11 Jan 2006 20:09:03 +0000 Subject: Decided to use a switch() in mb_niceformat(). --- Src/utils.c | 19 ++++++++++++------- 1 file 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; -- cgit 1.4.1