]> The Tcpdump Group git mirrors - tcpdump/commitdiff
With -A and -AA, don't send CRs to the standard output.
authorGuy Harris <[email protected]>
Mon, 3 Feb 2014 08:01:56 +0000 (00:01 -0800)
committerGuy Harris <[email protected]>
Mon, 3 Feb 2014 08:01:56 +0000 (00:01 -0800)
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 ".".

print-ascii.c

index 3ff8887b1f5a09c5c5069e6a100282e14561eae9..18d5d0fb312ec564816103581f0c5b55f2a6b084 100644 (file)
@@ -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);
+               }
        }
 }