73#define mbgetchar(p) (*p++)
75#define getsource(s,e) (((s)>=(e))?0:mbgetchar(s))
103 }
else if (*
s ==
'.' || *
s ==
'=' || *
s ==
':')
110 else if (b != (
s - 1))
131 if (!b && !p &&
sub ==
'|')
142#define RETURN(v) {error_info.indent--;return (v);}
144#define RETURN(v) {return (v);}
165 error(-1,
"onematch g=%d s=%-.*s p=%s r=%p flags=%o", g, e -
s,
s, p,
179 if (pc ==
'(' || *p ==
'(') {
184 subp = p + (pc !=
'(');
189 if (!(p =
gobble(mp, subp, 0, &g, !r)))
191 if (pc ==
'*' || pc ==
'?' || (pc ==
'+' && oldp == r)) {
199 if (pc ==
'*' || pc ==
'+') {
214 "subgroup#%d n=%d beg=%p end=%p len=%d",
228 "subgroup#%d n=%d beg=%p end=%p len=%d",
241 }
else if (pc ==
'*') {
246 while (*p ==
'*' && *(p + 1) !=
'(')
271 error(-3,
"best#%d groups=%d next=\"%s\"",
279 if (pc >=
'0' && pc <=
'9') {
283 "backref#%d n=%d g=%d beg=%p end=%p len=%d",
288 if (n <= g && mp->current.beg[n])
304 }
else if (pc !=
'?' && pc != sc)
321 error(-3,
"best#%d groups=%d next=\"%s\"", __LINE__,
339 if ((invert = (*p ==
'!')))
345 }
else if (pc ==
'[' && (*p ==
':' || *p ==
'=' || *p ==
'.')) {
352 if (pc == n && *p ==
']')
400 else if (*p ==
'-' && *(p + 1) !=
']') {
405 && tolower(*oldp) == tolower(*olds))
409 }
else if (pc ==
']' && n) {
413 }
else if (pc ==
'\\' && (oldp = p, !(pc =
mbgetchar(p)))) {
421 if (sc == x || sc == pc || (sc > x && sc < pc))
423 if (*p ==
'-' && *(p + 1) !=
']') {
429 }
else if (*p ==
'-' && *(p + 1) !=
']') {
446 if (pc >=
'0' && pc <=
'9') {
449 error(-2,
"backref#%d n=%d g=%d beg=%p end=%p len=%d",
455 while (oldp < mp->current.end[n])
456 if (!*olds || *olds++ != *oldp++)
484 error(-1,
"grpmatch g=%d s=%-.*s p=%s flags=%o", g, e -
s,
s, p,
489 if (*(a = mp->
next_p) !=
'&')
491 }
while ((p =
gobble(mp, p,
'|', &g, 1)));
512 match.last_s = e =
s + strlen(
s);
514 match.best.next_s = 0;
515 match.current.groups = 0;
516 match.current.beg[0] = 0;
521 match.current.groups++;
524 error(-1,
"match i=%d s=\"%s\" p=\"%s\" flags=%o groups=%d next=\"%s\"",
540 if (n >
match.current.groups)
541 n =
match.current.groups;
542 for (i = 0; i < n; i++) {
543 sub[i * 2] =
match.current.end[i] ? (size_t)(
match.current.beg[i] -
s) : 0;
544 sub[i * 2 + 1] =
match.current.end[i] ? (size_t)(
match.current.end[i] -
s) : 0;
size_t match(char *str, char *pat)
replacements for ctype.h functions
static bool gv_isgraph(int c)
static bool gv_islower(int c)
static bool gv_isxdigit(int c)
static bool gv_isupper(int c)
static bool gv_isalnum(int c)
static bool gv_iscntrl(int c)
static bool gv_isblank(int c)
static bool gv_isdigit(int c)
static bool gv_isalpha(int c)
static bool gv_isprint(int c)
static bool gv_isspace(int c)
static bool gv_ispunct(int c)
int strmatch(char *s, char *p)
static int onematch(Match_t *mp, int g, char *s, char *p, char *e, char *r, int flags)
static int grpmatch(Match_t *, int, char *, char *, char *, int)
int strgrpmatch(char *b, char *p, size_t *sub, int n, int flags)
static char * gobble(Match_t *mp, char *s, int sub, int *g, int clear)
a non-owning string reference
const char * data
start of the pointed to string
size_t size
extent of the string in bytes
Non-owning string references.
static bool strview_str_eq(strview_t a, const char *b)
compare a string reference to a string for equality
static bool clear(Ppoint_t pti, Ppoint_t ptj, int start, int end, int V, Ppoint_t pts[], int nextPt[])