summaryrefslogtreecommitdiff
path: root/print-ascii.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-02-03 00:01:56 -0800
committerGuy Harris <guy@alum.mit.edu>2014-02-03 00:01:56 -0800
commitbcda4c195010ff8ae356e9bb1d1080eebe008d77 (patch)
treec316bfb4907b6f812084de10bd14b285d89a53bb /print-ascii.c
parentb485483022cddbb9d21845e9c3b465f6cd882676 (diff)
downloadtcpdump-bcda4c195010ff8ae356e9bb1d1080eebe008d77.tar.gz
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 ".".
Diffstat (limited to 'print-ascii.c')
-rw-r--r--print-ascii.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/print-ascii.c b/print-ascii.c
index 3ff8887b..18d5d0fb 100644
--- a/print-ascii.c
+++ b/print-ascii.c
@@ -62,11 +62,25 @@ ascii_print(register const u_char *cp, register u_int length)
while (length > 0) {
s = *cp++;
length--;
- if (!ND_ISGRAPH(s) &&
- (s != '\t' && s != ' ' && s != '\n' && s != '\r'))
- putchar('.');
- else
- putchar(s);
+ if (s == '\r') {
+ /*
+ * Don't print CRs at the end of the line; they
+ * don't belong at the ends of lines on UN*X,
+ * and the standard I/O library will give us one
+ * on Windows so we don't need to print one
+ * ourselves.
+ *
+ * In the middle of a line, just print a '.'.
+ */
+ if (length > 1 && *cp != '\n')
+ putchar('.');
+ } else {
+ if (!ND_ISGRAPH(s) &&
+ (s != '\t' && s != ' ' && s != '\n'))
+ putchar('.');
+ else
+ putchar(s);
+ }
}
}