From b305911cbaa6d902c01d8db85a41696c6e4a78fc Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 27 Jul 2016 22:03:48 +0200
Subject: [PATCH] chars: straighten out the flow of a loop, so it is easier to
 follow

---
 src/chars.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/chars.c b/src/chars.c
index e861c939..d80bd3af 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -512,8 +512,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
 
 	assert(s1 != NULL && s2 != NULL);
 
-	for (; *s1 != '\0' && *s2 != '\0' && n > 0;
-		s1 += move_mbright(s1, 0), s2 += move_mbright(s2, 0), n--) {
+	while (*s1 != '\0' && *s2 != '\0' && n > 0) {
 	    bool bad1 = FALSE, bad2 = FALSE;
 
 	    if (mbtowc(&wc1, s1, MB_CUR_MAX) < 0) {
@@ -530,6 +529,10 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
 
 	    if (bad1 != bad2 || towlower(wc1) != towlower(wc2))
 		break;
+
+	    s1 += move_mbright(s1, 0);
+	    s2 += move_mbright(s2, 0);
+	    n--;
 	}
 
 	return (n > 0) ? towlower(wc1) - towlower(wc2) : 0;
-- 
GitLab