xbps-install: make question() read the whole input line
reading only the first character would answer the next question() with the next character (unless you just pressed enter)
This commit is contained in:
parent
cfc8e0a580
commit
56aa77d51b
@ -41,22 +41,27 @@ static bool
|
|||||||
question(bool preset, const char *fmt, va_list ap)
|
question(bool preset, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int response;
|
int response;
|
||||||
|
bool rv = false;
|
||||||
|
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
if(preset)
|
if (preset)
|
||||||
fputs(" [Y/n] ", stderr);
|
fputs(" [Y/n] ", stderr);
|
||||||
else
|
else
|
||||||
fputs(" [y/N] ", stderr);
|
fputs(" [y/N] ", stderr);
|
||||||
|
|
||||||
if ((response = fgetc(stdin)) != EOF) {
|
response = fgetc(stdin);
|
||||||
if (response == '\n')
|
if (response == '\n')
|
||||||
return preset;
|
rv = preset;
|
||||||
if (response == 'y' || response == 'Y')
|
else if (response == 'y' || response == 'Y')
|
||||||
return true;
|
rv = true;
|
||||||
if (response == 'n' || response == 'N')
|
else if (response == 'n' || response == 'N')
|
||||||
return false;
|
rv = false;
|
||||||
}
|
|
||||||
return false;
|
/* read the rest of the line */
|
||||||
|
while (response != EOF && response != '\n')
|
||||||
|
response = fgetc(stdin);
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user