Lines Matching +full:1 +full:g

14  * 1. Redistributions of source code must retain the above copyright
81 struct re_guts *g; member
83 regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
88 const char **lastpos; /* [nplus+1] */
103 static int matcher(struct re_guts *g, const char *string, size_t nmatch, regmatch_t pmatch[], int e…
107 static states step(struct re_guts *g, sopno start, sopno stop, states bef, wint_t ch, states aft, i…
109 #define BOL (OUT-1)
110 #define EOL (BOL-1)
159 if (MB_CUR_MAX == 1) in stepback()
164 for (mbc = 1; mbc <= MB_CUR_MAX; mbc++) { in stepback()
169 if (clen != (size_t)-1 && clen != (size_t)-2) in stepback()
182 == static int matcher(struct re_guts *g, const char *string, \
186 matcher(struct re_guts *g, in matcher() argument
197 const sopno gf = g->firststate+1; /* +1 for OEND */ in matcher()
198 const sopno gl = g->laststate; in matcher()
210 if (g->cflags&REG_NOSUB) in matcher()
223 if (g->must != NULL) { in matcher()
224 if (g->charjump != NULL && g->matchjump != NULL) { in matcher()
225 mustfirst = g->must; in matcher()
226 mustlast = g->must + g->mlen - 1; in matcher()
227 charjump = g->charjump; in matcher()
228 matchjump = g->matchjump; in matcher()
230 for (dp = start+g->mlen-1; dp < stop;) { in matcher()
240 * for strings of length 1 in matcher()
257 if (*dp == g->must[0] && in matcher()
258 stop - dp >= g->mlen && in matcher()
259 memcmp(dp, g->must, (size_t)g->mlen) == 0) in matcher()
261 if (dp == stop) /* we didn't find g->must */ in matcher()
267 m->g = g; in matcher()
283 if (dp != NULL && g->moffset > -1) { in matcher()
286 nstart = stepback(start, dp, g->moffset); in matcher()
304 if (nmatch == 0 && !g->backrefs) in matcher()
318 if (nmatch == 1 && !g->backrefs) in matcher()
323 m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * 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()
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()
350 assert(g->backrefs); /* must be back references doing it */ in matcher()
351 assert(g->nplus == 0 || m->lastpos != NULL); 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()
386 if (nmatch > 1) { in matcher()
388 for (i = 1; i < nmatch; i++) in matcher()
389 if (i <= m->g->nsub) in matcher()
392 pmatch[i].rm_so = -1; in matcher()
393 pmatch[i].rm_eo = -1; in matcher()
436 switch (OP(m->g->strip[es])) { in dissect()
439 es += OPND(m->g->strip[es]); in dissect()
442 while (OP(m->g->strip[es]) != (sop)O_CH) in dissect()
443 es += OPND(m->g->strip[es]); in dissect()
449 switch (OP(m->g->strip[ss])) { in dissect()
485 stp = rest - 1; in dissect()
488 ssub = ss + 1; in dissect()
489 esub = es - 1; in dissect()
509 stp = rest - 1; in dissect()
512 ssub = ss + 1; in dissect()
513 esub = es - 1; in dissect()
545 stp = rest - 1; in dissect()
548 ssub = ss + 1; in dissect()
549 esub = ss + OPND(m->g->strip[ss]) - 1; in dissect()
550 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
555 assert(OP(m->g->strip[esub]) == OOR1); in dissect()
557 assert(OP(m->g->strip[esub]) == OOR2); in dissect()
558 ssub = esub + 1; in dissect()
559 esub += OPND(m->g->strip[esub]); in dissect()
560 if (OP(m->g->strip[esub]) == (sop)OOR2) in dissect()
563 assert(OP(m->g->strip[esub]) == O_CH); in dissect()
577 i = OPND(m->g->strip[ss]); in dissect()
578 assert(0 < i && i <= m->g->nsub); in dissect()
582 i = OPND(m->g->strip[ss]); in dissect()
583 assert(0 < i && i <= m->g->nsub); in dissect()
599 (sp > m->offp && !ISWORD(*(sp-1)))))
603 (m->g->cflags&REG_NEWLINE)) || \
605 (sp > m->beginp && ISWORD(*(sp-1)))) \
641 switch (OP(s = m->g->strip[ss])) { in backref()
659 cs = &m->g->sets[OPND(s)]; in backref()
679 *(sp-1) == '\n' && (m->g->cflags&REG_NEWLINE))) in backref()
687 (m->g->cflags&REG_NEWLINE)) ) in backref()
700 (sp == m->endp && !ISWORD(*(sp - 1)))) in backref()
702 else if (ISWORD(*(sp - 1)) == ISWORD(*sp)) in backref()
723 s = m->g->strip[ss]; in backref()
727 } while (OP(s = m->g->strip[ss]) != (sop)O_CH); in backref()
731 hard = 1; in backref()
743 s = m->g->strip[ss]; in backref()
747 assert(0 < i && i <= m->g->nsub); in backref()
748 if (m->pmatch[i].rm_eo == -1) in backref()
750 assert(m->pmatch[i].rm_so != -1); in backref()
760 while (m->g->strip[ss] != (sop)SOP(O_BACK, i)) in backref()
762 return(backref(m, sp+len, stop, ss+1, stopst, lev, rec)); in backref()
764 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
767 return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec)); in backref()
770 assert(lev+1 <= m->g->nplus); in backref()
771 m->lastpos[lev+1] = sp; in backref()
772 return(backref(m, sp, stop, ss+1, stopst, lev+1, rec)); in backref()
775 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
778 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec); in backref()
780 return(backref(m, sp, stop, ss+1, stopst, lev-1, rec)); in backref()
784 ssub = ss + 1; in backref()
785 esub = ss + OPND(s) - 1; in backref()
786 assert(OP(m->g->strip[esub]) == OOR1); in backref()
792 if (OP(m->g->strip[esub]) == (sop)O_CH) in backref()
795 assert(OP(m->g->strip[esub]) == (sop)OOR2); in backref()
796 ssub = esub + 1; in backref()
797 esub += OPND(m->g->strip[esub]); in backref()
798 if (OP(m->g->strip[esub]) == (sop)OOR2) in backref()
801 assert(OP(m->g->strip[esub]) == O_CH); in backref()
807 assert(0 < i && i <= m->g->nsub); in backref()
810 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
817 assert(0 < i && i <= m->g->nsub); in backref()
820 dp = backref(m, sp, stop, ss+1, stopst, lev, rec); in backref()
862 st = step(m->g, startst, stopst, st, NOTHING, st, sflags); in walk()
874 c = (uch)*(start - 1); in walk()
892 if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) || in walk()
895 i = m->g->nbol; in walk()
897 if ( (c == '\n' && m->g->cflags&REG_NEWLINE) || in walk()
900 i += m->g->neol; in walk()
914 st = step(m->g, startst, stopst, st, flagch, st, in walk()
929 st = step(m->g, startst, stopst, st, flagch, st, sflags); in walk()
940 st = step(m->g, startst, stopst, st, flagch, st, sflags); in walk()
961 st = step(m->g, startst, stopst, tmp, c, st, sflags); in walk()
963 assert(EQ(step(m->g, startst, stopst, st, NOTHING, st, sflags), in walk()
981 == static states step(struct re_guts *g, sopno start, sopno stop, \
983 == #define BOL (OUT-1)
984 == #define EOL (BOL-1)
993 step(struct re_guts *g, in step() argument
1009 s = g->strip[pc]; in step()
1012 assert(pc == stop-1); in step()
1018 FWD(aft, bef, 1); in step()
1022 FWD(aft, bef, 1); in step()
1026 FWD(aft, bef, 1); in step()
1030 FWD(aft, bef, 1); in step()
1034 FWD(aft, bef, 1); in step()
1038 FWD(aft, bef, 1); in step()
1042 FWD(aft, bef, 1); in step()
1046 FWD(aft, bef, 1); in step()
1050 FWD(aft, aft, 1); in step()
1054 FWD(aft, bef, 1); in step()
1057 cs = &g->sets[OPND(s)]; in step()
1059 FWD(aft, bef, 1); in step()
1063 FWD(aft, aft, 1); in step()
1066 FWD(aft, aft, 1); in step()
1069 FWD(aft, aft, 1); in step()
1074 pc -= OPND(s) + 1; in step()
1079 FWD(aft, aft, 1); in step()
1083 FWD(aft, aft, 1); in step()
1087 FWD(aft, aft, 1); in step()
1090 FWD(aft, aft, 1); in step()
1091 assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2); in step()
1096 for (look = 1; in step()
1097 OP(s = g->strip[pc+look]) != (sop)O_CH; in step()
1100 FWD(aft, aft, look + 1); in step()
1104 FWD(aft, aft, 1); in step()
1105 if (OP(g->strip[pc+OPND(s)]) != (sop)O_CH) { in step()
1106 assert(OP(g->strip[pc+OPND(s)]) == (sop)OOR2); in step()
1111 FWD(aft, aft, 1); in step()
1137 struct re_guts *g = m->g; in print() local
1139 int first = 1; in print()
1147 for (i = 0; i < g->nstates; i++) in print()