From: Thibault Godouet Date: Wed, 21 Nov 2012 23:34:11 +0000 (+0000) Subject: fcrontab: don't alert about invalid character when correcting fcrontab twice X-Git-Tag: ver3_1_0~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c518bbf1c22953573a6f6777753651d93b3d6eb;p=thirdparty%2Ffcron.git fcrontab: don't alert about invalid character when correcting fcrontab twice --- diff --git a/fcrontab.c b/fcrontab.c index d75a9ab..1378c41 100644 --- a/fcrontab.c +++ b/fcrontab.c @@ -573,18 +573,24 @@ edit_file(char *fcron_orig) case 2: fprintf(stderr, "\nFile contains some errors. " "Ignore [i] or Correct [c] ? "); - /* the 2nd getchar() is for the newline char (\n) */ - while ( (c = getchar()) && c != 'i' && c != 'c' ) { - fprintf(stderr, "Please press c to correct, " - "or i to ignore: "); - while (c != '\n') - c = getchar(); - } - if ( c == 'c' ) { - /* free memory used to store the list */ - delete_file(user); - correction = 1; - } + while ( (c = getchar()) ) { + /* consume the rest of the line, e.g. the newline char (\n) */ + while (c != '\n' && (getchar() != '\n') ); + + if (c == 'i') { + break; + } + else if ( c == 'c' ) { + /* free memory used to store the list */ + delete_file(user); + correction = 1; + break; + } + else { + fprintf(stderr, "Please press c to correct, " + "or i to ignore: "); + } + } break; default: break;