diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-01-24 21:38:10 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-01-24 21:38:10 +0000 |
commit | 84d2d493b4b664d1465cff955367fb9bc7769e5d (patch) | |
tree | 8ad2bb065852abd9b737a3b6f4eca06a83c06562 /coreutils/tail.c | |
parent | 7b1c5aacb0964e1b58a245cf7336cbfc4245de64 (diff) | |
download | busybox-w32-84d2d493b4b664d1465cff955367fb9bc7769e5d.tar.gz busybox-w32-84d2d493b4b664d1465cff955367fb9bc7769e5d.tar.bz2 busybox-w32-84d2d493b4b664d1465cff955367fb9bc7769e5d.zip |
- remove nested function. Saves ~30 bytes.
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r-- | coreutils/tail.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c index 4baffeed1..f1ba04ec6 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -62,11 +62,17 @@ static ssize_t tail_read(int fd, char *buf, size_t count) | |||
62 | 62 | ||
63 | static const char header_fmt[] = "\n==> %s <==\n"; | 63 | static const char header_fmt[] = "\n==> %s <==\n"; |
64 | 64 | ||
65 | static unsigned eat_num(const char *p) { | ||
66 | if (*p == '-') p++; | ||
67 | else if (*p == '+') { p++; status = 1; } | ||
68 | return xatou_sfx(p, tail_suffixes); | ||
69 | } | ||
70 | |||
65 | int tail_main(int argc, char **argv) | 71 | int tail_main(int argc, char **argv) |
66 | { | 72 | { |
67 | unsigned count = 10; | 73 | unsigned count = 10; |
68 | unsigned sleep_period = 1; | 74 | unsigned sleep_period = 1; |
69 | bool from_top = 0; | 75 | bool from_top; |
70 | int header_threshhold = 1; | 76 | int header_threshhold = 1; |
71 | const char *str_c, *str_n, *str_s; | 77 | const char *str_c, *str_n, *str_s; |
72 | 78 | ||
@@ -80,13 +86,6 @@ int tail_main(int argc, char **argv) | |||
80 | char *s, *buf; | 86 | char *s, *buf; |
81 | const char *fmt; | 87 | const char *fmt; |
82 | 88 | ||
83 | void eat_num(const char *p) { | ||
84 | if (*p == '-') p++; | ||
85 | else if (*p == '+') { p++; from_top = 1; } | ||
86 | count = xatou_sfx(p, tail_suffixes); | ||
87 | } | ||
88 | |||
89 | |||
90 | #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL | 89 | #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL |
91 | /* Allow legacy syntax of an initial numeric option without -n. */ | 90 | /* Allow legacy syntax of an initial numeric option without -n. */ |
92 | if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-') | 91 | if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-') |
@@ -102,8 +101,8 @@ int tail_main(int argc, char **argv) | |||
102 | #define FOLLOW (opt & 0x1) | 101 | #define FOLLOW (opt & 0x1) |
103 | #define COUNT_BYTES (opt & 0x2) | 102 | #define COUNT_BYTES (opt & 0x2) |
104 | //if (opt & 0x1) // -f | 103 | //if (opt & 0x1) // -f |
105 | if (opt & 0x2) eat_num(str_c); // -c | 104 | if (opt & 0x2) count = eat_num(str_c); // -c |
106 | if (opt & 0x4) eat_num(str_n); // -n | 105 | if (opt & 0x4) count = eat_num(str_n); // -n |
107 | #if ENABLE_FEATURE_FANCY_TAIL | 106 | #if ENABLE_FEATURE_FANCY_TAIL |
108 | if (opt & 0x8) header_threshhold = INT_MAX; // -q | 107 | if (opt & 0x8) header_threshhold = INT_MAX; // -q |
109 | if (opt & 0x10) sleep_period = xatou(str_s); // -s | 108 | if (opt & 0x10) sleep_period = xatou(str_s); // -s |
@@ -111,10 +110,11 @@ int tail_main(int argc, char **argv) | |||
111 | #endif | 110 | #endif |
112 | argc -= optind; | 111 | argc -= optind; |
113 | argv += optind; | 112 | argv += optind; |
113 | from_top = status; | ||
114 | 114 | ||
115 | /* open all the files */ | 115 | /* open all the files */ |
116 | fds = xmalloc(sizeof(int) * (argc + 1)); | 116 | fds = xmalloc(sizeof(int) * (argc + 1)); |
117 | nfiles = i = 0; | 117 | status = nfiles = i = 0; |
118 | if (argc == 0) { | 118 | if (argc == 0) { |
119 | struct stat statbuf; | 119 | struct stat statbuf; |
120 | 120 | ||