X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fyaz-util.c;fp=util%2Fyaz-util.c;h=87fb1d5bdc2d8712d8371fe781e7a42635e31af1;hb=7826e2c92b1a07182ba5bfb94c304f1fa7d27387;hp=0000000000000000000000000000000000000000;hpb=de40d7c17747988ed4c53e51e45cbb790a3abd7b;p=yaz-moved-to-github.git diff --git a/util/yaz-util.c b/util/yaz-util.c new file mode 100644 index 0000000..87fb1d5 --- /dev/null +++ b/util/yaz-util.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1995, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: yaz-util.c,v $ + * Revision 1.1 1996-02-20 16:33:06 quinn + * Moved matchstr to global util + * + * Revision 1.1 1995/11/01 11:56:08 quinn + * Added Retrieval (data management) functions en masse. + * + * + */ + +#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(char *s1, char *s2) +{ + while (*s1 && *s2) + { + char c1, c2; + + if (*s1 == '-') + s1++; + if (*s2 == '-') + s2++; + if (!*s1 || !*s2) + break; + c1 = *s1; + c2 = *s2; + if (isupper(c1)) + c1 = tolower(c1); + if (isupper(c2)) + c2 = tolower(c2); + if (c1 != c2) + break; + s1++; + s2++; + } + return *s1 || *s2; +}