diff --git a/alib2algo/src/stringology/exact/QuiteNaive.h b/alib2algo/src/stringology/exact/QuiteNaive.h index 90c9b60b88be7666aae029cb833cb25767c1560b..f78ee69eb94246488e7cf3bfc4c5cf4e37fca943 100644 --- a/alib2algo/src/stringology/exact/QuiteNaive.h +++ b/alib2algo/src/stringology/exact/QuiteNaive.h @@ -50,11 +50,12 @@ ext::set < unsigned > QuiteNaive::match ( const string::LinearString < SymbolTyp if ( pat[m-1] != text[s+m-1] ) { s += gamma; } else { - ssize_t j = m - 2; - while ( j >= 0 && pat[j] == text[s+j] ) - -- j; + // Note: loop here goes in other direction than in the paper + size_t j = 0; + while ( j + 2 <= m && pat[j] == text[s+j] ) + ++ j; - if ( j < 0 ) + if ( j + 2 > m ) occ.insert(s); s += delta; }