Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/libbb/ask_confirmation.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 10  Line 10 
10  /* 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',
11   * return 1.  Otherwise return 0.   * return 1.  Otherwise return 0.
12   */   */
   
13  #include "libbb.h"  #include "libbb.h"
14    
15  int FAST_FUNC bb_ask_confirmation(void)  int FAST_FUNC bb_ask_confirmation(void)
16  {  {
17   int retval = 0;   char first = 0;
  int first = 1;  
18   int c;   int c;
19    
20   while (((c = getchar()) != EOF) && (c != '\n')) {   while (((c = getchar()) != EOF) && (c != '\n')) {
21   /* Make sure we get the actual function call for isspace,   if (first == 0 && !isblank(c)) {
22   * as speed is not critical here. */   first = c|0x20;
  if (first && !(isspace)(c)) {  
  --first;  
  if ((c == 'y') || (c == 'Y')) {  
  ++retval;  
  }  
23   }   }
24   }   }
25    
26   return retval;   return first == 'y';
27  }  }

Legend:
Removed from v.983  
changed lines
  Added in v.984