]> granicus.if.org Git - fcron/commitdiff
fcrontab: don't alert about invalid character when correcting fcrontab twice
authorThibault Godouet <fcron@free.fr>
Wed, 21 Nov 2012 23:34:11 +0000 (23:34 +0000)
committerThibault Godouet <fcron@free.fr>
Wed, 21 Nov 2012 23:34:11 +0000 (23:34 +0000)
fcrontab.c

index d75a9abe70a0663071b92db94b5aae3a50f8fffa..1378c41a7a470b04fef0b09af0312691b46adc4e 100644 (file)
@@ -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;