From 507a9e338fe084ad283f09819c7ec7cbb6a2066c Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Sat, 14 Mar 2015 00:30:35 +0100 Subject: [PATCH] utils: small code cleanup. --- bin/xbps-install/question.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/xbps-install/question.c b/bin/xbps-install/question.c index bea2c317..e4c73bb6 100644 --- a/bin/xbps-install/question.c +++ b/bin/xbps-install/question.c @@ -40,20 +40,20 @@ static bool question(bool preset, const char *fmt, va_list ap) { - char response[4]; + char response; vfprintf(stderr, fmt, ap); - if (preset) - fprintf(stderr, " %s ", "[Y/n]"); + if(preset) + fputs(" [Y/n] ", stderr); else - fprintf(stderr, " %s ", "[y/N]"); + fputs(" [y/N] ", stderr); - if (fgets(response, sizeof(response), stdin)) { - if (response[0] == '\n') + if ((response = fgetc(stdin))) { + if (response == '\n') return preset; - if (response[0] == 'y' || response[0] == 'Y') + if (response == 'y' || response == 'Y') return true; - if (response[0] == 'n' || response[0] == 'N') + if (response == 'n' || response == 'N') return false; } return false;