46 #define matcher smatcher
49 #define dissect sdissect
50 #define backref sbackref
58 #define matcher lmatcher
61 #define dissect ldissect
62 #define backref lbackref
93 #define MAX_RECURSION 100
96 #define BOLEOL (BOL + 2)
97 #define NOTHING (BOL + 3)
100 #define CODEMAX (BOL + 5)
101 #define NONCHAR(c) ((c) > OUT)
102 #define NNONCHAR (CODEMAX - OUT)
110 static char *pchar(
int);
114 #define SP(t, s, c) print(m, t, s, c, stdout)
115 #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
118 if (m->eflags & RZ_REGEX_TRACE) \
119 (void)printf("=%s\n", (str)); \
124 #define AT(t, p1, p2, s1, s2)
139 const sopno gf =
g->firststate + 1;
140 const sopno gl =
g->laststate;
158 if (
g->must !=
NULL) {
159 for (dp =
start; dp < stop; dp++)
160 if (*dp ==
g->must[0] && stop - dp >=
g->mlen &&
161 memcmp(dp,
g->must, (
size_t)
g->mlen) == 0)
176 if (
m->g->nstates * 4 <
m->g->nstates)
194 if (nmatch == 0 && !
g->backrefs)
202 NOTE(
"finding start");
204 if (
endp ||
m->coldp >
m->endp) {
209 if (nmatch == 1 && !
g->backrefs)
224 for (
i = 1;
i <=
m->g->nsub;
i++)
225 m->pmatch[
i].rm_so =
m->pmatch[
i].rm_eo = -1;
230 if (
g->nplus > 0 && !
m->lastpos) {
231 if ((
g->nplus + 1) *
sizeof(
char *) <
g->nplus) {
236 m->lastpos = (
char **)
malloc((
g->nplus + 1) *
239 if (
g->nplus > 0 && !
m->lastpos) {
244 NOTE(
"backref dissect");
254 if (
g->nplus || !
m->lastpos) {
266 for (
i = 1;
i <=
m->g->nsub;
i++) {
267 if (
m->pmatch[
i].rm_so != -1) {
270 if (
m->pmatch[
i].rm_eo != -1) {
275 NOTE(
"backoff dissect");
283 if (
m->coldp == stop)
295 for (
i = 1;
i < nmatch;
i++) {
296 if (i <= m->
g->nsub) {
306 if (
m->pmatch !=
NULL)
307 free((
char *)
m->pmatch);
308 if (
m->lastpos !=
NULL)
309 free((
char *)
m->lastpos);
333 AT(
"diss",
start, stop, startst, stopst);
335 for (ss = startst; ss < stopst; ss = es) {
338 switch (
OP(
m->g->strip[es])) {
341 es +=
OPND(
m->g->strip[es]);
344 while (
OP(
m->g->strip[es]) !=
O_CH)
345 es +=
OPND(
m->g->strip[es]);
351 switch (
OP(
m->g->strip[ss])) {
377 tail =
slow(
m, rest, stop, es, stopst);
391 }
else if (
sp != rest)
402 tail =
slow(
m, rest, stop, es, stopst);
414 sep =
slow(
m, ssp, rest, ssub, esub);
415 if (!sep || sep == ssp)
426 if (
slow(
m, ssp, sep, ssub, esub) == rest) {
427 dp =
dissect(
m, ssp, sep, ssub, esub);
441 tail =
slow(
m, rest, stop, es, stopst);
449 esub = ss +
OPND(
m->g->strip[ss]) - 1;
450 if (
OP(
m->g->strip[esub]) !=
OOR1) {
454 if (
slow(
m,
sp, rest, ssub, esub) == rest)
457 if (
OP(
m->g->strip[esub]) ==
OOR1) {
459 if (
OP(
m->g->strip[esub]) ==
OOR2) {
461 esub +=
OPND(
m->g->strip[esub]);
462 if (
OP(
m->g->strip[esub]) ==
OOR2) {
465 if (
OP(
m->g->strip[esub]) !=
O_CH) {
484 i =
OPND(
m->g->strip[ss]);
485 if (
i > 0 && i <= m->
g->nsub) {
486 m->pmatch[
i].rm_so =
sp -
m->offp;
490 i =
OPND(
m->g->strip[ss]);
491 if (
i > 0 && i <= m->
g->nsub) {
492 m->pmatch[
i].rm_eo =
sp -
m->offp;
527 AT(
"back",
start, stop, startst, stopst);
532 for (ss = startst; !hard && ss < stopst; ss++)
533 switch (
OP(
s =
m->g->strip[ss])) {
535 if (
sp == stop || *
sp++ != (
char)
OPND(
s))
550 (sp < m->
endp && *(
sp - 1) ==
'\n' &&
557 (sp < m->
endp && *
sp ==
'\n' &&
564 (sp < m->
endp && *(
sp - 1) ==
'\n' &&
567 !
ISWORD((
unsigned char)*(
sp - 1)))) &&
574 (sp < m->
endp && *
sp ==
'\n' &&
577 (
sp >
m->beginp &&
ISWORD((
unsigned char)*(
sp - 1)))) {
590 }
while (
OP(
s =
m->g->strip[ss]) !=
O_CH);
605 AT(
"hard",
sp, stop, ss, stopst);
610 if (
i > 0 && i <= m->
g->nsub) {
611 if (
m->pmatch[
i].rm_eo == -1) {
615 if (
m->pmatch[
i].rm_so != -1) {
616 len =
m->pmatch[
i].rm_eo -
m->pmatch[
i].rm_so;
619 if (stop -
m->beginp >=
len) {
620 if (
sp > stop -
len) {
624 ssp =
m->offp +
m->pmatch[
i].rm_so;
625 if (memcmp(
sp, ssp,
len) != 0)
629 return (
backref(
m,
sp +
len, stop, ss + 1, stopst, lev, rec));
633 dp =
backref(
m,
sp, stop, ss + 1, stopst, lev, rec);
639 if (
m->lastpos && (lev + 1 <=
m->g->nplus)) {
640 m->lastpos[lev + 1] =
sp;
641 return (
backref(
m,
sp, stop, ss + 1, stopst, lev + 1, rec));
645 if (
sp ==
m->lastpos[lev])
646 return (
backref(
m,
sp, stop, ss + 1, stopst, lev - 1, rec));
648 m->lastpos[lev] =
sp;
651 return (
backref(
m,
sp, stop, ss + 1, stopst, lev - 1, rec));
657 esub = ss +
OPND(
s) - 1;
658 if (
OP(
m->g->strip[esub]) !=
OOR1) {
662 dp =
backref(
m,
sp, stop, ssub, esub, lev, rec);
666 if (
OP(
m->g->strip[esub]) ==
O_CH)
669 if (
OP(
m->g->strip[esub]) !=
OOR2) {
673 esub +=
OPND(
m->g->strip[esub]);
674 if (
OP(
m->g->strip[esub]) ==
OOR2)
676 else if (
OP(
m->g->strip[esub]) !=
O_CH) {
683 if (
i > 0 && i <= m->
g->nsub) {
684 offsave =
m->pmatch[
i].rm_so;
685 m->pmatch[
i].rm_so =
sp -
m->offp;
686 dp =
backref(
m,
sp, stop, ss + 1, stopst, lev, rec);
689 m->pmatch[
i].rm_so = offsave;
695 if (
i > 0 && i <= m->
g->nsub) {
696 offsave =
m->pmatch[
i].rm_eo;
697 m->pmatch[
i].rm_eo =
sp -
m->offp;
698 dp =
backref(
m,
sp, stop, ss + 1, stopst, lev, rec);
701 m->pmatch[
i].rm_eo = offsave;
762 if ((flagch ==
BOL || (lastc !=
OUT && !
ISWORD(lastc))) &&
770 if (flagch ==
BOW || flagch ==
EOW) {
817 AT(
"slow",
start, stop, startst, stopst);
820 SP(
"sstart",
st, *
p);
844 SP(
"sboleol",
st,
c);
848 if ((flagch ==
BOL || (lastc !=
OUT && !
ISWORD(lastc))) &&
856 if (flagch ==
BOW || flagch ==
EOW) {
858 SP(
"sboweow",
st,
c);
910 if (ch == (
char)
OPND(
s))
1019 (void)fprintf(
d,
"%s", caption);
1021 (void)fprintf(
d,
" %s", pchar(ch));
1022 for (
i = 0;
i <
g->nstates;
i++)
1024 (void)fprintf(
d,
"%s%d", (first) ?
"\t" :
", ",
i);
1027 (void)fprintf(
d,
"\n");
1040 (void)
printf(
"%s ", pchar(*stop));
1041 (void)
printf(
"%ld-%ld\n", (
long)startst, (
long)stopst);
1056 static char pbuf[10];
1059 (void)
snprintf(pbuf,
sizeof pbuf,
"%c", ch);
1061 (
void)
snprintf(pbuf,
sizeof pbuf,
"\\%o", ch);
static ut32 stp(ArmOp *op, int k)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags long
static states step(struct re_guts *, sopno, sopno, states, int, states)
static char * dissect(struct match *, char *, char *, sopno, sopno)
static char * slow(struct match *, char *, char *, sopno, sopno)
static int matcher(struct re_guts *, char *, size_t, RzRegexMatch[], int)
static char * fast(struct match *, char *, char *, sopno, sopno)
static char * backref(struct match *, char *, char *, sopno, sopno, sopno, int)
#define AT(t, p1, p2, s1, s2)
#define OP(v, w, x, y, z)
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * malloc(size_t size)
#define BACK(dst, src, n)
#define RZ_REGEX_STARTEND
struct rz_regmatch_t RzRegexMatch
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()