projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove #ifdef __STDC__ junk. We don't do K&R round these parts,
[oweals/busybox.git]
/
coreutils
/
tail.c
diff --git
a/coreutils/tail.c
b/coreutils/tail.c
index c940bfef75cb61ede918be18343ed8a405f56fec..a9da95462efc2743cbdffa3b59cd648f3683719b 100644
(file)
--- a/
coreutils/tail.c
+++ b/
coreutils/tail.c
@@
-38,7
+38,7
@@
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
-#include "
internal
.h"
+#include "
busybox
.h"
#define STDIN "standard input"
#define LINES 0
#define STDIN "standard input"
#define LINES 0
@@
-61,7
+61,7
@@
static char verbose = 0;
static off_t units=0;
static off_t units=0;
-int tail_stream(int fd)
+
static
int tail_stream(int fd)
{
ssize_t startpoint;
ssize_t endpoint=0;
{
ssize_t startpoint;
ssize_t endpoint=0;
@@
-87,12
+87,12
@@
int tail_stream(int fd)
ssize_t f_size=0;
bs=BUFSIZ;
ssize_t f_size=0;
bs=BUFSIZ;
- line=malloc(bs);
+ line=
x
malloc(bs);
while(1) {
bytes_read=read(fd,line,bs);
if(bytes_read<=0)
break;
while(1) {
bytes_read=read(fd,line,bs);
if(bytes_read<=0)
break;
- buffer=realloc(buffer,f_size+bytes_read);
+ buffer=
x
realloc(buffer,f_size+bytes_read);
memcpy(&buffer[f_size],line,bytes_read);
filelocation=f_size+=bytes_read;
}
memcpy(&buffer[f_size],line,bytes_read);
filelocation=f_size+=bytes_read;
}
@@
-150,23
+150,11
@@
int tail_stream(int fd)
void add_file(char *name)
{
++n_files;
void add_file(char *name)
{
++n_files;
- files = realloc(files, n_files);
- files[n_files - 1] = (char *) malloc(strlen(name) + 1);
+ files =
x
realloc(files, n_files);
+ files[n_files - 1] = (char *)
x
malloc(strlen(name) + 1);
strcpy(files[n_files - 1], name);
}
strcpy(files[n_files - 1], name);
}
-void checknumbers(const char* name)
-{
- int test=atoi(name);
- if(test){
- units=test;
- if(units<0)
- units=units-1;
- } else {
- fatalError("Unrecognised number '%s'\n", name);
- }
-}
-
int tail_main(int argc, char **argv)
{
int show_headers = 1;
int tail_main(int argc, char **argv)
{
int show_headers = 1;
@@
-178,14
+166,9
@@
int tail_main(int argc, char **argv)
opterr = 0;
opterr = 0;
- while ((opt=getopt(argc,argv,"c:fhn:s:q:v
123456789+
")) >0) {
+ while ((opt=getopt(argc,argv,"c:fhn:s:q:v")) >0) {
switch (opt) {
switch (opt) {
- case '1':case '2':case '3':case '4':case '5':
- case '6':case '7':case '8':case '9':case '0':
- checknumbers(argv[optind-1]);
- break;
-
#ifndef BB_FEATURE_SIMPLE_TAIL
case 'c':
unit_type = BYTES;
#ifndef BB_FEATURE_SIMPLE_TAIL
case 'c':
unit_type = BYTES;
@@
-253,10
+236,7
@@
int tail_main(int argc, char **argv)
else
break;
}else {
else
break;
}else {
- if (*argv[optind] == '+') {
- checknumbers(argv[optind]);
- }
- else if (!strcmp(argv[optind], "-")) {
+ if (!strcmp(argv[optind], "-")) {
add_file(STDIN);
} else {
add_file(argv[optind]);
add_file(STDIN);
} else {
add_file(argv[optind]);
@@
-268,13
+248,13
@@
int tail_main(int argc, char **argv)
units=-11;
if(units>0)
units--;
units=-11;
if(units>0)
units--;
- fd=malloc(sizeof(int)*n_files);
+ fd=
x
malloc(sizeof(int)*n_files);
if (n_files == 1)
#ifndef BB_FEATURE_SIMPLE_TAIL
if (!verbose)
#endif
show_headers = 0;
if (n_files == 1)
#ifndef BB_FEATURE_SIMPLE_TAIL
if (!verbose)
#endif
show_headers = 0;
- buffer=malloc(BUFSIZ);
+ buffer=
x
malloc(BUFSIZ);
for (test = 0; test < n_files; test++) {
if (show_headers)
printf("==> %s <==\n", files[test]);
for (test = 0; test < n_files; test++) {
if (show_headers)
printf("==> %s <==\n", files[test]);