summaryrefslogtreecommitdiff
path: root/src/mbyte.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-06-06 21:59:07 +0000
committerBram Moolenaar <Bram@vim.org>2005-06-06 21:59:07 +0000
commit45eeb13324b1d4fa80c1e4ed872bebd1202bf1f0 (patch)
tree04352cb65f7968a02df5a3ec8021feff22fdea54 /src/mbyte.c
parentcfc6c43ce2fe59ccc7e48785e6c20126f0ee9d7f (diff)
downloadvim-45eeb13324b1d4fa80c1e4ed872bebd1202bf1f0.zip
updated for version 7.0081
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c6
1 files changed, 5 insertions, 1 deletions
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));