33 // s->next = mal(256*sizeof(*s->next));
35 s->re = mal(n*sizeof(*state0->re));
53 fprint(2, "grep: internal error: %s\n", s);
70 return n + r->hi - r->lo + 1;
76 oralloc(int t, Re *r, Re *b)
100 case Tclass: /* add to character */
101 for(n=r->lo; n<=r->hi; n++)
102 c->cases[n] = oralloc(Tor, r->next, c->cases[n]);
105 default: /* add everything unknown to next */
106 c->next = oralloc(Talt, r, c->next);
128 a->cases = mal(256*sizeof(*a->cases));
134 a->cases[i] = addcase(r);
141 r->next = addcase(r->next);
142 r->alt = addcase(r->alt);
160 yyerror("empty pattern"); /* can't be a file name here */
170 topre = re2or(oldtop, topre);
174 appendnext(Re *a, Re *b)
184 patchnext(Re *a, Re *b)
206 if(flags['i'] && c >= 'A' && c <= 'Z')
220 patchnext(a.end, b.beg);
231 patchnext(a.end, c.beg);
245 appendnext(c.end, a.end);
250 re2char(int c0, int c1)
255 c.beg->lo = c0 & 0xff;
256 c.beg->hi = c1 & 0xff;
275 print("type %d\n", a->type);
276 error("print1 type");
279 print("case ->%p\n", a->next);
282 for(j=i+1; j<256; j++)
283 if(a->cases[i] != a->cases[j])
285 print(" [%.2x-%.2x] ->%p\n", i, j-1, a->cases[i]);
289 reprint1(a->cases[i]);
293 print("^ ->%p\n", a->next);
297 print("$ ->%p\n", a->next);
301 print("[%.2x-%.2x] ->%p\n", a->lo, a->hi, a->next);
306 print("| %p ->%p\n", a->alt, a->next);
315 reprint(char *s, Re *r)