summaryrefslogtreecommitdiff
path: root/hex.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-06-17 15:24:25 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-06-17 15:24:25 -0400
commit9f6ab53dffc25b8b958b071c7690e9edfe9a6c32 (patch)
tree13517d96eba7a52610536d94c61e7e78760bf480 /hex.c
parent0e0f7f0b7c6c658259f09152ff8326f05b81b271 (diff)
downloadgpsd-9f6ab53dffc25b8b958b071c7690e9edfe9a6c32.tar.gz
Better visibility test. All regression tests pass. Code splints clean.
Diffstat (limited to 'hex.c')
-rw-r--r--hex.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/hex.c b/hex.c
index 04eae847..991673ff 100644
--- a/hex.c
+++ b/hex.c
@@ -4,12 +4,20 @@
*/
#include <string.h>
#include <ctype.h>
+#include <assert.h>
#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];