aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-01-24 21:38:10 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-01-24 21:38:10 +0000
commit84d2d493b4b664d1465cff955367fb9bc7769e5d (patch)
tree8ad2bb065852abd9b737a3b6f4eca06a83c06562 /coreutils
parent7b1c5aacb0964e1b58a245cf7336cbfc4245de64 (diff)
downloadbusybox-84d2d493b4b664d1465cff955367fb9bc7769e5d.tar.gz
- remove nested function. Saves ~30 bytes.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/tail.c22
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)
static const char header_fmt[] = "\n==> %s <==\n";
+static unsigned eat_num(const char *p) {
+ if (*p == '-') p++;
+ else if (*p == '+') { p++; status = 1; }
+ return xatou_sfx(p, tail_suffixes);
+}
+
int tail_main(int argc, char **argv)
{
unsigned count = 10;
unsigned sleep_period = 1;
- bool from_top = 0;
+ bool from_top;
int header_threshhold = 1;
const char *str_c, *str_n, *str_s;
@@ -80,13 +86,6 @@ int tail_main(int argc, char **argv)
char *s, *buf;
const char *fmt;
- void eat_num(const char *p) {
- if (*p == '-') p++;
- else if (*p == '+') { p++; from_top = 1; }
- count = xatou_sfx(p, tail_suffixes);
- }
-
-
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
/* Allow legacy syntax of an initial numeric option without -n. */
if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
@@ -102,8 +101,8 @@ int tail_main(int argc, char **argv)
#define FOLLOW (opt & 0x1)
#define COUNT_BYTES (opt & 0x2)
//if (opt & 0x1) // -f
- if (opt & 0x2) eat_num(str_c); // -c
- if (opt & 0x4) eat_num(str_n); // -n
+ if (opt & 0x2) count = eat_num(str_c); // -c
+ if (opt & 0x4) count = eat_num(str_n); // -n
#if ENABLE_FEATURE_FANCY_TAIL
if (opt & 0x8) header_threshhold = INT_MAX; // -q
if (opt & 0x10) sleep_period = xatou(str_s); // -s
@@ -111,10 +110,11 @@ int tail_main(int argc, char **argv)
#endif
argc -= optind;
argv += optind;
+ from_top = status;
/* open all the files */
fds = xmalloc(sizeof(int) * (argc + 1));
- nfiles = i = 0;
+ status = nfiles = i = 0;
if (argc == 0) {
struct stat statbuf;