commit c8b1a82f1fd6a4ae0122d031cd5db7d0ff7dcee1 from: Sven M. Hallberg date: Fri Feb 11 20:29:42 2022 UTC changed my mind; dont do output (or inner input) on chunk edges! commit - 30d8c294a20149ef5d6c21f9727e5a85c8a814d3 commit + c8b1a82f1fd6a4ae0122d031cd5db7d0ff7dcee1 blob - a59e1746b69c19fb9b3313c1c3052b11fce2b306 blob + 6d6cf89cfcdfa24ae10076757a596f16cb59a029 --- nfa.c +++ nfa.c @@ -668,7 +668,7 @@ nfastep(struct prep *pr, int x, struct set *act, struc { NFA a = pr->a; bunch_t *tmp; - int r = 0; /* consume input? */ + int r = 0; /* input consumed? */ printstates(act, x); /* diagnostic output */ @@ -681,10 +681,10 @@ nfastep(struct prep *pr, int x, struct set *act, struc if (inset(act, a.size)) /* final state? */ pr->match = pr->pos; /* save position */ - if (x < OUTPUT && matchchr(a, act, next, x)) /* match input? */ + if (matchchr(a, act, next, x)) /* input match? */ r = 1; - else - r = generate(pr, act, next); /* attempt output */ + else /* else try output */ + r = generate(pr, act, next); /* swap sets */ tmp = act->bits; @@ -692,23 +692,6 @@ nfastep(struct prep *pr, int x, struct set *act, struc next->bits = tmp; return r; -} - -static int -inputactive(const struct prep *pr) -{ - struct state s; - size_t k; - - FOREACHSTATE(pr->a, k, &pr->act) { - s = pr->a.state[k]; - - /* NB: assume that chr does not cross range bounds */ - if (s.chr.n >= CHAR_MIN && s.chr.n <= END) - return 1; - } - - return 0; } int @@ -723,11 +706,6 @@ nfacont(struct prep *pr, const char *input, size_t sz) pr->pos += r; } - /* run until output ceases */ - while(!inputactive(pr)) - if (nfastep(pr, OUTPUT, &pr->act, &pr->next) == -1) - break; - return pr->match; }