X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmatchstr.c;h=82aa0062fee6e45409cd21b92ab1fc8f4247dc44;hb=94b1547e5951e1e01bf5180159e74095cd0527f4;hp=101e777b75b81327469a778684799878ef760e7b;hpb=0c46d2e66bdeea1600e700124a81a5d0a65d349e;p=yaz-moved-to-github.git diff --git a/src/matchstr.c b/src/matchstr.c index 101e777..82aa006 100644 --- a/src/matchstr.c +++ b/src/matchstr.c @@ -18,6 +18,27 @@ #include #include +int yaz_strcasecmp(const char *s1, const char *s2) +{ + return yaz_strncasecmp(s1, s2, strlen(s1) + 1); +} + +int yaz_strncasecmp(const char *s1, const char *s2, size_t n) +{ + while (n--) + { + unsigned char c1 = *s1++; + unsigned char c2 = *s2++; + if (yaz_isupper(c1)) + c1 = yaz_tolower(c1); + if (yaz_isupper(c2)) + c2 = yaz_tolower(c2); + if (c1 != c2) + return c1 - c2; + } + return 0; +} + int yaz_matchstr(const char *s1, const char *s2) { while (*s1 && *s2)