diff options
author | Hannes Reinecke <hare@suse.de> | 2005-12-15 12:22:42 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@suse.de> | 2005-12-15 12:22:42 +0100 |
commit | d313632b04e2277306af74738df0b4444bcad695 (patch) | |
tree | bdf8292b6c2a0e233dfba26521f5c6133f8c9bc4 /extras/scsi_id | |
parent | 0105b9330cace0a1492003968a5d2552f1b64f43 (diff) |
fold multiple consecutive whitespace chars into single '_'
Diffstat (limited to 'extras/scsi_id')
-rw-r--r-- | extras/scsi_id/scsi_id.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index 39391f6e2e..aa1b16009e 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -677,13 +677,22 @@ static int per_dev_options(struct sysfs_device *scsi_dev, int *good_bad, */ static void format_serial(char *serial) { - char *p = serial; + char *p = serial, *q; + q = p; while (*p != '\0') { - if (isspace(*p)) - *p = '_'; + if (isspace(*p)) { + if (q > serial && q[-1] != '_') { + *q = '_'; + q++; + } + } else { + *q = *p; + q++; + } p++; } + *q = '\0'; } /* |