gargoyle/src/twine.c

24 lines
571 B
C

#include <ctype.h>
#include <gargoyle/twine.h>
static uint8_t is_sep(char tok) {
return (tok == '_' || tok == '-');
}
uint8_t gargoyle_cmp(const char *s1, const char *s2, uint16_t len, uint8_t flags) {
while(*s1 && *s2 && len) {
if(flags & GARGOYLE_CMP_ICASE && isalpha(*s1) && tolower(*s1) == tolower(*s2)) {
s1 += 1, s2 += 1;
} else if(flags & GARGOYLE_CMP_SYMBL && is_sep(*s1) && is_sep(*s2)) {
s1 += 1, s2 += 1;
} else if(*s1 == *s2) {
s1 += 1, s2 += 1;
} else {
return 0;
}
len -= 1;
}
return *s1 == *s2;
}