diff options
Diffstat (limited to 'libautomata_compile_kmp_automaton.c')
| -rw-r--r-- | libautomata_compile_kmp_automaton.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libautomata_compile_kmp_automaton.c b/libautomata_compile_kmp_automaton.c index 3917b00..46b0430 100644 --- a/libautomata_compile_kmp_automaton.c +++ b/libautomata_compile_kmp_automaton.c @@ -24,15 +24,15 @@ libautomata_compile_kmp_automaton(const void *pattern, size_t length, size_t ele (!memcmp(&((const char *)pattern)[i * (WIDTH)], &((const char *)pattern)[j * (WIDTH)], (WIDTH))) #define IMPLEMENT(EQ, EQ_PARAM, CASE)\ - while (i < length) {\ - if (j != SIZE_MAX && !(EQ(EQ_PARAM)))\ - j = ret->next[j];\ - i++;\ - j++;\ - if (EQ(EQ_PARAM))\ + for (; i < length; i++, j++) {\ + if (EQ(EQ_PARAM)) {\ ret->next[i] = ret->next[j];\ - else CASE:\ + } else {\ + CASE:\ ret->next[i] = j;\ + while (j != SIZE_MAX && !(EQ(EQ_PARAM)))\ + j = ret->next[j];\ + }\ }\ return ret |
