diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2011-05-04 20:49:42 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2011-05-04 20:49:42 +0000 |
commit | 435fc5e81357bafca6f3010233d2cd0f523cf3d1 (patch) | |
tree | 51e279222f74b929af3dcf47ecfbbb99ab2f355e /sys/scsi/scsiconf.c | |
parent | 7e6438dc0acdfa02b269d906ec421b6458252a60 (diff) |
When printing scsi device ids, skip leading blanks and collapse multiple
whitespace into one. Written after Mitja showed a particularly unwieldy
attach line:
sd0 at scsibus0 targ 2 lun 0: <ATA, HTS721010G9SA00, MCZI> SCSI3 0/direct fixed t10.ATA_____HTS721010G9SA00_______________________________blahblahblah
ok/incorporating a suggestion from matthew@, krw@ likes it, dlg@ doesn't
feel strongly either way.
Diffstat (limited to 'sys/scsi/scsiconf.c')
-rw-r--r-- | sys/scsi/scsiconf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 57c3d5c8ea2..07448b7bd65 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.174 2011/04/29 02:10:05 dlg Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.175 2011/05/04 20:49:41 sthen Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -789,9 +789,12 @@ scsibus_printlink(struct scsi_link *link) if (ISSET(link->id->d_flags, DEVID_F_PRINT)) { for (i = 0; i < link->id->d_len; i++) { - if (id[i] == '\0' || id[i] == ' ') - printf("_"); - else if (id[i] < 0x20 || id[i] >= 0x80) { + if (id[i] == '\0' || id[i] == ' ') { + /* skip leading blanks */ + /* collapse multiple blanks into one */ + if (i > 0 && id[i-1] != id[i]) + printf("_"); + } else if (id[i] < 0x20 || id[i] >= 0x80) { /* non-printable characters */ printf("~"); } else { |