X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmatchstr.c;h=b078150958fc975fa372d515df0b6442647d4ca0;hb=138fbf3c4582f2738e5b30e440994c9b6d76e194;hp=95c32e05ee57d49c565511221586d36313ae7ca2;hpb=05c274ef315384faafcc5900c17468f0ea2474e6;p=yaz-moved-to-github.git diff --git a/src/matchstr.c b/src/matchstr.c index 95c32e0..b078150 100644 --- a/src/matchstr.c +++ b/src/matchstr.c @@ -1,8 +1,6 @@ -/* - * Copyright (c) 1995-2004, Index Data. +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: matchstr.c,v 1.2 2004-10-15 00:19:00 adam Exp $ */ /** @@ -20,38 +18,32 @@ #include #include -/* - * Match strings, independently of case and occurences of '-'. - * fairly inefficient - will be replaced with an indexing scheme for - * the various subsystems if we get a bottleneck here. - */ - int yaz_matchstr(const char *s1, const char *s2) { while (*s1 && *s2) { - char c1 = *s1; - char c2 = *s2; + unsigned char c1 = *s1; + unsigned char c2 = *s2; if (c2 == '?') return 0; - if (c1 == '-') - c1 = *++s1; - if (c2 == '-') - c2 = *++s2; - if (!c1 || !c2) - break; + if (c1 == '-') + c1 = *++s1; + if (c2 == '-') + c2 = *++s2; + if (!c1 || !c2) + break; if (c2 != '.') { - if (isupper(c1)) - c1 = tolower(c1); - if (isupper(c2)) - c2 = tolower(c2); - if (c1 != c2) - break; + if (isupper(c1)) + c1 = tolower(c1); + if (isupper(c2)) + c2 = tolower(c2); + if (c1 != c2) + break; } - s1++; - s2++; + s1++; + s2++; } return *s1 || *s2; } @@ -81,3 +73,11 @@ void __assert_fail (const char *assertion, const char *file, } #endif #endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +