75#define mbgetchar(p) (*p++)
77#define getsource(s,e) (((s)>=(e))?0:mbgetchar(s))
105 }
else if (*
s ==
'.' || *
s ==
'=' || *
s ==
':')
112 else if (b != (
s - 1))
133 if (!b && !p &&
sub ==
'|')
144#define RETURN(v) {error_info.indent--;return (v);}
146#define RETURN(v) {return (v);}
167 error(-1,
"onematch g=%d s=%-.*s p=%s r=%p flags=%o", g, e -
s,
s, p,
181 if (pc ==
'(' || *p ==
'(') {
186 subp = p + (pc !=
'(');
191 if (!(p =
gobble(mp, subp, 0, &g, !r)))
193 if (pc ==
'*' || pc ==
'?' || (pc ==
'+' && oldp == r)) {
201 if (pc ==
'*' || pc ==
'+') {
216 "subgroup#%d n=%d beg=%p end=%p len=%d",
230 "subgroup#%d n=%d beg=%p end=%p len=%d",
243 }
else if (pc ==
'*') {
248 while (*p ==
'*' && *(p + 1) !=
'(')
273 error(-3,
"best#%d groups=%d next=\"%s\"",
281 if (pc >=
'0' && pc <=
'9') {
285 "backref#%d n=%d g=%d beg=%p end=%p len=%d",
290 if (n <= g && mp->current.beg[n])
306 }
else if (pc !=
'?' && pc != sc)
323 error(-3,
"best#%d groups=%d next=\"%s\"", __LINE__,
341 if ((invert = (*p ==
'!')))
347 }
else if (pc ==
'[' && (*p ==
':' || *p ==
'=' || *p ==
'.')) {
354 if (pc == n && *p ==
']')
402 else if (*p ==
'-' && *(p + 1) !=
']') {
407 && tolower(*oldp) == tolower(*olds))
411 }
else if (pc ==
']' && n) {
415 }
else if (pc ==
'\\' && (oldp = p, !(pc =
mbgetchar(p)))) {
423 if (sc == x || sc == pc || (sc > x && sc < pc))
425 if (*p ==
'-' && *(p + 1) !=
']') {
431 }
else if (*p ==
'-' && *(p + 1) !=
']') {
448 if (pc >=
'0' && pc <=
'9') {
451 error(-2,
"backref#%d n=%d g=%d beg=%p end=%p len=%d",
457 while (oldp < mp->current.end[n])
458 if (!*olds || *olds++ != *oldp++)
486 error(-1,
"grpmatch g=%d s=%-.*s p=%s flags=%o", g, e -
s,
s, p,
491 if (*(a = mp->
next_p) !=
'&')
493 }
while ((p =
gobble(mp, p,
'|', &g, 1)));
514 match.last_s = e =
s + strlen(
s);
516 match.best.next_s = 0;
517 match.current.groups = 0;
518 match.current.beg[0] = 0;
523 match.current.groups++;
526 error(-1,
"match i=%d s=\"%s\" p=\"%s\" flags=%o groups=%d next=\"%s\"",
542 if (n >
match.current.groups)
543 n =
match.current.groups;
544 for (i = 0; i < n; i++) {
545 sub[i * 2] =
match.current.end[i] ? (size_t)(
match.current.beg[i] -
s) : 0;
546 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[])