/* To avoid dependencies between libucw and other libraries (which might
* be referenced by the KMP_GET_CHAR macro), we have to split kmp_enter_string()
* to a conversion wrapper (this function) and the rest, which resides in kmp.c
- * and uses KMP_GET_RAW to read its input.
+ * and uses zero-terminated array of kmp_char_t characters as its input.
*/
kmp_char_t buf[strlen(str)+1], *str2 = buf, c = 0;
do
/* 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 *