Fixed bug #2068: pkg-config trouble.
[yaz-moved-to-github.git] / src / match_glob.c
1 /*
2  * Copyright (C) 1995-2007, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: match_glob.c,v 1.1 2007-10-24 13:50:02 adam Exp $
6  */
7
8 /**
9  * \file
10  * \brief Glob expression match
11  */
12
13
14 #include <assert.h>
15 #include <stdlib.h>
16 #include <ctype.h>
17 #include <string.h>
18
19 #include <yaz/xmalloc.h>
20 #include <yaz/wrbuf.h>
21 #include <yaz/match_glob.h>
22
23 int yaz_match_glob(const char *glob, const char *text)
24 {
25     if (glob[0] == '\0')
26         return *text == '\0';
27     if (glob[0] == '*')
28     {
29         do 
30         {
31             if (yaz_match_glob(glob+1, text))
32                 return 1;
33         }
34         while (*text++);
35         return 0;
36     }
37     if (*text && (glob[0] == '?' || glob[0] == *text))
38         return yaz_match_glob(glob+1, text+1);
39     return 0;
40 }
41
42 /*
43  * Local variables:
44  * c-basic-offset: 4
45  * indent-tabs-mode: nil
46  * End:
47  * vim: shiftwidth=4 tabstop=8 expandtab
48  */
49