Lines Matching +full:1 +full:g
14 * 1. Redistributions of source code must retain the above copyright
70 struct re_guts *g; member
72 regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
77 const RCHAR_T **lastpos; /* [nplus+1] */
91 static int matcher(struct re_guts *g, const RCHAR_T *string, size_t nmatch, regmatch_t pmatch[], in…
96 static states step(struct re_guts *g, sopno start, sopno stop, states bef, int flag, RCHAR_T ch, st…
97 #define BOL (1)
98 #define EOL (BOL+1)
132 matcher(struct re_guts *g, const RCHAR_T *string, size_t nmatch, in matcher() argument
140 const sopno gf = g->firststate+1; /* +1 for OEND */ in matcher()
141 const sopno gl = g->laststate; in matcher()
146 if (g->cflags®_NOSUB) in matcher()
159 if (g->must != NULL) { in matcher()
161 if (*dp == g->must[0] && (size_t)(stop - dp) >= g->mlen && in matcher()
162 MEMCMP(dp, g->must, g->mlen) == 0) in matcher()
164 if (dp == stop) /* we didn't find g->must */ in matcher()
169 m->g = g; in matcher()
190 if (nmatch == 0 && !g->backrefs) in matcher()
203 if (nmatch == 1 && !g->backrefs) in matcher()
208 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * in matcher()
214 for (i = 1; i <= m->g->nsub; i++) in matcher()
215 m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; in matcher()
216 if (!g->backrefs && !(m->eflags®_BACKR)) { in matcher()
220 if (g->nplus > 0 && m->lastpos == NULL) in matcher()
221 m->lastpos = (const RCHAR_T **)malloc((g->nplus+1) * in matcher()
223 if (g->nplus > 0 && m->lastpos == NULL) { in matcher()
235 assert(g->backrefs); /* must be back references doing it */ in matcher()
236 assert(g->nplus == 0 || m->lastpos != NULL); in matcher()
241 endp = slow(m, m->coldp, endp-1, gf, gl); in matcher()
246 for (i = 1; i <= m->g->nsub; i++) { in matcher()
247 assert(m->pmatch[i].rm_so == -1); in matcher()
248 assert(m->pmatch[i].rm_eo == -1); in matcher()
260 start = m->coldp + 1; /* recycle starting later */ in matcher()
269 if (nmatch > 1) { in matcher()
271 for (i = 1; i < nmatch; i++) in matcher()
272 if (i <= m->g->nsub) in matcher()
275 pmatch[i].rm_so = -1; in matcher()
276 pmatch[i].rm_eo = -1; in matcher()
314 switch (m->g->strip[es]) { in dissect()
317 es += m->g->stripdata[es]; in dissect()
320 while (m->g->strip[es] != O_CH) in dissect()
321 es += m->g->stripdata[es]; in dissect()
327 switch (m->g->strip[ss]) { in dissect()
359 stp = rest - 1; in dissect()
362 ssub = ss + 1; in dissect()
363 esub = es - 1; in dissect()
383 stp = rest - 1; in dissect()
386 ssub = ss + 1; in dissect()
387 esub = es - 1; in dissect()
419 stp = rest - 1; in dissect()
422 ssub = ss + 1; in dissect()
423 esub = ss + m->g->stripdata[ss] - 1; in dissect()
424 assert(m->g->strip[esub] == OOR1); in dissect()
429 assert(m->g->strip[esub] == OOR1); in dissect()
431 assert(m->g->strip[esub] == OOR2); in dissect()
432 ssub = esub + 1; in dissect()
433 esub += m->g->stripdata[esub]; in dissect()
434 if (m->g->strip[esub] == OOR2) in dissect()
437 assert(m->g->strip[esub] == O_CH); in dissect()
451 i = m->g->stripdata[ss]; in dissect()
452 assert(0 < i && i <= m->g->nsub); in dissect()
456 i = m->g->stripdata[ss]; in dissect()
457 assert(0 < i && i <= m->g->nsub); in dissect()
497 s = m->g->strip[ss]; in backref()
498 d = m->g->stripdata[ss]; in backref()
510 cs = &m->g->sets[d]; in backref()
516 (sp < m->endp && *(sp-1) == '\n' && in backref()
517 (m->g->cflags®_NEWLINE)) ) in backref()
525 (m->g->cflags®_NEWLINE)) ) in backref()
532 (sp < m->endp && *(sp-1) == '\n' && in backref()
533 (m->g->cflags®_NEWLINE)) || in backref()
535 !ISWORD(*(sp-1))) ) && in backref()
544 (m->g->cflags®_NEWLINE)) || in backref()
546 (sp > m->beginp && ISWORD(*(sp-1))) ) in backref()
555 s = m->g->strip[ss]; in backref()
556 d = m->g->stripdata[ss]; in backref()
560 s = m->g->strip[ss]; in backref()
561 d = m->g->stripdata[ss]; in backref()
566 hard = 1; in backref()
579 s = m->g->strip[ss]; in backref()
580 d = m->g->stripdata[ss]; in backref()
584 assert(0 < i && i <= m->g->nsub); in backref()
585 if (m->pmatch[i].rm_eo == -1) in backref()
587 assert(m->pmatch[i].rm_so != -1); in backref()
595 while (m->g->strip[ss] != O_BACK || m->g->stripdata[ss] != i) in backref()
597 return(backref(m, sp+len, stop, ss+1, stopst, lev)); in backref()
600 dp = backref(m, sp, stop, ss+1, stopst, lev); in backref()
603 return(backref(m, sp, stop, ss+d+1, stopst, lev)); in backref()
607 assert(lev+1 <= m->g->nplus); in backref()
608 m->lastpos[lev+1] = sp; in backref()
609 return(backref(m, sp, stop, ss+1, stopst, lev+1)); in backref()
613 return(backref(m, sp, stop, ss+1, stopst, lev-1)); in backref()
616 dp = backref(m, sp, stop, ss-d+1, stopst, lev); in backref()
618 return(backref(m, sp, stop, ss+1, stopst, lev-1)); in backref()
623 ssub = ss + 1; in backref()
624 esub = ss + d - 1; in backref()
625 assert(m->g->strip[esub] == OOR1); in backref()
631 if (m->g->strip[esub] == O_CH) in backref()
634 assert(m->g->strip[esub] == OOR2); in backref()
635 ssub = esub + 1; in backref()
636 esub += m->g->stripdata[esub]; in backref()
637 if (m->g->strip[esub] == OOR2) in backref()
640 assert(m->g->strip[esub] == O_CH); in backref()
645 assert(0 < i && i <= m->g->nsub); in backref()
648 dp = backref(m, sp, stop, ss+1, stopst, lev); in backref()
656 assert(0 < i && i <= m->g->nsub); in backref()
659 dp = backref(m, sp, stop, ss+1, stopst, lev); in backref()
687 RCHAR_T c = (start == m->beginp) ? OUT : *(start-1); in fast()
695 st = step(m->g, startst, stopst, st, NOTHING, OUT, st); in fast()
709 if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || in fast()
712 i = m->g->nbol; in fast()
714 if ( (c == '\n' && m->g->cflags®_NEWLINE) || in fast()
717 i += m->g->neol; in fast()
721 st = step(m->g, startst, stopst, st, flag, OUT, st); in fast()
735 st = step(m->g, startst, stopst, st, flag, OUT, st); in fast()
747 st = step(m->g, startst, stopst, tmp, 0, c, st); in fast()
749 assert(EQ(step(m->g, startst, stopst, st, NOTHING, OUT, st), st)); in fast()
756 return(p+1); in fast()
772 RCHAR_T c = (start == m->beginp) ? OUT : *(start-1); in slow()
782 st = step(m->g, startst, stopst, st, NOTHING, OUT, st); in slow()
792 if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || in slow()
795 i = m->g->nbol; in slow()
797 if ( (c == '\n' && m->g->cflags®_NEWLINE) || in slow()
800 i += m->g->neol; in slow()
804 st = step(m->g, startst, stopst, st, flag, OUT, st); in slow()
818 st = step(m->g, startst, stopst, st, flag, OUT, st); in slow()
832 st = step(m->g, startst, stopst, tmp, 0, c, st); in slow()
834 assert(EQ(step(m->g, startst, stopst, st, NOTHING, OUT, st), st)); in slow()
846 step(struct re_guts *g, in step() argument
863 s = g->strip[pc]; in step()
864 d = g->stripdata[pc]; in step()
867 assert(pc == stop-1); in step()
873 FWD(aft, bef, 1); in step()
877 FWD(aft, bef, 1); in step()
881 FWD(aft, bef, 1); in step()
885 FWD(aft, bef, 1); in step()
889 FWD(aft, bef, 1); in step()
893 FWD(aft, bef, 1); in step()
896 cs = &g->sets[d]; in step()
898 FWD(aft, bef, 1); in step()
902 FWD(aft, aft, 1); in step()
905 FWD(aft, aft, 1); in step()
908 FWD(aft, aft, 1); in step()
913 pc -= d + 1; in step()
918 FWD(aft, aft, 1); in step()
922 FWD(aft, aft, 1); in step()
926 FWD(aft, aft, 1); in step()
929 FWD(aft, aft, 1); in step()
930 assert(OP(g->strip[pc+d]) == OOR2); in step()
935 for (look = 1; /**/; look += d) { in step()
936 s = g->strip[pc+look]; in step()
937 d = g->stripdata[pc+look]; in step()
946 FWD(aft, aft, 1); in step()
947 if (g->strip[pc+d] != O_CH) { in step()
948 assert(g->strip[pc+d] == OOR2); in step()
953 FWD(aft, aft, 1); in step()
971 struct re_guts *g = m->g; in print() local
973 int first = 1; in print()
981 for (i = 0; i < g->nstates; i++) in print()