mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:15:10 +00:00
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.
50 lines
967 B
C
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;
|
|
}
|