Lines Matching refs:g

116 	struct re_guts *g;  member
159 static int isinsets(struct re_guts *g, int c);
160 static int samesets(struct re_guts *g, int c1, int c2);
161 static void categorize(struct parse *p, struct re_guts *g);
167 static void stripsnug(struct parse *p, struct re_guts *g);
168 static void findmust(struct parse *p, struct re_guts *g);
169 static sopno pluscount(struct parse *p, struct re_guts *g);
216 ((p)->ncsalloc / CHAR_BIT * (p)->g->csetsize + \
240 struct re_guts *g; in regcomp() local
265 g = malloc(sizeof(struct re_guts) + (NC - 1) * sizeof(cat_t)); in regcomp()
266 if (g == NULL) in regcomp()
272 free(g); in regcomp()
277 p->g = g; in regcomp()
286 g->csetsize = NC; in regcomp()
287 g->sets = NULL; in regcomp()
288 g->setbits = NULL; in regcomp()
289 g->ncsets = 0; in regcomp()
290 g->cflags = cflags; in regcomp()
291 g->iflags = 0; in regcomp()
292 g->nbol = 0; in regcomp()
293 g->neol = 0; in regcomp()
294 g->must = NULL; in regcomp()
295 g->mlen = 0; in regcomp()
296 g->nsub = 0; in regcomp()
297 g->ncategories = 1; /* category 0 is "everything else" */ in regcomp()
298 g->categories = &g->catspace[-(CHAR_MIN)]; in regcomp()
299 (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); in regcomp()
300 g->backrefs = 0; in regcomp()
304 g->firststate = THERE(); in regcomp()
312 g->laststate = THERE(); in regcomp()
315 categorize(p, g); in regcomp()
316 stripsnug(p, g); in regcomp()
317 findmust(p, g); in regcomp()
318 g->nplus = pluscount(p, g); in regcomp()
319 g->magic = MAGIC2; in regcomp()
320 preg->re_nsub = g->nsub; in regcomp()
321 preg->re_g = g; in regcomp()
325 if (g->iflags&BAD) in regcomp()
414 p->g->nsub++; in p_ere_exp()
415 subno = p->g->nsub; in p_ere_exp()
442 p->g->iflags |= USEBOL; in p_ere_exp()
443 p->g->nbol++; in p_ere_exp()
448 p->g->iflags |= USEEOL; in p_ere_exp()
449 p->g->neol++; in p_ere_exp()
460 if (p->g->cflags&REG_NEWLINE) in p_ere_exp()
593 p->g->iflags |= USEBOL; in p_bre()
594 p->g->nbol++; in p_bre()
603 p->g->iflags |= USEEOL; in p_bre()
604 p->g->neol++; in p_bre()
639 if (p->g->cflags&REG_NEWLINE) in p_simp_re()
651 p->g->nsub++; in p_simp_re()
652 subno = p->g->nsub; in p_simp_re()
682 assert(i <= p->g->nsub); in p_simp_re()
691 p->g->backrefs = 1; in p_simp_re()
802 if (p->g->cflags&REG_ICASE) { in p_bracket()
806 for (i = p->g->csetsize - 1; i >= 0; i--) in p_bracket()
818 for (i = p->g->csetsize - 1; i >= 0; i--) in p_bracket()
823 if (p->g->cflags&REG_NEWLINE) in p_bracket()
1085 cap = p->g->categories; in ordinary()
1086 if ((p->g->cflags & REG_ICASE) && isalpha(uc) && othercase(uc) != uc) in ordinary()
1092 p->g->ncategories + 1)); in ordinary()
1093 cap[uc] = (unsigned char)p->g->ncategories++; in ordinary()
1246 no = p->g->ncsets++; in allocset()
1247 css = (size_t)p->g->csetsize; in allocset()
1255 if (reallocarr(&p->g->sets, nc, sizeof(cset))) in allocset()
1257 old_ptr = p->g->setbits; in allocset()
1258 if (reallocarr(&p->g->setbits, nc / CHAR_BIT, css)) { in allocset()
1262 if (old_ptr != p->g->setbits) { in allocset()
1264 p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); in allocset()
1266 (void) memset((char *)p->g->setbits + (nbytes - css), 0, css); in allocset()
1269 cs = &p->g->sets[no]; in allocset()
1270 cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); in allocset()
1300 top = &p->g->sets[p->g->ncsets]; in freeset()
1301 css = (size_t)p->g->csetsize; in freeset()
1306 p->g->ncsets--; in freeset()
1334 top = &p->g->sets[p->g->ncsets]; in freezeset()
1335 css = (size_t)p->g->csetsize; in freezeset()
1338 for (cs2 = &p->g->sets[0]; cs2 < top; cs2++) in freezeset()
1353 return (sopno)(cs - p->g->sets); in freezeset()
1371 css = (size_t)p->g->csetsize; in firstch()
1396 css = (size_t)p->g->csetsize; in nch()
1556 struct re_guts *g, in isinsets() argument
1564 _DIAGASSERT(g != NULL); in isinsets()
1566 if (g->setbits == NULL) in isinsets()
1569 ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; in isinsets()
1571 for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) in isinsets()
1583 struct re_guts *g, in samesets() argument
1593 _DIAGASSERT(g != NULL); in samesets()
1595 ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; in samesets()
1597 for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) in samesets()
1610 struct re_guts *g) in categorize() argument
1618 _DIAGASSERT(g != NULL); in categorize()
1620 cats = g->categories; in categorize()
1627 if (cats[c] == 0 && isinsets(g, c)) { in categorize()
1629 g->ncategories + 1)); in categorize()
1630 cat = g->ncategories++; in categorize()
1633 if (cats[c2] == 0 && samesets(g, c, c2)) in categorize()
1787 struct re_guts *g) in stripsnug() argument
1791 _DIAGASSERT(g != NULL); in stripsnug()
1793 g->nstates = p->slen; in stripsnug()
1794 g->strip = p->strip; in stripsnug()
1795 reallocarr(&g->strip, p->slen, sizeof(sop)); in stripsnug()
1812 struct re_guts *g) in findmust() argument
1823 _DIAGASSERT(g != NULL); in findmust()
1831 scan = g->strip + 1; in findmust()
1853 g->iflags |= BAD; in findmust()
1859 if (newlen > g->mlen) { /* ends one */ in findmust()
1861 g->mlen = newlen; in findmust()
1869 g->mlen = 0; in findmust()
1871 if (g->mlen == 0) /* there isn't one */ in findmust()
1875 g->must = malloc((size_t)g->mlen + 1); in findmust()
1876 if (g->must == NULL) { /* argh; just forget it */ in findmust()
1877 g->mlen = 0; in findmust()
1880 cp = g->must; in findmust()
1882 for (i = g->mlen; i > 0; i--) { in findmust()
1885 assert(cp < g->must + g->mlen); in findmust()
1888 assert(cp == g->must + g->mlen); in findmust()
1899 struct re_guts *g) in pluscount() argument
1907 _DIAGASSERT(g != NULL); in pluscount()
1912 scan = g->strip + 1; in pluscount()
1927 g->iflags |= BAD; in pluscount()