diff options
author | Vaclav Dolezal | 2017-08-29 14:31:06 +0200 |
---|---|---|
committer | Vaclav Dolezal | 2017-08-29 15:26:39 +0200 |
commit | 6c183c283bb7d5aadfa98c8fb218e4a9bb424e45 (patch) | |
tree | 0cf064fe1c64b2ee3c424ed6046ccdae20cb39fe /disk-utils | |
parent | fdisk: fix copy from readline and whitespace stripping (diff) | |
download | kernel-qcow2-util-linux-6c183c283bb7d5aadfa98c8fb218e4a9bb424e45.tar.gz kernel-qcow2-util-linux-6c183c283bb7d5aadfa98c8fb218e4a9bb424e45.tar.xz kernel-qcow2-util-linux-6c183c283bb7d5aadfa98c8fb218e4a9bb424e45.zip |
fdisk: use strutils to trim whitespace from input
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/fdisk.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index be8f00edc..226f07065 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -97,7 +97,6 @@ int get_user_reply(const char *prompt, char *buf, size_t bufsz) struct pollfd fds[] = { { .fd = fileno(stdin), .events = POLLIN } }; - char *p; size_t sz; int ret = 0; @@ -165,11 +164,7 @@ int get_user_reply(const char *prompt, char *buf, size_t bufsz) /* * cleanup the reply */ - for (p = buf; *p && !isgraph(*p); p++); /* get first non-blank */ - - if (p > buf) - memmove(buf, p, strlen(p) + 1); /* remove blank space */ - sz = strlen(buf); + sz = ltrim_whitespace((unsigned char *) buf); if (sz && *(buf + sz - 1) == '\n') *(buf + sz - 1) = '\0'; |