[git commit master] libbb/ask_confirmation.c: shrink

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 27 08:49:04 UTC 2009


commit: http://git.busybox.net/busybox/commit/?id=52b971f516efc3acb8c69536c3b7be7b7c3bf1c0
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
bb_ask_confirmation                                   95      76     -19

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 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 9dfbd15..e0e9419 100644
--- a/libbb/ask_confirmation.c
+++ b/libbb/ask_confirmation.c
@@ -10,23 +10,18 @@
 /* Read a line from stdin.  If the first non-whitespace char is 'y' or 'Y',
  * return 1.  Otherwise return 0.
  */
-
 #include "libbb.h"
 
 int FAST_FUNC bb_ask_confirmation(void)
 {
-	int retval = 0;
-	int first = 1;
+	char first = 0;
 	int c;
 
 	while (((c = getchar()) != EOF) && (c != '\n')) {
-		if (first && !isspace(c)) {
-			--first;
-			if ((c == 'y') || (c == 'Y')) {
-				++retval;
-			}
+		if (first == 0 && !isblank(c)) {
+			first = c|0x20;
 		}
 	}
 
-	return retval;
+	return first == 'y';
 }
-- 
1.6.3.3



More information about the busybox-cvs mailing list