From 56f067a284ecb601384f9c6884155fb66b9dbc95 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 1 Jun 2016 21:56:38 +0200
Subject: [PATCH] chars: ensure that files are sorted also when strncasecmp()
 is strange

When running in a non-UTF locale, and when strncasecmp() suffers from
the same defect as strncmp(), make sure not to pass a length with the
high bit set.
---
 src/chars.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/chars.c b/src/chars.c
index 4341aa26..42249ac9 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -483,14 +483,14 @@ size_t move_mbright(const char *buf, size_t pos)
 /* This function is equivalent to strcasecmp(). */
 int nstrcasecmp(const char *s1, const char *s2)
 {
-    return strncasecmp(s1, s2, (size_t)-1);
+    return strncasecmp(s1, s2, HIGHEST_POSITIVE);
 }
 #endif
 
 /* This function is equivalent to strcasecmp() for multibyte strings. */
 int mbstrcasecmp(const char *s1, const char *s2)
 {
-    return mbstrncasecmp(s1, s2, (size_t)-1);
+    return mbstrncasecmp(s1, s2, HIGHEST_POSITIVE);
 }
 
 #ifndef HAVE_STRNCASECMP
-- 
GitLab