Skip to content

Commit

Permalink
add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
colinleroy committed Jan 30, 2024
1 parent 8123fcb commit 6564e4c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/isequal.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,18 @@ static int comparefileswithwildcards(FILE *f1, FILE *f2)
}
}

static void cat(FILE *fp) {
rewind(fp);
unsigned char c;
while (fread(&c, 1, 1, fp)) {
fprintf(stderr, "%02X ", c);
}
}

int main(int argc, char *argv[])
{
FILE *f1, *f2;
int result;

if (handleparameter(argc, argv) < 0) {
return EXIT_FAILURE;
Expand Down Expand Up @@ -474,7 +483,14 @@ int main(int argc, char *argv[])
return comparefileswithwildcards(f1, f2);
}
else {
return comparefiles(f1, f2);
result = comparefiles(f1, f2);
if (result != 0) {
fprintf(stderr, "First file:\n");
cat(f1);
fprintf(stderr, "\nSecond file:\n");
cat(f2);
fprintf(stderr, "\n");
}
}
}
}

0 comments on commit 6564e4c

Please sign in to comment.