aboutsummaryrefslogtreecommitdiff
path: root/libbb/ask_confirmation.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /libbb/ask_confirmation.c
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
Major coreutils update.
Diffstat (limited to 'libbb/ask_confirmation.c')
-rw-r--r--libbb/ask_confirmation.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/libbb/ask_confirmation.c b/libbb/ask_confirmation.c
index d4d943ad7..a99a4e733 100644
--- a/libbb/ask_confirmation.c
+++ b/libbb/ask_confirmation.c
@@ -1,49 +1,49 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Utility routines. 3 * bb_ask_confirmation implementation for busybox
4 * 4 *
5 * Copyright (C) many different people. If you wrote this, please 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 * acknowledge your work.
7 * 6 *
8 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 10 * (at your option) any later version.
12 * 11 *
13 * This program is distributed in the hope that it will be useful, but 12 * This program is distributed in the hope that it will be useful,
14 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 15 * General Public License for more details.
17 * 16 *
18 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * USA 20 *
21 */
22
23/* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y',
24 * return 1. Otherwise return 0.
22 */ 25 */
23 26
24#include <stdio.h> 27#include <stdio.h>
28#include <ctype.h>
25#include "libbb.h" 29#include "libbb.h"
26 30
27 31int bb_ask_confirmation(void)
28int ask_confirmation()
29{ 32{
30 int c = '\0'; 33 int retval = 0;
31 int ret = 0; 34 int first = 1;
35 int c;
32 36
33 while (c != '\n') { 37 while (((c = getchar()) != EOF) && (c != '\n')) {
34 c = getchar(); 38 /* Make sure we get the actual function call for isspace,
35 if ( c != '\n' ) { 39 * as speed is not critical here. */
36 ret = ((c=='y')||(c=='Y')) ? 1 : 0; 40 if (first && !(isspace)(c)) {
41 --first;
42 if ((c == 'y') || (c == 'Y')) {
43 ++retval;
44 }
37 } 45 }
38 } 46 }
39 return ret;
40}
41 47
42/* END CODE */ 48 return retval;
43/* 49}
44Local Variables:
45c-file-style: "linux"
46c-basic-offset: 4
47tab-width: 4
48End:
49*/