From 45eeb13324b1d4fa80c1e4ed872bebd1202bf1f0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 6 Jun 2005 21:59:07 +0000 Subject: updated for version 7.0081 --- src/mbyte.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mbyte.c') diff --git a/src/mbyte.c b/src/mbyte.c index 996eb8dd5..93375bc2e 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -2192,6 +2192,7 @@ mb_strnicmp(s1, s2, nn) { int i, j, l; int cdiff; + int incomplete = FALSE; int n = nn; for (i = 0; i < n; i += l) @@ -2202,7 +2203,10 @@ mb_strnicmp(s1, s2, nn) { l = utf_byte2len(s1[i]); if (l > n - i) + { l = n - i; /* incomplete character */ + incomplete = TRUE; + } /* Check directly first, it's faster. */ for (j = 0; j < l; ++j) if (s1[i + j] != s2[i + j]) @@ -2210,7 +2214,7 @@ mb_strnicmp(s1, s2, nn) if (j < l) { /* If one of the two characters is incomplete return -1. */ - if (i + utf_byte2len(s1[i]) > n || i + utf_byte2len(s2[i]) > n) + if (incomplete || i + utf_byte2len(s2[i]) > n) return -1; cdiff = utf_fold(utf_ptr2char(s1 + i)) - utf_fold(utf_ptr2char(s2 + i)); -- cgit v1.2.3