summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/string-util.h1
-rw-r--r--source/fitz/string.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/include/mupdf/fitz/string-util.h b/include/mupdf/fitz/string-util.h
index 235bb060..ffd7cb1d 100644
--- a/include/mupdf/fitz/string-util.h
+++ b/include/mupdf/fitz/string-util.h
@@ -97,6 +97,7 @@ char *fz_cleanname(char *name);
Case insensitive (ASCII only) string comparison.
*/
int fz_strcasecmp(const char *a, const char *b);
+int fz_strncasecmp(const char *a, const char *b, int n);
/*
FZ_UTFMAX: Maximum number of bytes in a decoded rune (maximum length returned by fz_chartorune).
diff --git a/source/fitz/string.c b/source/fitz/string.c
index e70ae6e6..4bb3dc9d 100644
--- a/source/fitz/string.c
+++ b/source/fitz/string.c
@@ -22,6 +22,16 @@ fz_strnlen(const char *s, size_t n)
}
int
+fz_strncasecmp(const char *a, const char *b, int n)
+{
+ if (!n--)
+ return 0;
+ for (; *a && *b && n && (*a == *b || fz_tolower(*a) == fz_tolower(*b)); a++, b++, n--)
+ ;
+ return fz_tolower(*a) - fz_tolower(*b);
+}
+
+int
fz_strcasecmp(const char *a, const char *b)
{
while (fz_tolower(*a) == fz_tolower(*b))