Lines Matching refs:m
114 static const char *dissect(struct match *m, const char *start, const char *stop, sopno startst, sop…
115 static const char *backref(struct match *m, const char *start, const char *stop, sopno startst, sop…
116 static const char *walk(struct match *m, const char *start, const char *stop, sopno startst, sopno …
133 static void print(struct match *m, const char *caption, states st, int ch, FILE *d);
136 static void at(struct match *m, const char *title, const char *start, const char *stop, sopno start…
148 #define SP(t, s, c) print(m, t, s, c, stdout)
149 #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
150 #define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); }
209 struct match *m = &mv; in matcher() local
287 m->g = g; in matcher()
288 m->eflags = eflags; in matcher()
289 m->pmatch = NULL; in matcher()
290 m->lastpos = NULL; in matcher()
291 m->offp = string; in matcher()
292 m->beginp = start; in matcher()
293 m->endp = stop; in matcher()
294 STATESETUP(m, 4); in matcher()
295 SETUP(m->st); in matcher()
296 SETUP(m->fresh); in matcher()
297 SETUP(m->tmp); in matcher()
298 SETUP(m->empty); in matcher()
299 CLEAR(m->empty); in matcher()
300 ZAPSTATE(&m->mbs); in matcher()
311 SP("mloop", m->st, *start); in matcher()
315 endp = walk(m, start, stop, gf, gl, true); in matcher()
324 assert(m->coldp != NULL); in matcher()
327 endp = walk(m, m->coldp, stop, gf, gl, false); in matcher()
330 assert(m->coldp < m->endp); in matcher()
331 m->coldp += XMBRTOWC(NULL, m->coldp, in matcher()
332 (size_t)(m->endp - m->coldp), &m->mbs, 0); in matcher()
338 if (m->pmatch == NULL) in matcher()
339 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * in matcher()
341 if (m->pmatch == NULL) { in matcher()
345 for (i = 1; i <= m->g->nsub; i++) in matcher()
346 m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; in matcher()
347 if (!g->backrefs && !(m->eflags®_BACKR)) { in matcher()
349 dp = dissect(m, m->coldp, endp, gf, gl); in matcher()
351 if (g->nplus > 0 && m->lastpos == NULL) in matcher()
352 m->lastpos = malloc((g->nplus+1) * in matcher()
354 if (g->nplus > 0 && m->lastpos == NULL) { in matcher()
359 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
366 assert(g->nplus == 0 || m->lastpos != NULL); in matcher()
368 if (dp != NULL || endp <= m->coldp) in matcher()
371 endp = walk(m, m->coldp, endp-1, gf, gl, false); in matcher()
376 for (i = 1; i <= m->g->nsub; i++) { in matcher()
377 assert(m->pmatch[i].rm_so == (regoff_t)-1); in matcher()
378 assert(m->pmatch[i].rm_eo == (regoff_t)-1); in matcher()
382 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
391 start = m->coldp + XMBRTOWC(NULL, m->coldp, in matcher()
392 (size_t)(stop - m->coldp), &m->mbs, 0); in matcher()
399 pmatch[0].rm_so = m->coldp - m->offp; in matcher()
400 pmatch[0].rm_eo = endp - m->offp; in matcher()
403 assert(m->pmatch != NULL); in matcher()
405 if (i <= m->g->nsub) in matcher()
406 pmatch[i] = m->pmatch[i]; in matcher()
414 if (m->pmatch != NULL) { in matcher()
415 free(m->pmatch); in matcher()
416 m->pmatch = NULL; in matcher()
418 if (m->lastpos != NULL) { in matcher()
419 free(__UNCONST(m->lastpos)); in matcher()
420 m->lastpos = NULL; in matcher()
422 STATETEARDOWN(m); in matcher()
433 struct match *m, in dissect() argument
453 _DIAGASSERT(m != NULL); in dissect()
462 switch (OP(m->g->strip[es])) { in dissect()
465 es += OPND(m->g->strip[es]); in dissect()
468 while (OP(m->g->strip[es]) != O_CH) in dissect()
469 es += OPND(m->g->strip[es]); in dissect()
475 switch (OP(m->g->strip[ss])) { in dissect()
481 &m->mbs, 0); in dissect()
495 &m->mbs, 0); in dissect()
506 rest = walk(m, sp, stp, ss, es, false); in dissect()
509 tail = walk(m, rest, stop, es, stopst, false); in dissect()
519 if (walk(m, sp, rest, ssub, esub, false) != NULL) { in dissect()
520 dp = dissect(m, sp, rest, ssub, esub); in dissect()
530 rest = walk(m, sp, stp, ss, es, false); in dissect()
533 tail = walk(m, rest, stop, es, stopst, false); in dissect()
545 sep = walk(m, ssp, rest, ssub, esub, false); in dissect()
557 assert(walk(m, ssp, sep, ssub, esub, false) == rest); in dissect()
558 dp = dissect(m, ssp, sep, ssub, esub); in dissect()
566 rest = walk(m, sp, stp, ss, es, false); in dissect()
569 tail = walk(m, rest, stop, es, stopst, false); in dissect()
577 esub = ss + OPND(m->g->strip[ss]) - 1; in dissect()
578 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
580 if (walk(m, sp, rest, ssub, esub, false) == rest) in dissect()
583 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
585 assert(OP(m->g->strip[esub]) == OOR2); in dissect()
587 esub += OPND(m->g->strip[esub]); in dissect()
588 if (OP(m->g->strip[esub]) == OOR2) in dissect()
591 assert(OP(m->g->strip[esub]) == O_CH); in dissect()
593 dp = dissect(m, sp, rest, ssub, esub); in dissect()
605 i = OPND(m->g->strip[ss]); in dissect()
606 assert(0 < i && i <= m->g->nsub); in dissect()
607 m->pmatch[i].rm_so = sp - m->offp; in dissect()
610 i = OPND(m->g->strip[ss]); in dissect()
611 assert(0 < i && i <= m->g->nsub); in dissect()
612 m->pmatch[i].rm_eo = sp - m->offp; in dissect()
624 #define ISBOW(m, sp) \ argument
625 (sp < m->endp && ISWORD(*sp) && \
626 ((sp == m->beginp && !(m->eflags®_NOTBOL)) || \
627 (sp > m->offp && !ISWORD(*(sp-1)))))
628 #define ISEOW(m, sp) \ argument
629 (((sp == m->endp && !(m->eflags®_NOTEOL)) || \
630 (sp < m->endp && *sp == '\n' && \
631 (m->g->cflags®_NEWLINE)) || \
632 (sp < m->endp && !ISWORD(*sp)) ) && \
633 (sp > m->beginp && ISWORD(*(sp-1)))) \
642 struct match *m, in backref() argument
664 _DIAGASSERT(m != NULL); in backref()
674 switch (OP(s = m->g->strip[ss])) { in backref()
679 &m->mbs, BADCHAR); in backref()
687 &m->mbs, BADCHAR); in backref()
694 cs = &m->g->sets[OPND(s)]; in backref()
696 &m->mbs, BADCHAR); in backref()
701 if (sp == m->beginp && (m->eflags & REG_NOTBOL) == 0) in backref()
707 if (sp == m->endp && (m->eflags & REG_NOTEOL) == 0) in backref()
713 if ((sp == m->beginp && !(m->eflags®_NOTBOL)) || in backref()
714 (sp > m->offp && sp < m->endp && in backref()
715 *(sp-1) == '\n' && (m->g->cflags®_NEWLINE))) in backref()
721 if ( (sp == m->endp && !(m->eflags®_NOTEOL)) || in backref()
722 (sp < m->endp && *sp == '\n' && in backref()
723 (m->g->cflags®_NEWLINE)) ) in backref()
729 if (ISBOW(m, sp) || ISEOW(m, sp)) in backref()
735 if (((sp == m->beginp) && !ISWORD(*sp)) || in backref()
736 (sp == m->endp && !ISWORD(*(sp - 1)))) in backref()
744 if (ISBOW(m, sp)) in backref()
750 if (ISEOW(m, sp)) in backref()
759 s = m->g->strip[ss]; in backref()
763 } while (OP(s = m->g->strip[ss]) != O_CH); in backref()
779 s = m->g->strip[ss]; in backref()
783 assert(0 < i && i <= m->g->nsub); in backref()
784 if (m->pmatch[i].rm_eo == -1) in backref()
786 assert(m->pmatch[i].rm_so != -1); in backref()
787 len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; in backref()
790 assert(stop - m->beginp >= len); in backref()
793 ssp = m->offp + m->pmatch[i].rm_so; in backref()
796 while (m->g->strip[ss] != SOP(O_BACK, i)) in backref()
798 return(backref(m, sp+len, stop, ss+1, stopst, lev, rec)); in backref()
800 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
803 return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec)); in backref()
805 assert(m->lastpos != NULL); in backref()
806 assert(lev+1 <= m->g->nplus); in backref()
807 m->lastpos[lev+1] = sp; in backref()
808 return(backref(m, sp, stop, ss+1, stopst, lev+1, rec)); in backref()
810 if (sp == m->lastpos[lev]) /* last pass matched null */ in backref()
811 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
813 m->lastpos[lev] = sp; in backref()
814 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec); in backref()
816 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
822 assert(OP(m->g->strip[esub]) == OOR1); in backref()
824 dp = backref(m, sp, stop, ssub, esub, lev, rec); in backref()
828 if (OP(m->g->strip[esub]) == O_CH) in backref()
831 assert(OP(m->g->strip[esub]) == OOR2); in backref()
833 esub += OPND(m->g->strip[esub]); in backref()
834 if (OP(m->g->strip[esub]) == OOR2) in backref()
837 assert(OP(m->g->strip[esub]) == O_CH); in backref()
843 assert(0 < i && i <= m->g->nsub); in backref()
844 offsave = m->pmatch[i].rm_so; in backref()
845 m->pmatch[i].rm_so = sp - m->offp; in backref()
846 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
849 m->pmatch[i].rm_so = offsave; in backref()
853 assert(0 < i && i <= m->g->nsub); in backref()
854 offsave = m->pmatch[i].rm_eo; in backref()
855 m->pmatch[i].rm_eo = sp - m->offp; in backref()
856 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
859 m->pmatch[i].rm_eo = offsave; in backref()
878 walk(struct match *m, const char *start, const char *stop, sopno startst, in walk() argument
881 states st = m->st; in walk()
882 states fresh = m->fresh; in walk()
883 states empty = m->empty; in walk()
884 states tmp = m->tmp; in walk()
893 _DIAGASSERT(m != NULL); in walk()
902 st = step(m->g, startst, stopst, st, NOTHING, st, sflags); in walk()
906 if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL))) in walk()
920 if (p == m->endp) { in walk()
924 clen = XMBRTOWC(&c, p, (size_t)(m->endp - p), in walk()
925 &m->mbs, BADCHAR); in walk()
933 if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || in walk()
934 (lastc == OUT && !(m->eflags®_NOTBOL)) ) { in walk()
936 i = m->g->nbol; in walk()
938 if ( (c == '\n' && m->g->cflags®_NEWLINE) || in walk()
939 (c == OUT && !(m->eflags®_NOTEOL)) ) { in walk()
941 i += m->g->neol; in walk()
943 if (lastc == OUT && (m->eflags & REG_NOTBOL) == 0) { in walk()
948 if (c == OUT && (m->eflags & REG_NOTEOL) == 0) { in walk()
955 st = step(m->g, startst, stopst, st, flagch, st, in walk()
970 st = step(m->g, startst, stopst, st, flagch, st, sflags); in walk()
981 st = step(m->g, startst, stopst, st, flagch, st, sflags); in walk()
1002 st = step(m->g, startst, stopst, tmp, c, st, sflags); in walk()
1004 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st, sflags), in walk()
1011 m->coldp = matchp; in walk()
1014 &m->mbs, 0)); in walk()
1175 print(struct match *m, in print() argument
1181 struct re_guts *g = m->g; in print()
1185 _DIAGASSERT(m != NULL); in print()
1188 if (!(m->eflags®_TRACE)) in print()
1212 at( struct match *m, in at() argument
1220 _DIAGASSERT(m != NULL); in at()
1225 if (!(m->eflags®_TRACE)) in at()