Skip to content

Commit c89f1d7

Browse files
committed
With -A and -AA, don't send CRs to the standard output.
They don't belong on the ends of lines on UN*X, and the standard I/O library will give us one at the end of the line on Windows so they're not needed there. In the middle of a line, just print a ".".
1 parent 3e13e6a commit c89f1d7

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

print-ascii.c

+19-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,25 @@ ascii_print(register const u_char *cp, register u_int length)
6565
while (length > 0) {
6666
s = *cp++;
6767
length--;
68-
if (!ND_ISGRAPH(s) &&
69-
(s != '\t' && s != ' ' && s != '\n' && s != '\r'))
70-
putchar('.');
71-
else
72-
putchar(s);
68+
if (s == '\r') {
69+
/*
70+
* Don't print CRs at the end of the line; they
71+
* don't belong at the ends of lines on UN*X,
72+
* and the standard I/O library will give us one
73+
* on Windows so we don't need to print one
74+
* ourselves.
75+
*
76+
* In the middle of a line, just print a '.'.
77+
*/
78+
if (length > 1 && *cp != '\n')
79+
putchar('.');
80+
} else {
81+
if (!ND_ISGRAPH(s) &&
82+
(s != '\t' && s != ' ' && s != '\n'))
83+
putchar('.');
84+
else
85+
putchar(s);
86+
}
7387
}
7488
}
7589

0 commit comments

Comments
 (0)