X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=finddup.git;a=blobdiff_plain;f=finddup.c;h=a8847f5be4c4ac0602a510841b263807d5183ab0;hp=bca9c5c3ebfd63262cb47d1e022faf6b9fbcb5a4;hb=1621d18b51827a5c12b939f8e2573de58175d70f;hpb=630c461cbdb6610420863dcfe7af247d62bf004e diff --git a/finddup.c b/finddup.c index bca9c5c..a8847f5 100644 --- a/finddup.c +++ b/finddup.c @@ -160,7 +160,7 @@ int same_content(struct file_with_size *f1, struct file_with_size *f2) { close(fd2); return 1; } else { - if(strncmp(buffer1, buffer2, s1)) { + if(memcmp(buffer1, buffer2, s1)) { close(fd1); close(fd2); return 0; @@ -291,7 +291,7 @@ void print_result(struct file_with_size *list1, struct file_with_size *list2) { if(node1->group_id >= 0) { nb++; } } - if(show_hits) { + if(list2) { for(node2 = list2; node2; node2 = node2->next) { if(node2->group_id >= 0) { nb++; } } @@ -306,7 +306,7 @@ void print_result(struct file_with_size *list1, struct file_with_size *list2) { } } - if(show_hits) { + if(list2) { for(node2 = list2; node2; node2 = node2->next) { if(node2->group_id >= 0) { nodes[n++] = node2; @@ -317,6 +317,9 @@ void print_result(struct file_with_size *list1, struct file_with_size *list2) { qsort(nodes, nb, sizeof(struct file_with_size *), compare_nodes); for(n = 0; n < nb; n++) { + if(!show_groups && n > 0 && nodes[n]->group_id != nodes[n-1]->group_id) { + printf("\n"); + } print_file(nodes[n]); } @@ -418,12 +421,13 @@ void start(const char *dirname1, const char *dirname2) { } } - print_result(list1, list2); - - file_list_delete(list1); - if(dirname2) { + print_result(list1, list2); + file_list_delete(list1); file_list_delete(list2); + } else { + print_result(list1, 0); + file_list_delete(list1); } }