libbb/ask_confirmation.c: shrink
function old new delta bb_ask_confirmation 95 76 -19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
b204e6b61a
commit
52b971f516
@ -10,23 +10,18 @@
|
|||||||
/* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y',
|
/* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y',
|
||||||
* return 1. Otherwise return 0.
|
* return 1. Otherwise return 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
int FAST_FUNC bb_ask_confirmation(void)
|
int FAST_FUNC bb_ask_confirmation(void)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
char first = 0;
|
||||||
int first = 1;
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while (((c = getchar()) != EOF) && (c != '\n')) {
|
while (((c = getchar()) != EOF) && (c != '\n')) {
|
||||||
if (first && !isspace(c)) {
|
if (first == 0 && !isblank(c)) {
|
||||||
--first;
|
first = c|0x20;
|
||||||
if ((c == 'y') || (c == 'Y')) {
|
|
||||||
++retval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return first == 'y';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user