Move the tail -c option from FANCY_TAIL to the default tail, this makes
the default tail options conform to SUSv3, with the non-SUS option all in FANCY_TAIL
This commit is contained in:
parent
0120be94a0
commit
4ef5a84583
@ -420,11 +420,12 @@ config CONFIG_TAIL
|
|||||||
from files.
|
from files.
|
||||||
|
|
||||||
config CONFIG_FEATURE_FANCY_TAIL
|
config CONFIG_FEATURE_FANCY_TAIL
|
||||||
bool " Enable extra tail options (-c, -q, -s, and -v)"
|
bool " Enable extra tail options (-q, -s, and -v)"
|
||||||
default y
|
default y
|
||||||
depends on CONFIG_TAIL
|
depends on CONFIG_TAIL
|
||||||
help
|
help
|
||||||
Enable tail options (-c, -q, -s, and -v).
|
The options (-q, -s, and -v) are provided by GNU tail, but
|
||||||
|
are not specific in the SUSv3 standard.
|
||||||
|
|
||||||
config CONFIG_TEE
|
config CONFIG_TEE
|
||||||
bool "tee"
|
bool "tee"
|
||||||
|
@ -89,9 +89,9 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char tail_opts[] =
|
static const char tail_opts[] =
|
||||||
"fn:"
|
"fn:c:"
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
||||||
"c:qs:v"
|
"qs:v"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -104,9 +104,7 @@ int tail_main(int argc, char **argv)
|
|||||||
int from_top = 0;
|
int from_top = 0;
|
||||||
int follow = 0;
|
int follow = 0;
|
||||||
int header_threshhold = 1;
|
int header_threshhold = 1;
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
|
||||||
int count_bytes = 0;
|
int count_bytes = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
char *tailbuf;
|
char *tailbuf;
|
||||||
size_t tailbufsize;
|
size_t tailbufsize;
|
||||||
@ -132,11 +130,9 @@ int tail_main(int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
follow = 1;
|
follow = 1;
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
|
||||||
case 'c':
|
case 'c':
|
||||||
count_bytes = 1;
|
count_bytes = 1;
|
||||||
/* FALLS THROUGH */
|
/* FALLS THROUGH */
|
||||||
#endif
|
|
||||||
case 'n':
|
case 'n':
|
||||||
GET_COUNT:
|
GET_COUNT:
|
||||||
count = bb_xgetlarg10_sfx(optarg, tail_suffixes);
|
count = bb_xgetlarg10_sfx(optarg, tail_suffixes);
|
||||||
@ -201,7 +197,7 @@ int tail_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tailbufsize = BUFSIZ;
|
tailbufsize = BUFSIZ;
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
|
||||||
/* tail the files */
|
/* tail the files */
|
||||||
if (from_top < count_bytes) { /* Each is 0 or 1, so true iff 0 < 1. */
|
if (from_top < count_bytes) { /* Each is 0 or 1, so true iff 0 < 1. */
|
||||||
/* Hence, !from_top && count_bytes */
|
/* Hence, !from_top && count_bytes */
|
||||||
@ -209,7 +205,7 @@ int tail_main(int argc, char **argv)
|
|||||||
tailbufsize = count + BUFSIZ;
|
tailbufsize = count + BUFSIZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
buf = tailbuf = xmalloc(tailbufsize);
|
buf = tailbuf = xmalloc(tailbufsize);
|
||||||
|
|
||||||
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
|
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
|
||||||
@ -237,13 +233,10 @@ int tail_main(int argc, char **argv)
|
|||||||
if (from_top) {
|
if (from_top) {
|
||||||
nwrite = nread;
|
nwrite = nread;
|
||||||
if (seen < count) {
|
if (seen < count) {
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
|
||||||
if (count_bytes) {
|
if (count_bytes) {
|
||||||
nwrite -= (count - seen);
|
nwrite -= (count - seen);
|
||||||
seen = count;
|
seen = count;
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
s = buf;
|
s = buf;
|
||||||
do {
|
do {
|
||||||
--nwrite;
|
--nwrite;
|
||||||
@ -255,16 +248,13 @@ int tail_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
tail_xbb_full_write(buf + nread - nwrite, nwrite);
|
tail_xbb_full_write(buf + nread - nwrite, nwrite);
|
||||||
} else if (count) {
|
} else if (count) {
|
||||||
#ifdef CONFIG_FEATURE_FANCY_TAIL
|
|
||||||
if (count_bytes) {
|
if (count_bytes) {
|
||||||
taillen += nread;
|
taillen += nread;
|
||||||
if (taillen > count) {
|
if (taillen > count) {
|
||||||
memmove(tailbuf, tailbuf + taillen - count, count);
|
memmove(tailbuf, tailbuf + taillen - count, count);
|
||||||
taillen = count;
|
taillen = count;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
int k = nread;
|
int k = nread;
|
||||||
int nbuf = 0;
|
int nbuf = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user