Lines Matching refs:m
51 #define SP(t, s, c) print(m, t, s, c, stdout)
52 #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
53 #define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); }
76 register struct match *m = &mv; local
107 m->g = g;
108 m->eflags = eflags;
109 m->pmatch = NULL;
110 m->lastpos = NULL;
111 m->offp = string;
112 m->beginp = start;
113 m->endp = stop;
114 STATESETUP(m, 4);
115 SETUP(m->st);
116 SETUP(m->fresh);
117 SETUP(m->tmp);
118 SETUP(m->empty);
119 CLEAR(m->empty);
123 endp = fast(m, start, stop, gf, gl);
125 STATETEARDOWN(m);
132 assert(m->coldp != NULL);
135 endp = slow(m, m->coldp, stop, gf, gl);
138 assert(m->coldp < m->endp);
139 m->coldp++;
145 if (m->pmatch == NULL)
146 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
148 if (m->pmatch == NULL) {
149 STATETEARDOWN(m);
152 for (i = 1; i <= m->g->nsub; i++)
153 m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
154 if (!g->backrefs && !(m->eflags®_BACKR)) {
156 dp = dissect(m, m->coldp, endp, gf, gl);
158 if (g->nplus > 0 && m->lastpos == NULL)
159 m->lastpos = (unsigned char **)malloc((g->nplus+1) *
161 if (g->nplus > 0 && m->lastpos == NULL) {
162 free((char *)m->pmatch);
163 STATETEARDOWN(m);
167 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
174 assert(g->nplus == 0 || m->lastpos != NULL);
176 if (dp != NULL || endp <= m->coldp)
179 endp = slow(m, m->coldp, endp-1, gf, gl);
184 for (i = 1; i <= m->g->nsub; i++) {
185 assert(m->pmatch[i].rm_so == -1);
186 assert(m->pmatch[i].rm_eo == -1);
190 dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
198 start = m->coldp + 1; /* recycle starting later */
204 pmatch[0].rm_so = m->coldp - m->offp;
205 pmatch[0].rm_eo = endp - m->offp;
208 assert(m->pmatch != NULL);
210 if (i <= m->g->nsub)
211 pmatch[i] = m->pmatch[i];
218 if (m->pmatch != NULL)
219 free((char *)m->pmatch);
220 if (m->lastpos != NULL)
221 free((char *)m->lastpos);
222 STATETEARDOWN(m);
232 dissect(m, start, stop, startst, stopst) in dissect() argument
233 register struct match *m; in dissect()
258 switch (OP(m->g->strip[es])) {
261 es += OPND(m->g->strip[es]);
264 while (OP(m->g->strip[es]) != O_CH)
265 es += OPND(m->g->strip[es]);
271 switch (OP(m->g->strip[ss])) {
296 rest = slow(m, sp, stp, ss, es);
299 tail = slow(m, rest, stop, es, stopst);
309 if (slow(m, sp, rest, ssub, esub) != NULL) {
310 dp = dissect(m, sp, rest, ssub, esub);
320 rest = slow(m, sp, stp, ss, es);
323 tail = slow(m, rest, stop, es, stopst);
335 sep = slow(m, ssp, rest, ssub, esub);
347 assert(slow(m, ssp, sep, ssub, esub) == rest);
348 dp = dissect(m, ssp, sep, ssub, esub);
356 rest = slow(m, sp, stp, ss, es);
359 tail = slow(m, rest, stop, es, stopst);
367 esub = ss + OPND(m->g->strip[ss]) - 1;
368 assert(OP(m->g->strip[esub]) == OOR1);
370 if (slow(m, sp, rest, ssub, esub) == rest)
373 assert(OP(m->g->strip[esub]) == OOR1);
375 assert(OP(m->g->strip[esub]) == OOR2);
377 esub += OPND(m->g->strip[esub]);
378 if (OP(m->g->strip[esub]) == OOR2)
381 assert(OP(m->g->strip[esub]) == O_CH);
383 dp = dissect(m, sp, rest, ssub, esub);
395 i = OPND(m->g->strip[ss]);
396 assert(0 < i && i <= m->g->nsub);
397 m->pmatch[i].rm_so = sp - m->offp;
400 i = OPND(m->g->strip[ss]);
401 assert(0 < i && i <= m->g->nsub);
402 m->pmatch[i].rm_eo = sp - m->offp;
420 backref(m, start, stop, startst, stopst, lev) in backref() argument
421 register struct match *m; in backref()
447 switch (OP(s = m->g->strip[ss])) {
458 cs = &m->g->sets[OPND(s)];
463 if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
464 (sp < m->endp && *(sp-1) == '\n' &&
465 (m->g->cflags®_NEWLINE)) )
471 if ( (sp == m->endp && !(m->eflags®_NOTEOL)) ||
472 (sp < m->endp && *sp == '\n' &&
473 (m->g->cflags®_NEWLINE)) )
479 if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
480 (sp < m->endp && *(sp-1) == '\n' &&
481 (m->g->cflags®_NEWLINE)) ||
482 (sp > m->beginp &&
484 (sp < m->endp && ISWORD(*sp)) )
490 if (( (sp == m->endp && !(m->eflags®_NOTEOL)) ||
491 (sp < m->endp && *sp == '\n' &&
492 (m->g->cflags®_NEWLINE)) ||
493 (sp < m->endp && !ISWORD(*sp)) ) &&
494 (sp > m->beginp && ISWORD(*(sp-1))) )
503 s = m->g->strip[ss];
507 } while (OP(s = m->g->strip[ss]) != O_CH);
523 s = m->g->strip[ss];
527 assert(0 < i && i <= m->g->nsub);
528 if (m->pmatch[i].rm_eo == -1)
530 assert(m->pmatch[i].rm_so != -1);
531 len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
532 assert(stop - m->beginp >= len);
535 ssp = m->offp + m->pmatch[i].rm_so;
538 while (m->g->strip[ss] != SOP(O_BACK, i))
540 return(backref(m, sp+len, stop, ss+1, stopst, lev));
543 dp = backref(m, sp, stop, ss+1, stopst, lev);
546 return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));
549 assert(m->lastpos != NULL);
550 assert(lev+1 <= m->g->nplus);
551 m->lastpos[lev+1] = sp;
552 return(backref(m, sp, stop, ss+1, stopst, lev+1));
555 if (sp == m->lastpos[lev]) /* last pass matched null */
556 return(backref(m, sp, stop, ss+1, stopst, lev-1));
558 m->lastpos[lev] = sp;
559 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);
561 return(backref(m, sp, stop, ss+1, stopst, lev-1));
568 assert(OP(m->g->strip[esub]) == OOR1);
570 dp = backref(m, sp, stop, ssub, esub, lev);
574 if (OP(m->g->strip[esub]) == O_CH)
577 assert(OP(m->g->strip[esub]) == OOR2);
579 esub += OPND(m->g->strip[esub]);
580 if (OP(m->g->strip[esub]) == OOR2)
583 assert(OP(m->g->strip[esub]) == O_CH);
588 assert(0 < i && i <= m->g->nsub);
589 offsave = m->pmatch[i].rm_so;
590 m->pmatch[i].rm_so = sp - m->offp;
591 dp = backref(m, sp, stop, ss+1, stopst, lev);
594 m->pmatch[i].rm_so = offsave;
599 assert(0 < i && i <= m->g->nsub);
600 offsave = m->pmatch[i].rm_eo;
601 m->pmatch[i].rm_eo = sp - m->offp;
602 dp = backref(m, sp, stop, ss+1, stopst, lev);
605 m->pmatch[i].rm_eo = offsave;
625 fast(m, start, stop, startst, stopst) in fast() argument
626 register struct match *m; in fast()
632 register states st = m->st;
633 register states fresh = m->fresh;
634 register states tmp = m->tmp;
636 register int c = (start == m->beginp) ? OUT : *(start-1);
644 st = step(m->g, startst, stopst, st, NOTHING, st);
651 c = (p == m->endp) ? OUT : *p;
658 if ( (lastc == '\n' && m->g->cflags®_NEWLINE) ||
659 (lastc == OUT && !(m->eflags®_NOTBOL)) ) {
661 i = m->g->nbol;
663 if ( (c == '\n' && m->g->cflags®_NEWLINE) ||
664 (c == OUT && !(m->eflags®_NOTEOL)) ) {
666 i += m->g->neol;
670 st = step(m->g, startst, stopst, st, flagch, st);
684 st = step(m->g, startst, stopst, st, flagch, st);
696 st = step(m->g, startst, stopst, tmp, c, st);
698 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
703 m->coldp = coldp;
716 slow(m, start, stop, startst, stopst) in slow() argument
717 register struct match *m; in slow()
723 register states st = m->st;
724 register states empty = m->empty;
725 register states tmp = m->tmp;
727 register int c = (start == m->beginp) ? OUT : *(start-1);
737 st = step(m->g, startst, stopst, st, NOTHING, st);
742 c = (p == m->endp) ? OUT : *p;
747 if ( (lastc == '\n' && m->g->cflags®_NEWLINE) ||
748 (lastc == OUT && !(m->eflags®_NOTBOL)) ) {
750 i = m->g->nbol;
752 if ( (c == '\n' && m->g->cflags®_NEWLINE) ||
753 (c == OUT && !(m->eflags®_NOTEOL)) ) {
755 i += m->g->neol;
759 st = step(m->g, startst, stopst, st, flagch, st);
773 st = step(m->g, startst, stopst, st, flagch, st);
787 st = step(m->g, startst, stopst, tmp, c, st);
789 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
934 print(m, caption, st, ch, d) in print() argument
935 struct match *m; in print()
941 register struct re_guts *g = m->g;
945 if (!(m->eflags®_TRACE))
967 at(m, title, start, stop, startst, stopst) in at() argument
968 struct match *m; in at()
975 if (!(m->eflags®_TRACE))