Subject: Slight improvement: if cs = "\xC0\x80" and ct = "\x00", loop would continue after NUL-byte, this should not happen.

From: "jan.nijtmans" <[email-masked]>
Date: Tue, 21 May 2013 09:38:05 +0000

---
 generic/tclUtf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 9dacb53..a7a2091 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1110,12 +1110,12 @@ TclUtfCasecmp(
     CONST char *ct)		/* UTF string cs is compared to. */
 {
     Tcl_UniChar ch1, ch2;
-    char c;
+    int goOn;
 
     do {
 
-	/* If c == '\0', loop should end. */
-   	c = *cs;
+	/* If *cs == '\0' or *ct == '\0', loop should end. */
+	goOn = *cs && *ct;
 
 	cs += TclUtfToUniChar(cs, &ch1);
 	ct += TclUtfToUniChar(ct, &ch2);
@@ -1124,7 +1124,7 @@ TclUtfCasecmp(
 	    ch2 = Tcl_UniCharToLower(ch2);
 	    if (ch1 != ch2) break;
 	}
-    } while (c);
+    } while (goOn);
     return (ch1 - ch2);
 }
 
-- 
cgit v0.12