deps/kb_meme/meme-5.0.1/src/buffer.c
/*
 * buf_kmp_table
 * builds a partial match table for use by the kmp search when searching
 * for the match string.
 */
buf_kmp_table
builds a partial match table for use by the kmp search when searching
for the match string.
buf_kmp_table builds a partial match table for use by the kmp search when searching for the match string .
void buf_kmp_table(char *match_string, int *kmp_table, int len) {
  int pos, candidate;
  kmp_table[0] = -1;
  kmp_table[1] = 0;
  pos = 2;
  candidate = 0;
  while (pos < len) {
    if (match_string[pos - 1] == match_string[candidate]) {
      kmp_table[pos] = candidate + 1;
      pos += 1;
      candidate += 1;
    }
    else if (candidate > 0) {
      candidate = kmp_table[candidate];
    } else {
      kmp_table[pos] = 0;
      pos += 1;
    }
  }
}
void buf_kmp_table ( char * match_string , int * kmp_table , int len ) { int pos , candidate ; kmp_table [ 0 ] = -1 ; kmp_table [ 1 ] = 0 ; pos = 2 ; candidate = 0 ; while ( pos < len ) { if ( match_string [ pos - 1 ] == match_string [ candidate ] ) { kmp_table [ pos ] = candidate + 1 ; pos += 1 ; candidate += 1 ; } else if ( candidate > 0 ) { candidate = kmp_table [ candidate ] ; } else { kmp_table [ pos ] = 0 ; pos += 1 ; } } }
buf_kmp_table
 builds a partial match table for use by the kmp search when searching
 for the match string.
buf_kmp_table builds a partial match table for use by the kmp search when searching for the match string .