Bump to version 1.22.1
[platform/upstream/busybox.git] / libbb / ask_confirmation.c
index d08bc51..d95729c 100644 (file)
@@ -4,31 +4,24 @@
  *
  * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 /* 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')) {
-               /* Make sure we get the actual function call for isspace,
-                * as speed is not critical here. */
-               if (first && !(isspace)(c)) {
-                       --first;
-                       if ((c == 'y') || (c == 'Y')) {
-                               ++retval;
-                       }
+               if (first == 0 && !isblank(c)) {
+                       first = c|0x20;
                }
        }
 
-       return retval;
+       return first == 'y';
 }