Lines Matching refs:g
92 struct re_guts *g; member
151 static void stripsnug(struct parse *p, struct re_guts *g);
152 static void findmust(struct parse *p, struct re_guts *g);
154 static void computejumps(struct parse *p, struct re_guts *g);
155 static void computematchjumps(struct parse *p, struct re_guts *g);
156 static sopno pluscount(struct parse *p, struct re_guts *g);
208 struct re_guts *g; in regcomp_internal() local
231 g = (struct re_guts *)malloc(sizeof(struct re_guts)); in regcomp_internal()
232 if (g == NULL) in regcomp_internal()
245 free((char *)g); in regcomp_internal()
254 free((char *)g); in regcomp_internal()
259 p->g = g; in regcomp_internal()
290 g->sets = NULL; in regcomp_internal()
291 g->ncsets = 0; in regcomp_internal()
292 g->cflags = cflags; in regcomp_internal()
293 g->iflags = 0; in regcomp_internal()
294 g->nbol = 0; in regcomp_internal()
295 g->neol = 0; in regcomp_internal()
296 g->must = NULL; in regcomp_internal()
297 g->moffset = -1; in regcomp_internal()
298 g->charjump = NULL; in regcomp_internal()
299 g->matchjump = NULL; in regcomp_internal()
300 g->mlen = 0; in regcomp_internal()
301 g->nsub = 0; in regcomp_internal()
302 g->backrefs = 0; in regcomp_internal()
306 g->firststate = THERE(); in regcomp_internal()
312 g->laststate = THERE(); in regcomp_internal()
315 stripsnug(p, g); in regcomp_internal()
316 findmust(p, g); in regcomp_internal()
320 if(g->mlen > 3) { in regcomp_internal()
321 computejumps(p, g); in regcomp_internal()
322 computematchjumps(p, g); in regcomp_internal()
323 if(g->matchjump == NULL && g->charjump != NULL) { in regcomp_internal()
324 free(&g->charjump[CHAR_MIN]); in regcomp_internal()
325 g->charjump = NULL; in regcomp_internal()
328 g->nplus = pluscount(p, g); in regcomp_internal()
329 g->magic = MAGIC2; in regcomp_internal()
330 preg->re_nsub = g->nsub; in regcomp_internal()
331 preg->re_g = g; in regcomp_internal()
335 if (g->iflags&BAD) in regcomp_internal()
413 p->g->nsub++; in p_ere_exp()
414 subno = p->g->nsub; in p_ere_exp()
441 p->g->iflags |= USEBOL; in p_ere_exp()
442 p->g->nbol++; in p_ere_exp()
447 p->g->iflags |= USEEOL; in p_ere_exp()
448 p->g->neol++; in p_ere_exp()
462 if (p->g->cflags®_NEWLINE) in p_ere_exp()
507 assert(i <= p->g->nsub); in p_ere_exp()
516 p->g->backrefs = 1; in p_ere_exp()
743 p->g->iflags |= USEBOL; in p_bre_pre_parse()
744 p->g->nbol++; in p_bre_pre_parse()
756 p->g->iflags |= USEEOL; in p_bre_post_parse()
757 p->g->neol++; in p_bre_post_parse()
876 if (p->g->cflags®_NEWLINE) in p_simp_re()
894 p->g->nsub++; in p_simp_re()
895 subno = p->g->nsub; in p_simp_re()
927 assert(i <= p->g->nsub); in p_simp_re()
936 p->g->backrefs = 1; in p_simp_re()
1042 if (p->g->cflags®_ICASE) in p_bracket()
1059 if (cs->invert && p->g->cflags®_NEWLINE) in p_bracket()
1066 EMIT(OANYOF, (int)(cs - p->g->sets)); in p_bracket()
1177 if (p->g->cflags®_ICASE)
1197 EMIT(OANYOF, (int)(cs - p->g->sets));
1335 if (!(p->g->cflags®_EXTENDED))
1410 if ((p->g->cflags®_ICASE) && iswalpha(ch) && othercase(ch) != ch)
1422 EMIT(OANYOF, (int)(cs - p->g->sets));
1569 ncs = reallocarray(p->g->sets, p->g->ncsets + 1, sizeof(*ncs));
1574 p->g->sets = ncs;
1575 cs = &p->g->sets[p->g->ncsets++];
1588 cset *top = &p->g->sets[p->g->ncsets];
1595 p->g->ncsets--;
1838 stripsnug(struct parse *p, struct re_guts *g) argument
1840 g->nstates = p->slen;
1841 g->strip = reallocarray((char *)p->strip, p->slen, sizeof(sop));
1842 if (g->strip == NULL) {
1844 g->strip = p->strip;
1859 findmust(struct parse *p, struct re_guts *g) argument
1888 g->moffset = 0;
1889 scan = g->strip + 1;
1917 g->iflags |= BAD;
1933 if (newlen > (sopno)g->mlen) { /* ends one */
1935 g->mlen = newlen;
1937 g->moffset += offset;
1940 g->moffset = offset;
1948 if (newlen > (sopno)g->mlen) { /* ends one */
1950 g->mlen = newlen;
1952 g->moffset += offset;
1955 g->moffset = offset;
1966 if (newlen > (sopno)g->mlen) { /* ends one */
1968 g->mlen = newlen;
1970 g->moffset += offset;
1973 g->moffset = offset;
1989 if (newlen > (sopno)g->mlen) { /* ends one */
1991 g->mlen = newlen;
1993 g->moffset += offset;
1995 g->moffset = offset;
2003 if (g->mlen == 0) { /* there isn't one */
2004 g->moffset = -1;
2009 g->must = malloc((size_t)g->mlen + 1);
2010 if (g->must == NULL) { /* argh; just forget it */
2011 g->mlen = 0;
2012 g->moffset = -1;
2015 cp = g->must;
2018 while (cp < g->must + g->mlen) {
2025 assert(cp == g->must + g->mlen);
2114 computejumps(struct parse *p, struct re_guts *g) argument
2123 g->charjump = (int *)malloc((NC_MAX + 1) * sizeof(int));
2124 if (g->charjump == NULL) /* Not a fatal error */
2127 g->charjump = &g->charjump[-(CHAR_MIN)];
2133 g->charjump[ch] = g->mlen;
2140 for (mindex = 0; mindex < g->mlen; mindex++)
2141 g->charjump[(int)g->must[mindex]] = g->mlen - mindex - 1;
2158 computematchjumps(struct parse *p, struct re_guts *g) argument
2172 pmatches = (int*) malloc(g->mlen * sizeof(int));
2174 g->matchjump = NULL;
2178 g->matchjump = (int*) malloc(g->mlen * sizeof(int));
2179 if (g->matchjump == NULL) { /* Not a fatal error */
2185 for (mindex = 0; mindex < g->mlen; mindex++)
2186 g->matchjump[mindex] = 2*g->mlen - mindex - 1;
2189 for (mindex = g->mlen - 1, suffix = g->mlen; mindex >= 0;
2199 while (suffix < g->mlen
2200 && g->must[mindex] != g->must[suffix]) {
2201 g->matchjump[suffix] = MIN(g->matchjump[suffix],
2202 g->mlen - mindex - 1);
2212 g->matchjump[mindex] = MIN(g->matchjump[mindex],
2213 g->mlen + suffix - mindex);
2216 while (suffix < g->mlen) {
2217 while (suffix <= ssuffix && suffix < g->mlen) {
2218 g->matchjump[suffix] = MIN(g->matchjump[suffix],
2219 g->mlen + ssuffix - suffix);
2222 if (suffix < g->mlen)
2234 pluscount(struct parse *p, struct re_guts *g) argument
2244 scan = g->strip + 1;
2259 g->iflags |= BAD;