1 | /*
|
---|
2 | * Copyright (c) 1995-2000, Index Data.
|
---|
3 | * See the file LICENSE for details.
|
---|
4 | * Sebastian Hammer, Adam Dickmeiss
|
---|
5 | *
|
---|
6 | * $Log$
|
---|
7 | * Revision 1.1 2000/08/03 03:12:07 johnmcp
|
---|
8 | * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
|
---|
9 | *
|
---|
10 | * Revision 1.5 2000/02/29 13:44:55 adam
|
---|
11 | * Check for config.h (currently not generated).
|
---|
12 | *
|
---|
13 | * Revision 1.4 1999/11/30 13:47:12 adam
|
---|
14 | * Improved installation. Moved header files to include/yaz.
|
---|
15 | *
|
---|
16 | * Revision 1.3 1999/10/19 12:35:42 adam
|
---|
17 | * Minor bug fix (bug introduced by previous commit).
|
---|
18 | *
|
---|
19 | * Revision 1.2 1999/10/15 11:35:41 adam
|
---|
20 | * Character '.' matches any single character.
|
---|
21 | *
|
---|
22 | * Revision 1.1 1999/06/08 10:10:16 adam
|
---|
23 | * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
|
---|
24 | *
|
---|
25 | * Revision 1.7 1997/09/30 11:47:47 adam
|
---|
26 | * Added function 'cause checkergcc doesn't include assert handler.
|
---|
27 | *
|
---|
28 | * Revision 1.6 1997/09/04 07:54:34 adam
|
---|
29 | * Right hande side operand of yaz_matchstr may include a ? in
|
---|
30 | * which case it returns "match ok".
|
---|
31 | *
|
---|
32 | * Revision 1.5 1997/07/21 12:48:11 adam
|
---|
33 | * Removed windows DLL stubs.
|
---|
34 | *
|
---|
35 | * Revision 1.4 1997/05/01 15:07:55 adam
|
---|
36 | * Added DLL entry point routines.
|
---|
37 | *
|
---|
38 | * Revision 1.3 1996/10/29 13:36:28 adam
|
---|
39 | * Added header.
|
---|
40 | *
|
---|
41 | * Revision 1.2 1996/02/20 17:58:42 adam
|
---|
42 | * Added const to yaz_matchstr.
|
---|
43 | *
|
---|
44 | * Revision 1.1 1996/02/20 16:33:06 quinn
|
---|
45 | * Moved matchstr to global util
|
---|
46 | *
|
---|
47 | * Revision 1.1 1995/11/01 11:56:08 quinn
|
---|
48 | * Added Retrieval (data management) functions en masse.
|
---|
49 | *
|
---|
50 | *
|
---|
51 | */
|
---|
52 | #if HAVE_CONFIG_H
|
---|
53 | #include <config.h>
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | #include <stdio.h>
|
---|
57 | #include <assert.h>
|
---|
58 | #include <ctype.h>
|
---|
59 | #include <yaz/yaz-util.h>
|
---|
60 |
|
---|
61 | /*
|
---|
62 | * Match strings, independently of case and occurences of '-'.
|
---|
63 | * fairly inefficient - will be replaced with an indexing scheme for
|
---|
64 | * the various subsystems if we get a bottleneck here.
|
---|
65 | */
|
---|
66 |
|
---|
67 | int yaz_matchstr(const char *s1, const char *s2)
|
---|
68 | {
|
---|
69 | while (*s1 && *s2)
|
---|
70 | {
|
---|
71 | char c1 = *s1;
|
---|
72 | char c2 = *s2;
|
---|
73 |
|
---|
74 | if (c2 == '?')
|
---|
75 | return 0;
|
---|
76 | if (c1 == '-')
|
---|
77 | c1 = *++s1;
|
---|
78 | if (c2 == '-')
|
---|
79 | c2 = *++s2;
|
---|
80 | if (!c1 || !c2)
|
---|
81 | break;
|
---|
82 | if (c2 != '.')
|
---|
83 | {
|
---|
84 | if (isupper(c1))
|
---|
85 | c1 = tolower(c1);
|
---|
86 | if (isupper(c2))
|
---|
87 | c2 = tolower(c2);
|
---|
88 | if (c1 != c2)
|
---|
89 | break;
|
---|
90 | }
|
---|
91 | s1++;
|
---|
92 | s2++;
|
---|
93 | }
|
---|
94 | return *s1 || *s2;
|
---|
95 | }
|
---|
96 |
|
---|
97 | #ifdef __GNUC__
|
---|
98 | #ifdef __CHECKER__
|
---|
99 | void __assert_fail (const char *assertion, const char *file,
|
---|
100 | unsigned int line, const char *function)
|
---|
101 | {
|
---|
102 | fprintf (stderr, "%s in file %s line %d func %s\n",
|
---|
103 | assertion, file, line, function);
|
---|
104 | abort ();
|
---|
105 | }
|
---|
106 | #endif
|
---|
107 | #endif
|
---|