summaryrefslogtreecommitdiffstats
path: root/src/strings.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:51 +0000
commit3b8b0072dafee1c363713688a821982167185fa0 (patch)
tree7ae89cb789d77aecb88f4785011115d820f9bf49 /src/strings.c
parentAdding upstream version 2:9.1.0698. (diff)
downloadvim-upstream.tar.xz
vim-upstream.zip
Adding upstream version 2:9.1.0709.upstream/2%9.1.0709upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/strings.c')
-rw-r--r--src/strings.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/strings.c b/src/strings.c
index b8ea00b..a586d8a 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -590,6 +590,33 @@ vim_strnicmp(char *s1, char *s2, size_t len)
#endif
/*
+ * Compare two ASCII strings, for length "len", ignoring case, ignoring locale
+ * (mostly matters for turkish locale where i I might be different).
+ * return 0 for match, < 0 for smaller, > 0 for bigger
+ */
+ int
+vim_strnicmp_asc(char *s1, char *s2, size_t len)
+{
+ int i;
+ int save_cmp_flags = cmp_flags;
+
+ cmp_flags |= CMP_KEEPASCII; // compare by ASCII value, ignoring locale
+ while (len > 0)
+ {
+ i = vim_tolower(*s1) - vim_tolower(*s2);
+ if (i != 0)
+ break; // this character is different
+ if (*s1 == NUL)
+ break; // strings match until NUL
+ ++s1;
+ ++s2;
+ --len;
+ }
+ cmp_flags = save_cmp_flags;
+ return i;
+}
+
+/*
* Search for first occurrence of "c" in "string".
* Version of strchr() that handles unsigned char strings with characters from
* 128 to 255 correctly. It also doesn't return a pointer to the NUL at the