diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-27 09:49:04 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-27 09:49:04 +0100 |
commit | 52b971f516efc3acb8c69536c3b7be7b7c3bf1c0 (patch) | |
tree | d7ada98f78a74d560a96d1c5d0e0e8f903f8c666 /libbb/ask_confirmation.c | |
parent | b204e6b61a10794d664427a3c1dd5f012ebbbe65 (diff) | |
download | busybox-w32-52b971f516efc3acb8c69536c3b7be7b7c3bf1c0.tar.gz busybox-w32-52b971f516efc3acb8c69536c3b7be7b7c3bf1c0.tar.bz2 busybox-w32-52b971f516efc3acb8c69536c3b7be7b7c3bf1c0.zip |
libbb/ask_confirmation.c: shrink
function old new delta
bb_ask_confirmation 95 76 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/ask_confirmation.c')
-rw-r--r-- | libbb/ask_confirmation.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/libbb/ask_confirmation.c b/libbb/ask_confirmation.c index 9dfbd15cf..e0e94195e 100644 --- a/libbb/ask_confirmation.c +++ b/libbb/ask_confirmation.c | |||
@@ -10,23 +10,18 @@ | |||
10 | /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', | 10 | /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', |
11 | * return 1. Otherwise return 0. | 11 | * return 1. Otherwise return 0. |
12 | */ | 12 | */ |
13 | |||
14 | #include "libbb.h" | 13 | #include "libbb.h" |
15 | 14 | ||
16 | int FAST_FUNC bb_ask_confirmation(void) | 15 | int FAST_FUNC bb_ask_confirmation(void) |
17 | { | 16 | { |
18 | int retval = 0; | 17 | char first = 0; |
19 | int first = 1; | ||
20 | int c; | 18 | int c; |
21 | 19 | ||
22 | while (((c = getchar()) != EOF) && (c != '\n')) { | 20 | while (((c = getchar()) != EOF) && (c != '\n')) { |
23 | if (first && !isspace(c)) { | 21 | if (first == 0 && !isblank(c)) { |
24 | --first; | 22 | first = c|0x20; |
25 | if ((c == 'y') || (c == 'Y')) { | ||
26 | ++retval; | ||
27 | } | ||
28 | } | 23 | } |
29 | } | 24 | } |
30 | 25 | ||
31 | return retval; | 26 | return first == 'y'; |
32 | } | 27 | } |