87fb1d5bdc2d8712d8371fe781e7a42635e31af1
[yaz-moved-to-github.git] / util / yaz-util.c
1 /*
2  * Copyright (c) 1995, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: yaz-util.c,v $
7  * Revision 1.1  1996-02-20 16:33:06  quinn
8  * Moved matchstr to global util
9  *
10  * Revision 1.1  1995/11/01  11:56:08  quinn
11  * Added Retrieval (data management) functions en masse.
12  *
13  *
14  */
15
16 #include <ctype.h>
17
18 /*
19  * Match strings, independently of case and occurences of '-'.
20  * fairly inefficient - will be replaced with an indexing scheme for
21  * the various subsystems if we get a bottleneck here.
22  */
23
24 int yaz_matchstr(char *s1, char *s2)
25 {
26     while (*s1 && *s2)
27     {
28         char c1, c2;
29
30         if (*s1 == '-')
31             s1++;
32         if (*s2 == '-')
33             s2++;
34         if (!*s1 || !*s2)
35             break;
36         c1 = *s1;
37         c2 = *s2;
38         if (isupper(c1))
39             c1 = tolower(c1);
40         if (isupper(c2))
41             c2 = tolower(c2);
42         if (c1 != c2)
43             break;
44         s1++;
45         s2++;
46     }
47     return *s1 || *s2;
48 }