X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmatchstr.c;h=82aa0062fee6e45409cd21b92ab1fc8f4247dc44;hb=94140e7ec2de8ecd8c6f3715121b0502f469c003;hp=ce9521ca809bbbfa201250aa602f6bd8e09ae485;hpb=4f3bcae93d51a26709c12b51261c3d95af610cb2;p=yaz-moved-to-github.git diff --git a/src/matchstr.c b/src/matchstr.c index ce9521c..82aa006 100644 --- a/src/matchstr.c +++ b/src/matchstr.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ @@ -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)