27 |
|
|
28 |
|
int ign_header = 0; /* ignore header differences? */ |
29 |
|
|
30 |
+ |
int escape_newlines = 0; /* allow backslash to skip newlines */ |
31 |
+ |
|
32 |
|
double rel_min = 1e-5; /* positive for relative comparisons */ |
33 |
|
|
34 |
|
double rms_lim = 0.01; /* RMS difference limit */ |
134 |
|
} |
135 |
|
while (fgets(bp->str + bp->len, bp->siz - bp->len, fp)) { |
136 |
|
bp->len += strlen(bp->str + bp->len); |
137 |
< |
if (bp->str[bp->len-1] == '\n') |
137 |
> |
if (bp->str[bp->len-1] == '\n') { |
138 |
> |
if (bp->len > 1 && bp->str[bp->len-2] == '\r') { |
139 |
> |
bp->str[--bp->len] = '\0'; |
140 |
> |
bp->str[bp->len-1] = '\n'; |
141 |
> |
} |
142 |
> |
if (escape_newlines && bp->len > 1 && |
143 |
> |
bp->str[bp->len-2] == '\\') { |
144 |
> |
bp->str[--bp->len] = '\0'; |
145 |
> |
bp->str[bp->len-1] = ' '; |
146 |
> |
continue; |
147 |
> |
} |
148 |
|
break; /* found EOL */ |
149 |
+ |
} |
150 |
|
if (bp->len < bp->siz - 4) |
151 |
|
continue; /* at EOF? */ |
152 |
|
if (bp->siz >= MAXBUF) { |
582 |
|
if (report >= REP_VERBOSE) { |
583 |
|
fputs(progname, stdout); |
584 |
|
fputs(": comparing inputs as ASCII text", stdout); |
585 |
+ |
if (escape_newlines) |
586 |
+ |
fputs(", allowing escaped newlines", stdout); |
587 |
|
if (comment_c) { |
588 |
|
fputs(", ignoring comments starting with '", stdout); |
589 |
|
fputc(comment_c, stdout); |
615 |
|
/* compare non-empty lines */ |
616 |
|
if (!equiv_string(l1buf.str, l2buf.str)) { |
617 |
|
if (report != REP_QUIET) { |
618 |
< |
printf("%s: inputs '%s' and '%s' differ at line %d|%d\n", |
619 |
< |
progname, f1name, f2name, |
620 |
< |
lin1cnt, lin2cnt); |
618 |
> |
printf("%s: inputs '%s' and '%s' differ at line %d", |
619 |
> |
progname, f1name, f2name, lin1cnt); |
620 |
> |
if (lin1cnt != lin2cnt) |
621 |
> |
printf("|%d\n", lin2cnt); |
622 |
> |
else |
623 |
> |
putchar('\n'); |
624 |
|
if ( report >= REP_VERBOSE && |
625 |
|
(l1buf.len < 256) & |
626 |
|
(l2buf.len < 256) ) { |
934 |
|
switch (argv[a][1]) { |
935 |
|
case 'h': /* ignore header info. */ |
936 |
|
ign_header = !ign_header; |
937 |
+ |
continue; |
938 |
+ |
case 'n': /* allow newline escapes */ |
939 |
+ |
escape_newlines = !escape_newlines; |
940 |
|
continue; |
941 |
|
case 'c': /* ignore comments */ |
942 |
|
comment_c = argv[a][2]; |