src/find.c
//execute the KMP algorithm on the file, and word passed in input
execute the KMP algorithm on the file, and word passed in input
execute the KMP algorithm on the file and word passed in input
void executeKMP(fWord *w, FILE *fp){
    char *line = NULL;
    size_t len = 0;
    ssize_t line_size;
    int countLine = 0;
    while((line_size = getline(&line, &len, fp)) != -1){
        trimTrailing(line); 
        int n = strlen(line);
        int m = strlen(w->word);
        w->p->fileOccurrences = w->p->fileOccurrences + KMP(line, w->word, n, m, countLine, w->p); 
        countLine = countLine + 1; 
     }
     w->totalOccurences = w->totalOccurences + w->p->fileOccurrences; 
            w->p->position = getHead(); 
            w->p = w->p->next;
}
void executeKMP ( fWord * w , FILE * fp ) { char * line = NULL ; size_t len = 0 ; ssize_t line_size ; int countLine = 0 ; while ( ( line_size = getline ( & line , & len , fp ) ) != -1 ) { trimTrailing ( line ) ; int n = strlen ( line ) ; int m = strlen ( w -> word ) ; w -> p -> fileOccurrences = w -> p -> fileOccurrences + KMP ( line , w -> word , n , m , countLine , w -> p ) ; countLine = countLine + 1 ; } w -> totalOccurences = w -> totalOccurences + w -> p -> fileOccurrences ; w -> p -> position = getHead ( ) ; w -> p = w -> p -> next ; }
execute the KMP algorithm on the file, and word passed in input
execute the KMP algorithm on the file and word passed in input
//deletes all the blank spaces after the read line //save the number of occurrences founded //increments the number of lines //increments the number of total occurrences //pointer back to head of the list