Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/coreutils/wc.c

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

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 36  Line 36 
36   * (adapted from example in gnu wc.c)   * (adapted from example in gnu wc.c)
37   *   *
38   *      echo hello > /tmp/testfile &&   *      echo hello > /tmp/testfile &&
39   *      (dd ibs=1k skip=1 count=0 &> /dev/null ; wc -c) < /tmp/testfile   *      (dd ibs=1k skip=1 count=0 &> /dev/null; wc -c) < /tmp/testfile
40   *   *
41   * for which 'wc -c' should output '0'.   * for which 'wc -c' should output '0'.
42   */   */
43    
44  #include "busybox.h"  #include "libbb.h"
45    
46  #ifdef CONFIG_LOCALE_SUPPORT  #if ENABLE_LOCALE_SUPPORT
47  #define isspace_given_isprint(c) isspace(c)  #define isspace_given_isprint(c) isspace(c)
48  #else  #else
49  #undef isspace  #undef isspace
# Line 68  enum { Line 68  enum {
68   WC_LENGTH = 3   WC_LENGTH = 3
69  };  };
70    
71  int wc_main(int argc, char **argv)  int wc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
72    int wc_main(int argc UNUSED_PARAM, char **argv)
73  {  {
74   FILE *fp;   FILE *fp;
75   const char *s, *arg;   const char *s, *arg;
76   const char *start_fmt = "%9"COUNT_FMT;   const char *start_fmt = " %9"COUNT_FMT + 1;
77   const char *fname_fmt = " %s\n";   const char *fname_fmt = " %s\n";
78   COUNT_T *pcounts;   COUNT_T *pcounts;
79   COUNT_T counts[4];   COUNT_T counts[4];
# Line 81  int wc_main(int argc, char **argv) Line 82  int wc_main(int argc, char **argv)
82   unsigned u;   unsigned u;
83   int num_files = 0;   int num_files = 0;
84   int c;   int c;
85   char status = EXIT_SUCCESS;   smallint status = EXIT_SUCCESS;
86   char in_word;   smallint in_word;
87   unsigned print_type;   unsigned print_type;
88    
89   print_type = getopt32(argc, argv, "lwcL");   print_type = getopt32(argv, "lwcL");
90    
91   if (print_type == 0) {   if (print_type == 0) {
92   print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);   print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
# Line 149  int wc_main(int argc, char **argv) Line 150  int wc_main(int argc, char **argv)
150   }   }
151   } else if (c == EOF) {   } else if (c == EOF) {
152   if (ferror(fp)) {   if (ferror(fp)) {
153   bb_perror_msg("%s", arg);   bb_simple_perror_msg(arg);
154   status = EXIT_FAILURE;   status = EXIT_FAILURE;
155   }   }
156   --counts[WC_CHARS];   --counts[WC_CHARS];

Legend:
Removed from v.815  
changed lines
  Added in v.816