6 typedef struct RethreadQ RethreadQ;
13 regexec(Reprog *p, char *str, Resub *sem, int msize)
15 RethreadQ lists[2], *clist, *nlist, *tmp;
16 Rethread *t, *next, *pool, *avail;
22 memset(p->threads, 0, sizeof(Rethread)*p->nthr);
25 if(p->startinst->gen != 0) {
26 for(ci = p->startinst; ci < p->startinst + p->len; ci++)
32 clist->tail = &clist->head;
35 nlist->tail = &nlist->head;
44 if(sem != nil && msize > 0) {
47 if(sem->ep != nil && *sem->ep != '\0') {
54 for(r = L'☺'; r != L'\0'; sp += i) {
55 i = chartorune(&r, sp);
59 assert(pool < p->threads + p->nthr);
67 memset(t->sem, 0, sizeof(Resub)*msize);
71 clist->tail = &t->next;
85 case OANY: /* fallthrough */
90 nlist->tail = &t->next;
104 nlist->tail = &t->next;
113 if(sp == str || sp[-1] == '\n') {
119 if(r == L'\n' || r == L'\0' && ep == nil) {
129 assert(pool < p->threads + p->nthr);
137 memcpy(next->sem, t->sem, sizeof(Resub)*msize);
138 next->next = t->next;
145 t->sem[ci->sub].sp = sp;
151 if(sem != nil && msize > 0) {
152 memcpy(sem, t->sem, sizeof(Resub)*msize);
158 t->sem[ci->sub].ep = sp;
168 if(matchgen && next->gen > matchgen) {
169 *clist->tail = avail;
181 nlist->tail = &nlist->head;
185 return matchgen > 0 ? 1 : 0;