/*
* This code would not have been possible without the prior work and
* suggestions of various sourced. Special thanks to Robey for
*
* 04/09: Fixed the "*\*" against "*a" bug (caused an endless loop)
*
* Chris Fuller (aka Fred1@IRC & Fwitz@IRC)
* crf@cfox.bchs.uh.edu
*
* I hereby release this code into the public domain
*
*/
#include "lib.h"
#include "wildcard-match.h"
#include <ctype.h>
#define NOMATCH 0
{
int sofar = 0;
if (na[0] == '\0') {
/* empty string can match only "*" wildcard(s) */
}
/* find the end of each string */
while (*(mask++) != '\0');
mask-=2;
while (*(data++) != '\0');
data-=2;
/* If the mask runs out of chars before the string, fall back on
* a wildcard or fail. */
sofar = 0;
}
else
return NOMATCH;
}
switch (*mask) {
case WILDS: /* Matches anything */
do
mask--; /* Zap redundant wilds */
sofar = 0; /* Update fallback pos */
return MATCH;
continue; /* Next char, please */
case WILDQ:
mask--;
data--;
continue; /* '?' always matches */
}
mask--;
data--;
sofar++; /* Tally the match */
continue; /* Next char, please */
}
sofar = 0;
continue; /* Next char, please */
}
return NOMATCH; /* No fallback=No match */
}
mask--; /* Zap leftover %s & *s */
}
{
}
{
}