utils: small code cleanup.
This commit is contained in:
parent
52dae50075
commit
507a9e338f
@ -40,20 +40,20 @@
|
|||||||
static bool
|
static bool
|
||||||
question(bool preset, const char *fmt, va_list ap)
|
question(bool preset, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char response[4];
|
char response;
|
||||||
|
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
if (preset)
|
if(preset)
|
||||||
fprintf(stderr, " %s ", "[Y/n]");
|
fputs(" [Y/n] ", stderr);
|
||||||
else
|
else
|
||||||
fprintf(stderr, " %s ", "[y/N]");
|
fputs(" [y/N] ", stderr);
|
||||||
|
|
||||||
if (fgets(response, sizeof(response), stdin)) {
|
if ((response = fgetc(stdin))) {
|
||||||
if (response[0] == '\n')
|
if (response == '\n')
|
||||||
return preset;
|
return preset;
|
||||||
if (response[0] == 'y' || response[0] == 'Y')
|
if (response == 'y' || response == 'Y')
|
||||||
return true;
|
return true;
|
||||||
if (response[0] == 'n' || response[0] == 'N')
|
if (response == 'n' || response == 'N')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user