deps/kb_meme/meme-5.0.1/src/buffer.c
/*
 *  buf_kmp_search
 *  uses a kmp search to move the position forward to the first possible 
 *  character of the match string, returns the number of characters 
 *  remaining to match if it gets to the end of the buffer before completely
 *  matching the string.
 */
buf_kmp_search
uses a kmp search to move the position forward to the first possible
character of the match string, returns the number of characters
remaining to match if it gets to the end of the buffer before completely
matching the string.
buf_kmp_search uses a kmp search to move the position forward to the first possible character of the match string returns the number of characters remaining to match if it gets to the end of the buffer before completely matching the string .
int buf_kmp_search(BUF_T *buf, char *match_string, int *kmp_table, int len) {
  int m, i;
  m = buf->position;
  i = 0;
  while (m + i < buf->limit) {
    if (match_string[i] == buf->buffer[m+i]) {
      i += 1;
      if (i == len) {
        buf->position = m;
        return 0;
      }
    } else {
      m = m + i - kmp_table[i];
      if (i > 0) {
        i = kmp_table[i];
      }
    }
  }
  buf->position = m;
  return len - i;
}
int buf_kmp_search ( BUF_T * buf , char * match_string , int * kmp_table , int len ) { int m , i ; m = buf -> position ; i = 0 ; while ( m + i < buf -> limit ) { if ( match_string [ i ] == buf -> buffer [ m + i ] ) { i += 1 ; if ( i == len ) { buf -> position = m ; return 0 ; } } else { m = m + i - kmp_table [ i ] ; if ( i > 0 ) { i = kmp_table [ i ] ; } } } buf -> position = m ; return len - i ; }
buf_kmp_search
  uses a kmp search to move the position forward to the first possible
  character of the match string, returns the number of characters
  remaining to match if it gets to the end of the buffer before completely
  matching the string.
buf_kmp_search uses a kmp search to move the position forward to the first possible character of the match string returns the number of characters remaining to match if it gets to the end of the buffer before completely matching the string .
//incomplete match, return the number of characters not matched