diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-02-11 21:55:04 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-02-11 21:55:04 +0000 |
commit | 9ffdaa647ee57263247e047e6c67c5a7fa1f2a6c (patch) | |
tree | 3485e1645439990642fcb941d579deb10f8a17a7 /coreutils/tail.c | |
parent | 5e1b2ca1161cba481ccf4873427389f59dbc23e0 (diff) | |
download | busybox-w32-9ffdaa647ee57263247e047e6c67c5a7fa1f2a6c.tar.gz busybox-w32-9ffdaa647ee57263247e047e6c67c5a7fa1f2a6c.tar.bz2 busybox-w32-9ffdaa647ee57263247e047e6c67c5a7fa1f2a6c.zip |
Updates
-Erik
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r-- | coreutils/tail.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c index 31705afa2..821244f9e 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | #include "internal.h" | 2 | #include "internal.h" |
3 | |||
3 | /* This file contains _two_ implementations of tail. One is | 4 | /* This file contains _two_ implementations of tail. One is |
4 | * a bit more full featured, but costs 6k. The other (i.e. the | 5 | * a bit more full featured, but costs 6k. The other (i.e. the |
5 | * SIMPLE_TAIL one) is less capable, but is good enough for about | 6 | * SIMPLE_TAIL one) is less capable, but is good enough for about |
@@ -51,7 +52,7 @@ | |||
51 | #define XWRITE(fd, buffer, n_bytes) \ | 52 | #define XWRITE(fd, buffer, n_bytes) \ |
52 | do { \ | 53 | do { \ |
53 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ | 54 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ |
54 | error("write error"); \ | 55 | errorMsg("write error"); \ |
55 | } while (0) | 56 | } while (0) |
56 | 57 | ||
57 | /* Number of items to tail. */ | 58 | /* Number of items to tail. */ |
@@ -117,7 +118,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
117 | lseek(fd, pos, SEEK_SET); | 118 | lseek(fd, pos, SEEK_SET); |
118 | bytes_read = fullRead(fd, buffer, bytes_read); | 119 | bytes_read = fullRead(fd, buffer, bytes_read); |
119 | if (bytes_read == -1) | 120 | if (bytes_read == -1) |
120 | error("read error"); | 121 | errorMsg("read error"); |
121 | 122 | ||
122 | /* Count the incomplete line on files that don't end with a newline. */ | 123 | /* Count the incomplete line on files that don't end with a newline. */ |
123 | if (bytes_read && buffer[bytes_read - 1] != '\n') | 124 | if (bytes_read && buffer[bytes_read - 1] != '\n') |
@@ -147,7 +148,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
147 | } | 148 | } |
148 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); | 149 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); |
149 | if (bytes_read == -1) | 150 | if (bytes_read == -1) |
150 | error("read error"); | 151 | errorMsg("read error"); |
151 | 152 | ||
152 | return 0; | 153 | return 0; |
153 | } | 154 | } |
@@ -209,7 +210,7 @@ static int pipe_lines(const char *filename, int fd, long int n_lines) | |||
209 | } | 210 | } |
210 | } | 211 | } |
211 | if (tmp->nbytes == -1) | 212 | if (tmp->nbytes == -1) |
212 | error("read error"); | 213 | errorMsg("read error"); |
213 | 214 | ||
214 | free((char *) tmp); | 215 | free((char *) tmp); |
215 | 216 | ||
@@ -272,7 +273,7 @@ static long dump_remainder(const char *filename, int fd) | |||
272 | total += bytes_read; | 273 | total += bytes_read; |
273 | } | 274 | } |
274 | if (bytes_read == -1) | 275 | if (bytes_read == -1) |
275 | error("read error"); | 276 | errorMsg("read error"); |
276 | if (forever) { | 277 | if (forever) { |
277 | fflush(stdout); | 278 | fflush(stdout); |
278 | sleep(1); | 279 | sleep(1); |
@@ -294,7 +295,7 @@ static int tail_lines(const char *filename, int fd, long int n_lines) | |||
294 | write_header(filename); | 295 | write_header(filename); |
295 | 296 | ||
296 | if (fstat(fd, &stats)) | 297 | if (fstat(fd, &stats)) |
297 | error("fstat error"); | 298 | errorMsg("fstat error"); |
298 | 299 | ||
299 | /* Use file_lines only if FD refers to a regular file with | 300 | /* Use file_lines only if FD refers to a regular file with |
300 | its file pointer positioned at beginning of file. */ | 301 | its file pointer positioned at beginning of file. */ |
@@ -329,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units) | |||
329 | /* Not standard input. */ | 330 | /* Not standard input. */ |
330 | fd = open(filename, O_RDONLY); | 331 | fd = open(filename, O_RDONLY); |
331 | if (fd == -1) | 332 | if (fd == -1) |
332 | error("open error"); | 333 | errorMsg("open error"); |
333 | 334 | ||
334 | errors = tail_lines(filename, fd, (long) n_units); | 335 | errors = tail_lines(filename, fd, (long) n_units); |
335 | close(fd); | 336 | close(fd); |