Created
December 23, 2011 15:03
-
-
Save sw/1514422 to your computer and use it in GitHub Desktop.
SLRE: is_any_of() with escape character support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int | |
is_any_of(const unsigned char *p, int len, const char *s, int *ofs) | |
{ | |
int i, ch; | |
ch = s[*ofs]; | |
for (i = 0; i < len; i++) | |
if (p[i] == ch) { | |
(*ofs)++; | |
return (1); | |
} | |
else if (p[i] == 0) | |
{ | |
if ( ((p[i + 1] == SPACE) && isspace(ch) ) | |
|| ((p[i + 1] == NONSPACE) && !isspace(ch) ) | |
|| ((p[i + 1] == DIGIT) && isdigit(ch) ) | |
|| ((p[i + 1] == '\0') && (ch == '\0') ) | |
{ | |
(*ofs)++; | |
return (1); | |
} | |
i++; | |
} | |
} | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment