fdisk: use strutils to trim whitespace from input

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
This commit is contained in:
Vaclav Dolezal 2017-08-29 14:31:06 +02:00
parent 1d775aa260
commit 6c183c283b
2 changed files with 2 additions and 7 deletions

View File

@ -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';

View File

@ -213,7 +213,7 @@ static inline size_t ltrim_whitespace(unsigned char *str)
len = strlen((char *) p);
if (len && p > str)
if (p > str)
memmove(str, p, len + 1);
return len;