xbps_yesno/noyes: change the funcs to only accept "yes" or "no"

(case insensitive) answers rather than the short ones.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091222112759-0mnzjt3qcwp45ugn
This commit is contained in:
Juan RP 2009-12-22 12:27:59 +01:00
parent 6b83ad4c7e
commit 009c2131fc

View File

@ -473,20 +473,18 @@ question(bool preset, const char *fmt, va_list ap)
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
if (preset) if (preset)
fprintf(stderr, " %s ", "[Y/n]"); fprintf(stderr, " %s ", "[YES/no]");
else else
fprintf(stderr, " %s ", "[y/N]"); fprintf(stderr, " %s ", "[yes/NO]");
if (fgets(response, 32, stdin)) { if (fgets(response, 32, stdin)) {
(void)strtrim(response); (void)strtrim(response);
if (strlen(response) == 0) if (strlen(response) == 0)
return preset; return preset;
if ((strcasecmp(response, "y") == 0) || if (strcasecmp(response, "yes") == 0)
(strcasecmp(response, "yes") == 0))
return true; return true;
else if ((strcasecmp(response, "n") == 0) || else if (strcasecmp(response, "no") == 0)
(strcasecmp(response, "no") == 0))
return false; return false;
} }
return false; return false;