Hi,
I'm writing this code where I want to match a string with a signature.
A wildcard '?' would mean it can skip 1 character. A wildcard '*' means it can skip 0 to 32 characters.
For example, say I have:
string "screwed" and a signature "screw?d"
These two would match.
Say I have:
string "screw33333d" and a signature "screw*d"
These two would match also.
The code I have right now looks like this, and it seems to work fine with the '*' wildcard, but I don't understand why '?' is not working.
int i, star;
new_segment:
star = 0;
while (sig[0] == '*')
{
star = 1;
sig++;
}
test_match:
for (i = 0; sig[i] && (sig[i] != '*'); i++)
{
if (sig[i] != text[i])
{
if (! text[i]) return false;
if (sig[i] == '?') continue;
if (! star) return false;
text++;
goto test_match;
}
}
if (sig[i] == '*')
{
text += i;
sig += i;
goto new_segment;
}
if (! text[i]) return true;
if (i && sig[i-1] == '*') return true;
if (! star) return false;
text++;
goto test_match;
Can anyone help me?