Added body-of-text to BIB-1 ANY and the WAIS profile
[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.2  1996-02-20 17:58:42  adam
8  * Added const to yaz_matchstr.
9  *
10  * Revision 1.1  1996/02/20  16:33:06  quinn
11  * Moved matchstr to global util
12  *
13  * Revision 1.1  1995/11/01  11:56:08  quinn
14  * Added Retrieval (data management) functions en masse.
15  *
16  *
17  */
18
19 #include <ctype.h>
20
21 /*
22  * Match strings, independently of case and occurences of '-'.
23  * fairly inefficient - will be replaced with an indexing scheme for
24  * the various subsystems if we get a bottleneck here.
25  */
26
27 int yaz_matchstr(const char *s1, const char *s2)
28 {
29     while (*s1 && *s2)
30     {
31         char c1, c2;
32
33         if (*s1 == '-')
34             s1++;
35         if (*s2 == '-')
36             s2++;
37         if (!*s1 || !*s2)
38             break;
39         c1 = *s1;
40         c2 = *s2;
41         if (isupper(c1))
42             c1 = tolower(c1);
43         if (isupper(c2))
44             c2 = tolower(c2);
45         if (c1 != c2)
46             break;
47         s1++;
48         s2++;
49     }
50     return *s1 || *s2;
51 }