Skip to content

Commit

Permalink
Show what the problematic byte is in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerb9 committed Jul 17, 2024
1 parent 43ecb4c commit 33b9041
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bacmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ int main(int argc, char *argv[]) {
offset_b = cb1 + (cb2<<8);
delta = offset_b - offset_a;

while (ca1 != EOF && cb1 != EOF) {
while ( (ca1 != EOF) && (cb1 != EOF) ) {
count++;
ca0 = ca1; cb0 = cb1; /* stash old value for lineptr check */
ca1 = fgetc(fa);
cb1 = fgetc(fb);
if (ca1 == cb1) continue;

if ( ca1 == EOF ) {
fprintf(stderr, "EOF on %s after byte %d\n", argv[1], count-2);
fprintf(stderr, "EOF on %s after byte %d. %s has %c.\n",
argv[1], count-2, argv[2], cb1);
exit(1);
}
else if ( cb1 == EOF ) {
fprintf(stderr, "EOF on %s after byte %d\n", argv[2], count-2);
fprintf(stderr, "EOF on %s after byte %d. %s has %c.\n",
argv[2], count-2, argv[1], ca1);
exit(2);
}

Expand Down

0 comments on commit 33b9041

Please sign in to comment.