/* For every found string with id ID, it increments freq[ID].
* Also, it finds the longest among the leftmost matches. */
{
- byte *str_end = str + len;
+ if (!len)
+ return NULL;
kmp_state_t s = 0;
kmp_char_t c = KMP_CONTROL_CHAR;
struct kmp_transition tr, **prev;
}
if (eof)
break;
- if (str >= str_end)
+ if (!--len)
c = 0;
else
kmp_get_char((const byte **)&str, &c, kmp->modify_flags);
}
static inline void
-kmp_search(struct kmp *kmp, const byte *str, struct list *nonzeroes, struct kmp_result *freq)
+kmp_search(struct kmp *kmp, const byte *str, uns len, struct list *nonzeroes, struct kmp_result *freq)
{
- kmp_search_internal(kmp, (byte*) str, strlen(str), nonzeroes, freq, NULL);
+ kmp_search_internal(kmp, (byte*) str, len, nonzeroes, freq, NULL);
}
static inline byte *