]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use fn_print_char() to simplify some code
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 13 Feb 2018 18:53:24 +0000 (19:53 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 13 Feb 2018 18:53:37 +0000 (19:53 +0100)
util-print.c

index 5123ba1ab9a1c2f0493f13e1f6cf679c070146a2..b85299ca292ce715194c904099611b7f1f761313 100644 (file)
@@ -107,15 +107,7 @@ fn_print(netdissect_options *ndo,
                        ret = 0;
                        break;
                }
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT("M-");
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT("^");
-               }
-               ND_PRINT("%c", c);
+               fn_print_char(ndo, c);
        }
        return(ret);
 }
@@ -158,15 +150,7 @@ fn_printztn(netdissect_options *ndo,
                        /* End of string */
                        break;
                }
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT("M-");
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT("^");
-               }
-               ND_PRINT("%c", c);
+               fn_print_char(ndo, c);
        }
        return(bytes);
 }
@@ -187,15 +171,7 @@ fn_printn(netdissect_options *ndo,
                n--;
                c = EXTRACT_U_1(s);
                s++;
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT("M-");
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT("^");
-               }
-               ND_PRINT("%c", c);
+               fn_print_char(ndo, c);
        }
        return (n == 0) ? 0 : 1;
 }
@@ -224,15 +200,7 @@ fn_printzp(netdissect_options *ndo,
                        ret = 0;
                        break;
                }
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT("M-");
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT("^");
-               }
-               ND_PRINT("%c", c);
+               fn_print_char(ndo, c);
        }
        return (n == 0) ? 0 : ret;
 }