about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Src/utils.c19
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;