Lines Matching refs:m

110 static const char *walk(struct match *m, const char *start, const char *stop,
139 #define SP(t, s, c) print(m, t, s, c, stdout)
140 #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
141 #define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
191 struct match *m = &mv; in matcher() local
267 m->g = g; in matcher()
268 m->eflags = eflags; in matcher()
269 m->pmatch = NULL; in matcher()
270 m->lastpos = NULL; in matcher()
271 m->offp = string; in matcher()
272 m->beginp = start; in matcher()
273 m->endp = stop; in matcher()
274 STATESETUP(m, 4); in matcher()
275 SETUP(m->st); in matcher()
276 SETUP(m->fresh); in matcher()
277 SETUP(m->tmp); in matcher()
278 SETUP(m->empty); in matcher()
279 CLEAR(m->empty); in matcher()
280 ZAPSTATE(&m->mbs); in matcher()
291 SP("mloop", m->st, *start); in matcher()
295 endp = walk(m, start, stop, gf, gl, true); in matcher()
297 if (m->pmatch != NULL) in matcher()
298 free((char *)m->pmatch); in matcher()
299 if (m->lastpos != NULL) in matcher()
300 free((char *)m->lastpos); in matcher()
301 STATETEARDOWN(m); in matcher()
308 assert(m->coldp != NULL); in matcher()
311 endp = walk(m, m->coldp, stop, gf, gl, false); in matcher()
314 assert(m->coldp < m->endp); in matcher()
315 m->coldp += XMBRTOWC(NULL, m->coldp, in matcher()
316 m->endp - m->coldp, &m->mbs, 0); in matcher()
322 if (m->pmatch == NULL) in matcher()
323 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * in matcher()
325 if (m->pmatch == NULL) { in matcher()
326 STATETEARDOWN(m); in matcher()
329 for (i = 1; i <= m->g->nsub; i++) in matcher()
330 m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; in matcher()
331 if (!g->backrefs && !(m->eflags&REG_BACKR)) { in matcher()
333 dp = dissect(m, m->coldp, endp, gf, gl); in matcher()
335 if (g->nplus > 0 && m->lastpos == NULL) in matcher()
336 m->lastpos = malloc((g->nplus+1) * in matcher()
338 if (g->nplus > 0 && m->lastpos == NULL) { in matcher()
339 free(m->pmatch); in matcher()
340 STATETEARDOWN(m); in matcher()
344 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
351 assert(g->nplus == 0 || m->lastpos != NULL); in matcher()
353 if (dp != NULL || endp <= m->coldp) in matcher()
356 endp = walk(m, m->coldp, endp-1, gf, gl, false); in matcher()
361 for (i = 1; i <= m->g->nsub; i++) { in matcher()
362 assert(m->pmatch[i].rm_so == -1); in matcher()
363 assert(m->pmatch[i].rm_eo == -1); in matcher()
367 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
376 start = m->coldp + XMBRTOWC(NULL, m->coldp, in matcher()
377 stop - m->coldp, &m->mbs, 0); in matcher()
383 pmatch[0].rm_so = m->coldp - m->offp; in matcher()
384 pmatch[0].rm_eo = endp - m->offp; in matcher()
387 assert(m->pmatch != NULL); in matcher()
389 if (i <= m->g->nsub) in matcher()
390 pmatch[i] = m->pmatch[i]; in matcher()
397 if (m->pmatch != NULL) in matcher()
398 free((char *)m->pmatch); in matcher()
399 if (m->lastpos != NULL) in matcher()
400 free((char *)m->lastpos); in matcher()
401 STATETEARDOWN(m); in matcher()
409 dissect(struct match *m, const char *start, const char *stop, sopno startst, in dissect() argument
431 switch (OP(m->g->strip[es])) { in dissect()
434 es += OPND(m->g->strip[es]); in dissect()
437 while (OP(m->g->strip[es]) != (sop)O_CH) in dissect()
438 es += OPND(m->g->strip[es]); in dissect()
444 switch (OP(m->g->strip[ss])) { in dissect()
449 sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0); in dissect()
458 sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0); in dissect()
469 rest = walk(m, sp, stp, ss, es, false); in dissect()
472 tail = walk(m, rest, stop, es, stopst, false); in dissect()
482 if (walk(m, sp, rest, ssub, esub, false) != NULL) { in dissect()
483 dp = dissect(m, sp, rest, ssub, esub); in dissect()
493 rest = walk(m, sp, stp, ss, es, false); in dissect()
496 tail = walk(m, rest, stop, es, stopst, false); in dissect()
508 sep = walk(m, ssp, rest, ssub, esub, false); in dissect()
520 assert(walk(m, ssp, sep, ssub, esub, false) == rest); in dissect()
521 dp = dissect(m, ssp, sep, ssub, esub); in dissect()
529 rest = walk(m, sp, stp, ss, es, false); in dissect()
532 tail = walk(m, rest, stop, es, stopst, false); in dissect()
540 esub = ss + OPND(m->g->strip[ss]) - 1; in dissect()
541 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
543 if (walk(m, sp, rest, ssub, esub, in dissect()
547 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
549 assert(OP(m->g->strip[esub]) == OOR2); in dissect()
551 esub += OPND(m->g->strip[esub]); in dissect()
552 if (OP(m->g->strip[esub]) == (sop)OOR2) in dissect()
555 assert(OP(m->g->strip[esub]) == O_CH); in dissect()
557 dp = dissect(m, sp, rest, ssub, esub); in dissect()
569 i = OPND(m->g->strip[ss]); in dissect()
570 assert(0 < i && i <= m->g->nsub); in dissect()
571 m->pmatch[i].rm_so = sp - m->offp; in dissect()
574 i = OPND(m->g->strip[ss]); in dissect()
575 assert(0 < i && i <= m->g->nsub); in dissect()
576 m->pmatch[i].rm_eo = sp - m->offp; in dissect()
592 backref(struct match *m, const char *start, const char *stop, sopno startst, in backref() argument
616 switch (OP(s = m->g->strip[ss])) { in backref()
620 sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); in backref()
627 sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); in backref()
634 cs = &m->g->sets[OPND(s)]; in backref()
635 sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR); in backref()
640 if ((sp == m->beginp && !(m->eflags&REG_NOTBOL)) || in backref()
641 (sp > m->offp && sp < m->endp && in backref()
642 *(sp-1) == '\n' && (m->g->cflags&REG_NEWLINE))) { in backref()
647 if ((sp == m->endp && !(m->eflags&REG_NOTEOL)) || in backref()
648 (sp < m->endp && *sp == '\n' && in backref()
649 (m->g->cflags&REG_NEWLINE))) { in backref()
654 if (sp < m->endp && ISWORD(*sp) && in backref()
655 ((sp == m->beginp && !(m->eflags&REG_NOTBOL)) || in backref()
656 (sp > m->offp && !ISWORD(*(sp-1))))) { in backref()
661 if (((sp == m->endp && !(m->eflags&REG_NOTEOL)) || in backref()
662 (sp < m->endp && *sp == '\n' && in backref()
663 (m->g->cflags&REG_NEWLINE)) || in backref()
664 (sp < m->endp && !ISWORD(*sp))) && in backref()
665 (sp > m->beginp && ISWORD(*(sp-1)))) { in backref()
673 s = m->g->strip[ss]; in backref()
677 } while (OP(s = m->g->strip[ss]) != (sop)O_CH); in backref()
693 s = m->g->strip[ss]; in backref()
697 assert(0 < i && i <= m->g->nsub); in backref()
698 if (m->pmatch[i].rm_eo == -1) in backref()
700 assert(m->pmatch[i].rm_so != -1); in backref()
701 len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; in backref()
704 assert(stop - m->beginp >= len); in backref()
707 ssp = m->offp + m->pmatch[i].rm_so; in backref()
710 while (m->g->strip[ss] != (sop)SOP(O_BACK, i)) in backref()
712 return (backref(m, sp+len, stop, ss+1, stopst, lev, rec)); in backref()
714 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
717 return (backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec)); in backref()
719 assert(m->lastpos != NULL); in backref()
720 assert(lev+1 <= m->g->nplus); in backref()
721 m->lastpos[lev+1] = sp; in backref()
722 return (backref(m, sp, stop, ss+1, stopst, lev+1, rec)); in backref()
724 if (sp == m->lastpos[lev]) /* last pass matched null */ in backref()
725 return (backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
727 m->lastpos[lev] = sp; in backref()
728 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec); in backref()
730 return (backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
735 assert(OP(m->g->strip[esub]) == OOR1); in backref()
737 dp = backref(m, sp, stop, ssub, esub, lev, rec); in backref()
741 if (OP(m->g->strip[esub]) == (sop)O_CH) in backref()
744 assert(OP(m->g->strip[esub]) == (sop)OOR2); in backref()
746 esub += OPND(m->g->strip[esub]); in backref()
747 if (OP(m->g->strip[esub]) == (sop)OOR2) in backref()
750 assert(OP(m->g->strip[esub]) == O_CH); in backref()
756 assert(0 < i && i <= m->g->nsub); in backref()
757 offsave = m->pmatch[i].rm_so; in backref()
758 m->pmatch[i].rm_so = sp - m->offp; in backref()
759 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
762 m->pmatch[i].rm_so = offsave; in backref()
766 assert(0 < i && i <= m->g->nsub); in backref()
767 offsave = m->pmatch[i].rm_eo; in backref()
768 m->pmatch[i].rm_eo = sp - m->offp; in backref()
769 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
772 m->pmatch[i].rm_eo = offsave; in backref()
789 walk(struct match *m, const char *start, const char *stop, sopno startst, in walk() argument
792 states st = m->st; in walk()
793 states fresh = m->fresh; in walk()
794 states empty = m->empty; in walk()
795 states tmp = m->tmp; in walk()
808 st = step(m->g, startst, stopst, st, NOTHING, st); in walk()
812 if (start == m->offp || (start == m->beginp && !(m->eflags&REG_NOTBOL))) in walk()
825 if (p == m->endp) { in walk()
829 clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR); in walk()
837 if ((lastc == '\n' && m->g->cflags&REG_NEWLINE) || in walk()
838 (lastc == OUT && !(m->eflags&REG_NOTBOL))) { in walk()
840 i = m->g->nbol; in walk()
842 if ((c == '\n' && m->g->cflags&REG_NEWLINE) || in walk()
843 (c == OUT && !(m->eflags&REG_NOTEOL))) { in walk()
845 i += m->g->neol; in walk()
849 st = step(m->g, startst, stopst, st, in walk()
864 st = step(m->g, startst, stopst, st, flagch, st); in walk()
885 st = step(m->g, startst, stopst, tmp, c, st); in walk()
887 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); in walk()
893 m->coldp = matchp; in walk()
895 return (p + XMBRTOWC(NULL, p, stop - p, &m->mbs, 0)); in walk()
1023 print(struct match *m, const char *caption, states st, int ch, FILE *d) in print() argument
1025 struct re_guts *g = m->g; in print()
1029 if (!(m->eflags&REG_TRACE)) in print()
1047 at(struct match *m, const char *title, const char *start, const char *stop, in at() argument
1050 if (!(m->eflags&REG_TRACE)) in at()