diff options
author | Sami Kerola | 2012-03-18 13:11:46 +0100 |
---|---|---|
committer | Karel Zak | 2012-03-30 16:48:12 +0200 |
commit | d4a573bc7bb272f0867ed2067ba5fe7dd6c21eaf (patch) | |
tree | 72f248bee5c96140a6ab573a4d8d823f6943961a /disk-utils/fsck.minix.c | |
parent | fsck.minix: use symbolic exit codes (diff) | |
download | kernel-qcow2-util-linux-d4a573bc7bb272f0867ed2067ba5fe7dd6c21eaf.tar.gz kernel-qcow2-util-linux-d4a573bc7bb272f0867ed2067ba5fe7dd6c21eaf.tar.xz kernel-qcow2-util-linux-d4a573bc7bb272f0867ed2067ba5fe7dd6c21eaf.zip |
fsck.minix: use rpmatch() for yes/no question
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/fsck.minix.c')
-rw-r--r-- | disk-utils/fsck.minix.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index 17ac181bb..4aeaf743b 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -111,6 +111,7 @@ #include "writeall.h" #define ROOT_INO 1 +#define YESNO_LENGTH 64 /* * Global variables used in minix_programs.h inline fuctions @@ -238,7 +239,8 @@ get_current_name(void) { static int ask(const char * string, int def) { - int c; + int resp; + char input[YESNO_LENGTH]; if (!repair) { printf("\n"); @@ -251,30 +253,30 @@ ask(const char * string, int def) { errors_uncorrected = 1; return def; } - printf(def?"%s (y/n)? ":"%s (n/y)? ",string); - for (;;) { - fflush(stdout); - if ((c=getchar())==EOF) { - if (!def) - errors_uncorrected = 1; - return def; - } - c=toupper(c); - if (c == 'Y') { - def = 1; - break; - } else if (c == 'N') { - def = 0; - break; - } else if (c == ' ' || c == '\n') - break; + /* TRANSLATORS: these yes no questions uses rpmatch(), and should be + * translated. */ + printf(def ? _("%s (y/n)? ") : _("%s (n/y)? "), string); + fflush(stdout); + fgets(input, YESNO_LENGTH, stdin); + resp = rpmatch(input); + switch (resp) { + case -1: + /* def = def */ + break; + case 0: + case 1: + def = resp; + break; + default: + /* rpmatch bug? */ + abort(); } if (def) - printf("y\n"); + printf(_("y\n")); else { - printf("n\n"); + printf(_("n\n")); errors_uncorrected = 1; - } + } return def; } |