13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
/* Funktions for comparing with wild-cards */
16
18
#include <config.h>
18
20
#include <drizzled/internal/my_sys.h>
23
const char wild_many= '%';
24
const char wild_one= '_';
25
const char wild_prefix= '\\';
27
/* Test if a string is "comparable" to a wild-card string */
28
/* returns 0 if the strings are "comparable" */
32
char wild_prefix= '\\';
34
int wild_compare(const char *str, const char *wildstr, bool str_is_pattern)
40
while (*wildstr && *wildstr != wild_many && *wildstr != wild_one)
42
if (*wildstr == wild_prefix && wildstr[1])
45
if (str_is_pattern && *str++ != wild_prefix)
48
if (*wildstr++ != *str++)
53
if (*wildstr++ == wild_one)
55
if (! *str || (str_is_pattern && *str == wild_many))
56
return 1; /* One char; skip */
57
if (*str++ == wild_prefix && str_is_pattern && *str)
62
while (str_is_pattern && *str == wild_many)
64
for (; *wildstr == wild_many || *wildstr == wild_one; wildstr++)
65
if (*wildstr == wild_many)
67
while (str_is_pattern && *str == wild_many)
72
if (str_is_pattern && *str == wild_prefix && str[1])
78
return 0; /* '*' as last char: OK */
79
if ((cmp= *wildstr) == wild_prefix && wildstr[1] && !str_is_pattern)
83
while (*str && *str != cmp)
87
if (wild_compare(str,wildstr,str_is_pattern) == 0)
90
/* We will never come here */
27
96
} /* namespace internal */
28
97
} /* namespace drizzled */