question: accept enter key as default preset value.

This commit is contained in:
Juan RP 2015-01-12 10:22:30 +01:00
parent f7142412c9
commit 8f1e7d9e55

View File

@ -49,9 +49,8 @@ question(bool preset, const char *fmt, va_list ap)
fprintf(stderr, " %s ", "[y/N]"); fprintf(stderr, " %s ", "[y/N]");
if (fgets(response, sizeof(response), stdin)) { if (fgets(response, sizeof(response), stdin)) {
if (strlen(response) == 0) if (response[0] == '\n')
return preset; return preset;
if (response[0] == 'y' || response[0] == 'Y') if (response[0] == 'y' || response[0] == 'Y')
return true; return true;
if (response[0] == 'n' || response[0] == 'N') if (response[0] == 'n' || response[0] == 'N')