Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/head.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/coreutils/head.c
r1765 r2725 5 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> 6 6 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 9 … … 14 14 #include "libbb.h" 15 15 16 /* This is a NOEXEC applet. Be very careful! */ 17 16 18 static const char head_opts[] ALIGN1 = 17 19 "n:" … … 21 23 ; 22 24 23 #if ENABLE_FEATURE_FANCY_HEAD24 25 static const struct suffix_mult head_suffixes[] = { 25 26 { "b", 512 }, 26 27 { "k", 1024 }, 27 28 { "m", 1024*1024 }, 28 { }29 { "", 0 } 29 30 }; 30 #endif31 31 32 static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n"; 32 #define header_fmt_str "\n==> %s <==\n" 33 33 34 int head_main(int argc, char **argv) ;34 int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 35 35 int head_main(int argc, char **argv) 36 36 { … … 41 41 int header_threshhold = 1; 42 42 #endif 43 44 43 FILE *fp; 45 44 const char *fmt; … … 51 50 #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD 52 51 /* Allow legacy syntax of an initial numeric option without -n. */ 53 if (arg c > 1&& argv[1][0] == '-'52 if (argv[1] && argv[1][0] == '-' 54 53 && isdigit(argv[1][1]) 55 54 ) { … … 80 79 GET_COUNT: 81 80 #endif 82 83 #if !ENABLE_FEATURE_FANCY_HEAD84 count = xatoul(p);85 #else86 81 count = xatoul_sfx(p, head_suffixes); 87 #endif88 82 break; 89 83 default: … … 92 86 } 93 87 88 argc -= optind; 94 89 argv += optind; 95 if (!*argv) {90 if (!*argv) 96 91 *--argv = (char*)"-"; 97 }98 92 99 93 fmt = header_fmt_str + 1; 100 94 #if ENABLE_FEATURE_FANCY_HEAD 101 if (argc - optind<= header_threshhold) {95 if (argc <= header_threshhold) { 102 96 header_threshhold = 0; 103 97 } 104 98 #else 105 if (argc <= optind +1) {106 fmt += 11; 99 if (argc <= 1) { 100 fmt += 11; /* "" */ 107 101 } 108 102 /* Now define some things here to avoid #ifdefs in the code below. … … 129 123 } 130 124 if (fclose_if_not_stdin(fp)) { 131 bb_ perror_msg("%s", *argv); /* Avoid multibyte problems. */125 bb_simple_perror_msg(*argv); 132 126 retval = EXIT_FAILURE; 133 127 } 134 128 die_if_ferror_stdout(); 129 } else { 130 retval = EXIT_FAILURE; 135 131 } 136 132 fmt = header_fmt_str;
Note:
See TracChangeset
for help on using the changeset viewer.