Magellan Linux

Annotation of /tags/mkinitrd-6_2_0/libbb/ask_confirmation.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 816 - (hide annotations) (download)
Fri Apr 24 18:33:46 2009 UTC (15 years, 5 months ago) by niro
Original Path: trunk/mkinitrd-magellan/busybox/libbb/ask_confirmation.c
File MIME type: text/plain
File size: 723 byte(s)
-updated to busybox-1.13.4
1 niro 532 /* 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 tarball for details.
8     */
9    
10     /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y',
11     * return 1. Otherwise return 0.
12     */
13    
14     #include "libbb.h"
15    
16 niro 816 int FAST_FUNC bb_ask_confirmation(void)
17 niro 532 {
18     int retval = 0;
19     int first = 1;
20     int c;
21    
22     while (((c = getchar()) != EOF) && (c != '\n')) {
23     /* Make sure we get the actual function call for isspace,
24     * as speed is not critical here. */
25     if (first && !(isspace)(c)) {
26     --first;
27     if ((c == 'y') || (c == 'Y')) {
28     ++retval;
29     }
30     }
31     }
32    
33     return retval;
34     }