37 // s->next = mal(256*sizeof(*s->next));
39 s->re = mal(n*sizeof(*state0->re));
57 fprint(2, "grep: internal error: %s\n", s);
74 return n + r->hi - r->lo + 1;
80 oralloc(int t, Re *r, Re *b)
104 case Tclass: /* add to character */
105 for(n=r->lo; n<=r->hi; n++)
106 c->cases[n] = oralloc(Tor, r->next, c->cases[n]);
109 default: /* add everything unknown to next */
110 c->next = oralloc(Talt, r, c->next);
132 a->cases = mal(256*sizeof(*a->cases));
138 a->cases[i] = addcase(r);
145 r->next = addcase(r->next);
146 r->alt = addcase(r->alt);
164 yyerror("empty pattern"); /* can't be a file name here */
174 topre = re2or(oldtop, topre);
178 appendnext(Re *a, Re *b)
188 patchnext(Re *a, Re *b)
210 if(flags['i'] && c >= 'A' && c <= 'Z')
224 patchnext(a.end, b.beg);
235 patchnext(a.end, c.beg);
249 appendnext(c.end, a.end);
254 re2char(int c0, int c1)
259 c.beg->lo = c0 & 0xff;
260 c.beg->hi = c1 & 0xff;
279 print("type %d\n", a->type);
280 error("print1 type");
283 print("case ->%p\n", a->next);
286 for(j=i+1; j<256; j++)
287 if(a->cases[i] != a->cases[j])
289 print(" [%.2x-%.2x] ->%p\n", i, j-1, a->cases[i]);
293 reprint1(a->cases[i]);
297 print("^ ->%p\n", a->next);
301 print("$ ->%p\n", a->next);
305 print("[%.2x-%.2x] ->%p\n", a->lo, a->hi, a->next);
310 print("| %p ->%p\n", a->alt, a->next);
319 reprint(char *s, Re *r)