fdisk: use strutils to trim whitespace from input
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
This commit is contained in:
parent
1d775aa260
commit
6c183c283b
|
@ -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';
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue