From 9f6ab53dffc25b8b958b071c7690e9edfe9a6c32 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 17 Jun 2011 15:24:25 -0400 Subject: Better visibility test. All regression tests pass. Code splints clean. --- hex.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'hex.c') diff --git a/hex.c b/hex.c index 04eae847..991673ff 100644 --- a/hex.c +++ b/hex.c @@ -4,12 +4,20 @@ */ #include #include +#include #include "gpsd.h" char /*@ observer @*/ *gpsd_hexdump(char *binbuf, size_t binbuflen) { - if (isprint(binbuf[binbuflen-1])) + char *cp; + bool printable = true; + + assert(binbuf != NULL); + for (cp = binbuf; cp < binbuf + binbuflen; cp++) + if (!isprint(*cp) && !isspace(*cp)) + printable = false; + if (printable) return binbuf; else { static char hexbuf[MAX_PACKET_LENGTH * 2 + 1]; -- cgit v1.2.1