whitespace and comment format fixes, no code changes
[oweals/busybox.git] / libbb / ask_confirmation.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * bb_ask_confirmation implementation for busybox
4  *
5  * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
6  *
7  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8  */
9 #include "libbb.h"
10
11 /* Read a line from stdin.  If the first non-whitespace char is 'y' or 'Y',
12  * return 1.  Otherwise return 0.
13  */
14 int FAST_FUNC bb_ask_confirmation(void)
15 {
16         char first = 0;
17         int c;
18
19         while (((c = getchar()) != EOF) && (c != '\n')) {
20                 if (first == 0 && !isblank(c)) {
21                         first = c|0x20;
22                 }
23         }
24
25         return first == 'y';
26 }