• Home
  • Raw
  • Download

Lines Matching refs:m

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)
116 #define NOTE(str) { if (m->eflags&REG_TRACE) (void)printf("=%s\n", (str)); }
134 struct match *m = &mv; in matcher() local
165 m->g = g; in matcher()
166 m->eflags = eflags; in matcher()
167 m->pmatch = NULL; in matcher()
168 m->lastpos = NULL; in matcher()
169 m->offp = string; in matcher()
170 m->beginp = start; in matcher()
171 m->endp = stop; in matcher()
172 STATESETUP(m, 4); in matcher()
173 SETUP(m->st); in matcher()
174 SETUP(m->fresh); in matcher()
175 SETUP(m->tmp); in matcher()
176 SETUP(m->empty); in matcher()
177 CLEAR(m->empty); in matcher()
181 endp = fast(m, start, stop, gf, gl); in matcher()
183 free(m->pmatch); in matcher()
184 free(m->lastpos); in matcher()
185 STATETEARDOWN(m); in matcher()
192 assert(m->coldp != NULL); in matcher()
195 endp = slow(m, m->coldp, stop, gf, gl); in matcher()
198 assert(m->coldp < m->endp); in matcher()
199 m->coldp++; in matcher()
205 if (m->pmatch == NULL) in matcher()
206 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * in matcher()
208 if (m->pmatch == NULL) { in matcher()
209 STATETEARDOWN(m); in matcher()
212 for (i = 1; i <= (int)m->g->nsub; i++) in matcher()
213 m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; in matcher()
214 if (!g->backrefs && !(m->eflags&REG_BACKR)) { in matcher()
216 dp = dissect(m, m->coldp, endp, gf, gl); in matcher()
218 if (g->nplus > 0 && m->lastpos == NULL) in matcher()
219 m->lastpos = (char **)malloc((g->nplus+1) * in matcher()
221 if (g->nplus > 0 && m->lastpos == NULL) { in matcher()
222 free(m->pmatch); in matcher()
223 STATETEARDOWN(m); in matcher()
227 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
234 assert(g->nplus == 0 || m->lastpos != NULL); in matcher()
236 if (dp != NULL || endp <= m->coldp) in matcher()
239 endp = slow(m, m->coldp, endp-1, gf, gl); in matcher()
244 for (i = 1; i <= m->g->nsub; i++) { in matcher()
245 assert(m->pmatch[i].rm_so == -1); in matcher()
246 assert(m->pmatch[i].rm_eo == -1); in matcher()
250 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0); in matcher()
258 if (m->coldp == stop) in matcher()
260 start = m->coldp + 1; /* recycle starting later */ in matcher()
265 pmatch[0].rm_so = m->coldp - m->offp; in matcher()
266 pmatch[0].rm_eo = endp - m->offp; in matcher()
269 assert(m->pmatch != NULL); in matcher()
271 if (i <= (int)m->g->nsub) in matcher()
272 pmatch[i] = m->pmatch[i]; in matcher()
279 if (m->pmatch != NULL) in matcher()
280 free((char *)m->pmatch); in matcher()
281 if (m->lastpos != NULL) in matcher()
282 free((char *)m->lastpos); in matcher()
283 STATETEARDOWN(m); in matcher()
291 dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst) in dissect() argument
312 switch (OP(m->g->strip[es])) { in dissect()
315 es += OPND(m->g->strip[es]); in dissect()
318 while (OP(m->g->strip[es]) != O_CH) in dissect()
319 es += OPND(m->g->strip[es]); in dissect()
325 switch (OP(m->g->strip[ss])) { in dissect()
350 rest = slow(m, sp, stp, ss, es); in dissect()
353 tail = slow(m, rest, stop, es, stopst); in dissect()
363 if (slow(m, sp, rest, ssub, esub) != NULL) { in dissect()
364 dp = dissect(m, sp, rest, ssub, esub); in dissect()
374 rest = slow(m, sp, stp, ss, es); in dissect()
377 tail = slow(m, rest, stop, es, stopst); in dissect()
389 sep = slow(m, ssp, rest, ssub, esub); in dissect()
401 assert(slow(m, ssp, sep, ssub, esub) == rest); in dissect()
402 dp = dissect(m, ssp, sep, ssub, esub); in dissect()
410 rest = slow(m, sp, stp, ss, es); in dissect()
413 tail = slow(m, rest, stop, es, stopst); in dissect()
421 esub = ss + OPND(m->g->strip[ss]) - 1; in dissect()
422 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
424 if (slow(m, sp, rest, ssub, esub) == rest) in dissect()
427 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
429 assert(OP(m->g->strip[esub]) == OOR2); in dissect()
431 esub += OPND(m->g->strip[esub]); in dissect()
432 if (OP(m->g->strip[esub]) == OOR2) in dissect()
435 assert(OP(m->g->strip[esub]) == O_CH); in dissect()
437 dp = dissect(m, sp, rest, ssub, esub); in dissect()
449 i = OPND(m->g->strip[ss]); in dissect()
450 assert(0 < i && i <= m->g->nsub); in dissect()
451 m->pmatch[i].rm_so = sp - m->offp; in dissect()
454 i = OPND(m->g->strip[ss]); in dissect()
455 assert(0 < i && i <= m->g->nsub); in dissect()
456 m->pmatch[i].rm_eo = sp - m->offp; in dissect()
472 backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, in backref() argument
494 switch (OP(s = m->g->strip[ss])) { in backref()
505 cs = &m->g->sets[OPND(s)]; in backref()
510 if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) || in backref()
511 (sp < m->endp && *(sp-1) == '\n' && in backref()
512 (m->g->cflags&REG_NEWLINE)) ) in backref()
518 if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) || in backref()
519 (sp < m->endp && *sp == '\n' && in backref()
520 (m->g->cflags&REG_NEWLINE)) ) in backref()
526 if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) || in backref()
527 (sp < m->endp && *(sp-1) == '\n' && in backref()
528 (m->g->cflags&REG_NEWLINE)) || in backref()
529 (sp > m->beginp && in backref()
531 (sp < m->endp && ISWORD(*sp)) ) in backref()
537 if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) || in backref()
538 (sp < m->endp && *sp == '\n' && in backref()
539 (m->g->cflags&REG_NEWLINE)) || in backref()
540 (sp < m->endp && !ISWORD(*sp)) ) && in backref()
541 (sp > m->beginp && ISWORD(*(sp-1))) ) in backref()
550 s = m->g->strip[ss]; in backref()
554 } while (OP(s = m->g->strip[ss]) != O_CH); in backref()
570 s = m->g->strip[ss]; in backref()
574 assert(0 < i && i <= m->g->nsub); in backref()
575 if (m->pmatch[i].rm_eo == -1) in backref()
577 assert(m->pmatch[i].rm_so != -1); in backref()
578 len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; in backref()
581 assert(stop - m->beginp >= len); in backref()
584 ssp = m->offp + m->pmatch[i].rm_so; in backref()
587 while (m->g->strip[ss] != SOP(O_BACK, i)) in backref()
589 return(backref(m, sp+len, stop, ss+1, stopst, lev, rec)); in backref()
592 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
595 return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec)); in backref()
598 assert(m->lastpos != NULL); in backref()
599 assert(lev+1 <= m->g->nplus); in backref()
600 m->lastpos[lev+1] = sp; in backref()
601 return(backref(m, sp, stop, ss+1, stopst, lev+1, rec)); in backref()
604 if (sp == m->lastpos[lev]) /* last pass matched null */ in backref()
605 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
607 m->lastpos[lev] = sp; in backref()
608 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec); in backref()
610 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
617 assert(OP(m->g->strip[esub]) == OOR1); in backref()
619 dp = backref(m, sp, stop, ssub, esub, lev, rec); in backref()
623 if (OP(m->g->strip[esub]) == O_CH) in backref()
626 assert(OP(m->g->strip[esub]) == OOR2); in backref()
628 esub += OPND(m->g->strip[esub]); in backref()
629 if (OP(m->g->strip[esub]) == OOR2) in backref()
632 assert(OP(m->g->strip[esub]) == O_CH); in backref()
637 assert(0 < i && i <= m->g->nsub); in backref()
638 offsave = m->pmatch[i].rm_so; in backref()
639 m->pmatch[i].rm_so = sp - m->offp; in backref()
640 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
643 m->pmatch[i].rm_so = offsave; in backref()
648 assert(0 < i && i <= m->g->nsub); in backref()
649 offsave = m->pmatch[i].rm_eo; in backref()
650 m->pmatch[i].rm_eo = sp - m->offp; in backref()
651 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
654 m->pmatch[i].rm_eo = offsave; in backref()
672 fast(struct match *m, char *start, char *stop, sopno startst, sopno stopst) in fast() argument
674 states st = m->st; in fast()
675 states fresh = m->fresh; in fast()
676 states tmp = m->tmp; in fast()
678 int c = (start == m->beginp) ? OUT : *(start-1); in fast()
686 st = step(m->g, startst, stopst, st, NOTHING, st); in fast()
693 c = (p == m->endp) ? OUT : *p; in fast()
700 if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) || in fast()
701 (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) { in fast()
703 i = m->g->nbol; in fast()
705 if ( (c == '\n' && m->g->cflags&REG_NEWLINE) || in fast()
706 (c == OUT && !(m->eflags&REG_NOTEOL)) ) { in fast()
708 i += m->g->neol; in fast()
712 st = step(m->g, startst, stopst, st, flagch, st); in fast()
726 st = step(m->g, startst, stopst, st, flagch, st); in fast()
738 st = step(m->g, startst, stopst, tmp, c, st); in fast()
740 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); in fast()
745 m->coldp = coldp; in fast()
756 slow(struct match *m, char *start, char *stop, sopno startst, sopno stopst) in slow() argument
758 states st = m->st; in slow()
759 states empty = m->empty; in slow()
760 states tmp = m->tmp; in slow()
762 int c = (start == m->beginp) ? OUT : *(start-1); in slow()
772 st = step(m->g, startst, stopst, st, NOTHING, st); in slow()
777 c = (p == m->endp) ? OUT : *p; in slow()
782 if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) || in slow()
783 (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) { in slow()
785 i = m->g->nbol; in slow()
787 if ( (c == '\n' && m->g->cflags&REG_NEWLINE) || in slow()
788 (c == OUT && !(m->eflags&REG_NOTEOL)) ) { in slow()
790 i += m->g->neol; in slow()
794 st = step(m->g, startst, stopst, st, flagch, st); in slow()
808 st = step(m->g, startst, stopst, st, flagch, st); in slow()
822 st = step(m->g, startst, stopst, tmp, c, st); in slow()
824 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); in slow()
953 print(struct match *m, char *caption, states st, int ch, FILE *d) in print() argument
955 struct re_guts *g = m->g; in print()
959 if (!(m->eflags&REG_TRACE)) in print()
977 at(struct match *m, char *title, char *start, char *stop, sopno startst, in at() argument
980 if (!(m->eflags&REG_TRACE)) in at()