Parsee/src/Glob.c
LDA 692cb8aa6f [MOD] Verbosity levels, avatar cleanser
I have a weird bug where Parsee seems to hang on a Db request, been
tryign to figure that otu since a while but can't quite put my finger on
where.
You can have this commit, as a treat.
2024-08-24 19:36:37 +02:00

50 lines
967 B
C

#include <Glob.h>
#include <Cytoplasm/Str.h>
#include <string.h>
bool
GlobMatches(char *rule, char *string)
{
char c1, c2;
if (!rule || !string)
{
return false;
}
while ((c1 = *rule))
{
char next = *(rule + 1);
c2 = *string;
switch (c1)
{
case '*':
while ((c2 = *string) && (c2 != next))
{
string++;
}
if (next && !c2)
{
return false;
}
break;
case '?':
if (!c2)
{
return false;
}
string++;
break;
default:
if (c1 != c2)
{
return false;
}
string++;
break;
}
rule++;
}
return !*string;
}