diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2007-09-09 14:19:29 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2007-09-09 14:19:29 +0000 |
commit | ad43dabf018783f3f9ea74eb42cb8104771196d6 (patch) | |
tree | a6b7520a5c9a963448ccd8c2408b0dfd59b2ccca /usr.sbin/eeprom | |
parent | a10d340a1b94fb8f5543f7d886e0f6649f8e846d (diff) |
better printing code, fixing certain properties; reported by kettenis,
tested by him and Johan Mson Lindman. ok kettenis.
Diffstat (limited to 'usr.sbin/eeprom')
-rw-r--r-- | usr.sbin/eeprom/optree.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c index 3930fbaddc7..5e1419447e6 100644 --- a/usr.sbin/eeprom/optree.c +++ b/usr.sbin/eeprom/optree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optree.c,v 1.1 2007/09/04 23:28:26 fgsch Exp $ */ +/* $OpenBSD: optree.c,v 1.2 2007/09/09 14:19:28 fgsch Exp $ */ /* * Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org> @@ -48,14 +48,19 @@ op_print(struct opiocdesc *opio, int depth) opio->op_buf[opio->op_buflen] = '\0'; special = 0; - for (i = 0; i < opio->op_buflen; i++) { - p = &opio->op_buf[i]; - if ((*p < ' ' || *p > '~') && (*p != '\0' || - (i + 1 < opio->op_buflen && - (*++p < ' ' || *p > '~')))) { - special = 1; - break; + if (opio->op_buf[0] != '\0') { + for (i = 0; i < opio->op_buflen; i++) { + p = &opio->op_buf[i]; + if ((*p < ' ' || *p > '~') && (*p != '\0' || + (i + 1 < opio->op_buflen && + (*++p < ' ' || *p > '~')))) { + special = 1; + break; + } } + } else { + if (opio->op_buflen > 1) + special = 1; } if (special) { @@ -66,7 +71,8 @@ op_print(struct opiocdesc *opio, int depth) printf("%08x", *(int *)(long)&opio->op_buf[i]); } if (i < opio->op_buflen) { - printf("."); + if (i) + printf("."); for (; i < opio->op_buflen; i++) { printf("%02x", *(u_char *)&opio->op_buf[i]); |