diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-06-17 15:24:25 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-06-17 15:24:25 -0400 |
commit | 9f6ab53dffc25b8b958b071c7690e9edfe9a6c32 (patch) | |
tree | 13517d96eba7a52610536d94c61e7e78760bf480 /hex.c | |
parent | 0e0f7f0b7c6c658259f09152ff8326f05b81b271 (diff) | |
download | gpsd-9f6ab53dffc25b8b958b071c7690e9edfe9a6c32.tar.gz |
Better visibility test. All regression tests pass. Code splints clean.
Diffstat (limited to 'hex.c')
-rw-r--r-- | hex.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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]; |