Magellan Linux

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

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

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 11  Line 11 
11  /* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */  /* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
12  /* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */  /* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
13    
14  #include "busybox.h"  #include "libbb.h"
15    
16  static const char head_opts[] =  static const char head_opts[] ALIGN1 =
17   "n:"   "n:"
18  #if ENABLE_FEATURE_FANCY_HEAD  #if ENABLE_FEATURE_FANCY_HEAD
19   "c:qv"   "c:qv"
# Line 25  static const struct suffix_mult head_suf Line 25  static const struct suffix_mult head_suf
25   { "b", 512 },   { "b", 512 },
26   { "k", 1024 },   { "k", 1024 },
27   { "m", 1024*1024 },   { "m", 1024*1024 },
28   { NULL, 0 }   { }
29  };  };
30  #endif  #endif
31    
32  static const char header_fmt_str[] = "\n==> %s <==\n";  static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n";
33    
34    int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
35  int head_main(int argc, char **argv)  int head_main(int argc, char **argv)
36  {  {
37   unsigned long count = 10;   unsigned long count = 10;
# Line 90  int head_main(int argc, char **argv) Line 91  int head_main(int argc, char **argv)
91   }   }
92   }   }
93    
94     argc -= optind;
95   argv += optind;   argv += optind;
96   if (!*argv) {   if (!*argv)
97   *--argv = "-";   *--argv = (char*)"-";
  }  
98    
99   fmt = header_fmt_str + 1;   fmt = header_fmt_str + 1;
100  #if ENABLE_FEATURE_FANCY_HEAD  #if ENABLE_FEATURE_FANCY_HEAD
101   if (argc - optind <= header_threshhold) {   if (argc <= header_threshhold) {
102   header_threshhold = 0;   header_threshhold = 0;
103   }   }
104  #else  #else
105   if (argc <= optind + 1) {   if (argc <= 1) {
106   fmt += 11;   fmt += 11; /* "" */
107   }   }
108   /* Now define some things here to avoid #ifdefs in the code below.   /* Now define some things here to avoid #ifdefs in the code below.
109   * These should optimize out of the if conditions below. */   * These should optimize out of the if conditions below. */
# Line 127  int head_main(int argc, char **argv) Line 128  int head_main(int argc, char **argv)
128   putchar(c);   putchar(c);
129   }   }
130   if (fclose_if_not_stdin(fp)) {   if (fclose_if_not_stdin(fp)) {
131   bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */   bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
132   retval = EXIT_FAILURE;   retval = EXIT_FAILURE;
133   }   }
134   die_if_ferror_stdout();   die_if_ferror_stdout();

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