summaryrefslogtreecommitdiff
path: root/extras/ata_id/ata_id.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-11-05 21:49:52 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-11-05 21:49:52 +0100
commit92f4313665bc726baf055f81e2daae48c77123fc (patch)
tree028c85074533b111d471eb01cabe843c7d1ab22b /extras/ata_id/ata_id.c
parentb467444884865167296b588c9529e1643b9e4899 (diff)
unify string replacement
Diffstat (limited to 'extras/ata_id/ata_id.c')
-rw-r--r--extras/ata_id/ata_id.c38
1 files changed, 3 insertions, 35 deletions
diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c
index a4f73b8dfd..d407b0fad9 100644
--- a/extras/ata_id/ata_id.c
+++ b/extras/ata_id/ata_id.c
@@ -44,38 +44,6 @@ static void log_fn(struct udev *udev, int priority,
vsyslog(priority, format, args);
}
-static void set_str(char *to, const char *from, size_t count)
-{
- size_t i, j, len;
-
- /* strip trailing whitespace */
- len = strnlen(from, count);
- while (len && isspace(from[len-1]))
- len--;
-
- /* strip leading whitespace */
- i = 0;
- while (isspace(from[i]) && (i < len))
- i++;
-
- j = 0;
- while (i < len) {
- /* substitute multiple whitespace */
- if (isspace(from[i])) {
- while (isspace(from[i]))
- i++;
- to[j++] = '_';
- }
- /* skip chars */
- if (from[i] == '/') {
- i++;
- continue;
- }
- to[j++] = from[i++];
- }
- to[j] = '\0';
-}
-
int main(int argc, char *argv[])
{
struct udev *udev;
@@ -146,9 +114,9 @@ int main(int argc, char *argv[])
goto close;
}
- set_str(model, (char *) id.model, 40);
- set_str(serial, (char *) id.serial_no, 20);
- set_str(revision, (char *) id.fw_rev, 8);
+ udev_util_replace_whitespace((char *) id.model, model, 40);
+ udev_util_replace_whitespace((char *) id.serial_no, serial, 20);
+ udev_util_replace_whitespace((char *) id.fw_rev, revision, 8);
if (export) {
if ((id.config >> 8) & 0x80) {