summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-02-22 20:23:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-02-22 20:23:20 +0000
commitbc8565da3c2a85c911eb89da0ed0bb929d3e26a0 (patch)
treefa179644f0d89c73218127f0293aea5c9a718010 /usr.sbin
parent31db72acd3768c9f5171a404ba619383f7ebf9bc (diff)
Allow multiple NUL characters within string-valued properties (but add an
XXX saying that this may not exactly be what we want). This makes the output on macppc look much saner. ok fgsch@, beck@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/eeprom/optree.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c
index 67ea883e53a..58c4800c54f 100644
--- a/usr.sbin/eeprom/optree.c
+++ b/usr.sbin/eeprom/optree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optree.c,v 1.3 2007/11/12 20:54:54 kettenis Exp $ */
+/* $OpenBSD: optree.c,v 1.4 2008/02/22 20:23:19 kettenis Exp $ */
/*
* Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org>
@@ -51,15 +51,30 @@ op_print(struct opiocdesc *opio, int depth)
opio->op_buf[opio->op_buflen] = '\0';
special = 0;
+ /*
+ * XXX This allows multiple NUL characters within
+ * string-valued properties, which may not be what we
+ * want. But on macppc we have string-values
+ * properties that end with multiple NUL characters,
+ * and the serial number has them embedded within the
+ * string.
+ */
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;
+ if (*p >= ' ' && *p <= '~')
+ continue;
+ if (*p == '\0') {
+ if (i + 1 < opio->op_buflen)
+ p++;
+ if (*p >= ' ' && *p <= '~')
+ continue;
+ if (*p == '\0')
+ continue;
}
+
+ special = 1;
+ break;
}
} else {
if (opio->op_buflen > 1)
@@ -84,6 +99,8 @@ op_print(struct opiocdesc *opio, int depth)
} else {
for (i = 0; i < opio->op_buflen;
i += strlen(&opio->op_buf[i]) + 1) {
+ if (i && strlen(&opio->op_buf[i]) == 0)
+ continue;
if (i)
printf(" + ");
printf("'%s'", &opio->op_buf[i]);