traceroute: fix help text to not show -6 when traceroute6 is off
[oweals/busybox.git] / libbb / ask_confirmation.c
index 9dfbd15cfd87e9f9589dbe642fc7d68e7b7b00c4..e0e94195ecb03d8f11043512e7b0d552f60edca2 100644 (file)
 /* Read a line from stdin.  If the first non-whitespace char is 'y' or 'Y',
  * return 1.  Otherwise return 0.
  */
-
 #include "libbb.h"
 
 int FAST_FUNC bb_ask_confirmation(void)
 {
-       int retval = 0;
-       int first = 1;
+       char first = 0;
        int c;
 
        while (((c = getchar()) != EOF) && (c != '\n')) {
-               if (first && !isspace(c)) {
-                       --first;
-                       if ((c == 'y') || (c == 'Y')) {
-                               ++retval;
-                       }
+               if (first == 0 && !isblank(c)) {
+                       first = c|0x20;
                }
        }
 
-       return retval;
+       return first == 'y';
 }