Lines Matching refs:g
69 struct re_guts *g; member
113 static int isinsets(struct re_guts *g, int c);
114 static int samesets(struct re_guts *g, int c1, int c2);
116 static void categorize(struct parse *p, struct re_guts *g);
122 static void stripsnug(struct parse *p, struct re_guts *g);
123 static void findmust(struct parse *p, struct re_guts *g);
124 static sopno pluscount(struct parse *p, struct re_guts *g);
171 ((p)->ncsalloc / CHAR_BIT * (p)->g->csetsize + \
183 struct re_guts *g; in regcomp() local
205 g = (struct re_guts *)malloc(sizeof(struct re_guts) + in regcomp()
207 if (g == NULL) in regcomp()
212 free((char *)g); in regcomp()
218 free((char *)g); in regcomp()
224 p->g = g; in regcomp()
233 g->csetsize = NC; in regcomp()
234 g->sets = NULL; in regcomp()
235 g->setbits = NULL; in regcomp()
236 g->ncsets = 0; in regcomp()
237 g->cflags = cflags; in regcomp()
238 g->iflags = 0; in regcomp()
239 g->nbol = 0; in regcomp()
240 g->neol = 0; in regcomp()
241 g->must = NULL; in regcomp()
242 g->mlen = 0; in regcomp()
243 g->nsub = 0; in regcomp()
245 g->ncategories = 1; /* category 0 is "everything else" */ in regcomp()
246 g->categories = &g->catspace[-(CHAR_MIN)]; in regcomp()
247 memset((char *)g->catspace, 0, NC*sizeof(cat_t)); in regcomp()
249 g->backrefs = 0; in regcomp()
253 g->firststate = THERE(); in regcomp()
261 g->laststate = THERE(); in regcomp()
264 categorize(p, g); in regcomp()
265 stripsnug(p, g); in regcomp()
266 findmust(p, g); in regcomp()
267 g->nplus = pluscount(p, g); in regcomp()
268 g->magic = MAGIC2; in regcomp()
269 preg->re_nsub = g->nsub; in regcomp()
270 preg->re_g = g; in regcomp()
274 if (g->iflags&BAD) in regcomp()
353 p->g->nsub++; in p_ere_exp()
354 subno = p->g->nsub; in p_ere_exp()
381 p->g->iflags |= USEBOL; in p_ere_exp()
382 p->g->nbol++; in p_ere_exp()
387 p->g->iflags |= USEEOL; in p_ere_exp()
388 p->g->neol++; in p_ere_exp()
399 if (p->g->cflags®_NEWLINE) in p_ere_exp()
520 p->g->iflags |= USEBOL; in p_bre()
521 p->g->nbol++; in p_bre()
530 p->g->iflags |= USEEOL; in p_bre()
531 p->g->neol++; in p_bre()
566 p->g->nsub++; in p_simp_re()
567 subno = p->g->nsub; in p_simp_re()
597 assert(i <= p->g->nsub); in p_simp_re()
606 p->g->backrefs = 1; in p_simp_re()
615 if (p->g->cflags®_NEWLINE) in p_simp_re()
724 if (p->g->cflags®_ICASE) { in p_bracket()
728 for (i = p->g->csetsize - 1; i >= 0; i--) in p_bracket()
740 for (i = p->g->csetsize - 1; i >= 0; i--) in p_bracket()
745 if (p->g->cflags®_NEWLINE) in p_bracket()
963 if ((p->g->cflags®_ICASE) && isalpha(ch) && othercase(ch) != ch) in ordinary()
1092 int no = p->g->ncsets++; in allocset()
1096 size_t css = (size_t)p->g->csetsize; in allocset()
1106 if (p->g->sets == NULL) in allocset()
1107 p->g->sets = (cset *)malloc(nc * sizeof(cset)); in allocset()
1109 p->g->sets = (cset *)realloc((char *)p->g->sets, in allocset()
1111 if (p->g->setbits == NULL) in allocset()
1112 p->g->setbits = (uch *)malloc(nbytes); in allocset()
1114 p->g->setbits = (uch *)realloc((char *)p->g->setbits, in allocset()
1118 p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); in allocset()
1120 if (p->g->sets != NULL && p->g->setbits != NULL) in allocset()
1121 memset((char *)p->g->setbits + (nbytes - css), in allocset()
1132 cs = &p->g->sets[no]; in allocset()
1133 cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); in allocset()
1149 cset *top = &p->g->sets[p->g->ncsets]; in freeset()
1150 size_t css = (size_t)p->g->csetsize; in freeset()
1155 p->g->ncsets--; in freeset()
1172 cset *top = &p->g->sets[p->g->ncsets]; in freezeset()
1174 size_t css = (size_t)p->g->csetsize; in freezeset()
1177 for (cs2 = &p->g->sets[0]; cs2 < top; cs2++) in freezeset()
1192 return((int)(cs - p->g->sets)); in freezeset()
1202 size_t css = (size_t)p->g->csetsize; in firstch()
1218 size_t css = (size_t)p->g->csetsize; in nch()
1279 isinsets(struct re_guts *g, int c) in isinsets() argument
1283 int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; in isinsets()
1286 for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) in isinsets()
1296 samesets(struct re_guts *g, int c1, int c2) in samesets() argument
1300 int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; in samesets()
1304 for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) in samesets()
1315 categorize(struct parse *p, struct re_guts *g) in categorize() argument
1318 cat_t *cats = g->categories; in categorize()
1328 if (cats[c] == 0 && isinsets(g, c)) { in categorize()
1329 cat = g->ncategories++; in categorize()
1332 if (cats[c2] == 0 && samesets(g, c, c2)) in categorize()
1481 stripsnug(struct parse *p, struct re_guts *g) in stripsnug() argument
1483 g->nstates = p->slen; in stripsnug()
1484 g->strip = (sop *)realloc((char *)p->strip, in stripsnug()
1486 if (g->strip == NULL) { in stripsnug()
1488 g->strip = p->strip; in stripsnug()
1490 g->stripdata = (RCHAR_T *)realloc((char *)p->stripdata, in stripsnug()
1492 if (g->stripdata == NULL) { in stripsnug()
1494 g->stripdata = p->stripdata; in stripsnug()
1508 findmust(struct parse *p, struct re_guts *g) in findmust() argument
1528 scans = g->strip + 1; in findmust()
1529 scand = g->stripdata + 1; in findmust()
1556 g->iflags |= BAD; in findmust()
1562 if (newlen > g->mlen) { /* ends one */ in findmust()
1565 g->mlen = newlen; in findmust()
1572 if (g->mlen == 0) /* there isn't one */ in findmust()
1576 g->must = malloc(((size_t)g->mlen + 1) * sizeof(RCHAR_T)); in findmust()
1577 if (g->must == NULL) { /* argh; just forget it */ in findmust()
1578 g->mlen = 0; in findmust()
1581 cp = g->must; in findmust()
1584 for (i = g->mlen; i > 0; i--) { in findmust()
1591 assert(cp < g->must + g->mlen); in findmust()
1594 assert(cp == g->must + g->mlen); in findmust()
1602 pluscount(struct parse *p, struct re_guts *g) in pluscount() argument
1612 scan = g->strip + 1; in pluscount()
1627 g->iflags |= BAD; in pluscount()