From: Pavel Charvat Date: Wed, 5 Apr 2006 08:49:33 +0000 (+0200) Subject: New version of SubStrings analyser... X-Git-Tag: holmes-import~650^2~14 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8106838654534920f5e919604a437a990038c860;p=libucw.git New version of SubStrings analyser... - KMP uses continuous read of fastbuf streams - the tag is OR combination of groups masks --- diff --git a/lib/kmp.h b/lib/kmp.h index 9577e8d3..fd37a6e3 100644 --- a/lib/kmp.h +++ b/lib/kmp.h @@ -161,7 +161,8 @@ kmp_search_internal(struct kmp *kmp, byte *str, uns len, struct list *nonzeroes, /* 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; @@ -195,7 +196,7 @@ kmp_search_internal(struct kmp *kmp, byte *str, uns len, struct list *nonzeroes, } if (eof) break; - if (str >= str_end) + if (!--len) c = 0; else kmp_get_char((const byte **)&str, &c, kmp->modify_flags); @@ -210,9 +211,9 @@ kmp_search_internal(struct kmp *kmp, byte *str, uns len, struct list *nonzeroes, } 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 *