diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/du.c | 8 | ||||
-rw-r--r-- | coreutils/ln.c | 2 | ||||
-rw-r--r-- | coreutils/ls.c | 28 | ||||
-rw-r--r-- | coreutils/tail.c | 15 |
4 files changed, 36 insertions, 17 deletions
diff --git a/coreutils/du.c b/coreutils/du.c index 7151e3a9c..912605882 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -72,6 +72,10 @@ static long du(char *filename) | |||
72 | du_depth++; | 72 | du_depth++; |
73 | sum = statbuf.st_blocks; | 73 | sum = statbuf.st_blocks; |
74 | 74 | ||
75 | /* Don't add in stuff pointed to by links */ | ||
76 | if (S_ISLNK(statbuf.st_mode)) { | ||
77 | return 0; | ||
78 | } | ||
75 | if (S_ISDIR(statbuf.st_mode)) { | 79 | if (S_ISDIR(statbuf.st_mode)) { |
76 | DIR *dir; | 80 | DIR *dir; |
77 | struct dirent *entry; | 81 | struct dirent *entry; |
@@ -140,7 +144,7 @@ int du_main(int argc, char **argv) | |||
140 | 144 | ||
141 | for (; i < argc; i++) { | 145 | for (; i < argc; i++) { |
142 | sum = du(argv[i]); | 146 | sum = du(argv[i]); |
143 | if ((sum) && (isDirectory(argv[i], FALSE))) { | 147 | if ((sum) && (isDirectory(argv[i], FALSE, NULL))) { |
144 | print_normal(sum, argv[i]); | 148 | print_normal(sum, argv[i]); |
145 | } | 149 | } |
146 | } | 150 | } |
@@ -149,4 +153,4 @@ int du_main(int argc, char **argv) | |||
149 | exit(0); | 153 | exit(0); |
150 | } | 154 | } |
151 | 155 | ||
152 | /* $Id: du.c,v 1.11 2000/02/08 19:58:47 erik Exp $ */ | 156 | /* $Id: du.c,v 1.12 2000/02/11 21:55:04 erik Exp $ */ |
diff --git a/coreutils/ln.c b/coreutils/ln.c index bc51cb0d5..0715bfaed 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -84,7 +84,7 @@ extern int ln_main(int argc, char **argv) | |||
84 | exit FALSE; | 84 | exit FALSE; |
85 | } | 85 | } |
86 | 86 | ||
87 | linkIntoDirFlag = isDirectory(linkName, TRUE); | 87 | linkIntoDirFlag = isDirectory(linkName, TRUE, NULL); |
88 | 88 | ||
89 | if ((argc > 3) && !linkIntoDirFlag) { | 89 | if ((argc > 3) && !linkIntoDirFlag) { |
90 | fprintf(stderr, not_a_directory, "ln", linkName); | 90 | fprintf(stderr, not_a_directory, "ln", linkName); |
diff --git a/coreutils/ls.c b/coreutils/ls.c index f23c1e086..c2266f533 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -29,10 +29,10 @@ | |||
29 | * it more portable. | 29 | * it more portable. |
30 | * | 30 | * |
31 | * KNOWN BUGS: | 31 | * KNOWN BUGS: |
32 | * 1. messy output if you mix files and directories on the command line | 32 | * 1. ls -l of a directory doesn't give "total <blocks>" header |
33 | * 2. ls -l of a directory doesn't give "total <blocks>" header | 33 | * 2. ls of a symlink to a directory doesn't list directory contents |
34 | * 3. ls of a symlink to a directory doesn't list directory contents | 34 | * 3. hidden files can make column width too large |
35 | * 4. hidden files can make column width too large | 35 | * |
36 | * NON-OPTIMAL BEHAVIOUR: | 36 | * NON-OPTIMAL BEHAVIOUR: |
37 | * 1. autowidth reads directories twice | 37 | * 1. autowidth reads directories twice |
38 | * 2. if you do a short directory listing without filetype characters | 38 | * 2. if you do a short directory listing without filetype characters |
@@ -100,7 +100,9 @@ static unsigned short opts = 0; | |||
100 | static unsigned short column = 0; | 100 | static unsigned short column = 0; |
101 | 101 | ||
102 | #ifdef BB_FEATURE_AUTOWIDTH | 102 | #ifdef BB_FEATURE_AUTOWIDTH |
103 | static unsigned short terminal_width = 0, column_width = 0; | 103 | static unsigned short terminal_width = 0; |
104 | static unsigned short column_width = 0; | ||
105 | static unsigned short toplevel_column_width = 0; | ||
104 | #else | 106 | #else |
105 | #define terminal_width TERMINAL_WIDTH | 107 | #define terminal_width TERMINAL_WIDTH |
106 | #define column_width COLUMN_WIDTH | 108 | #define column_width COLUMN_WIDTH |
@@ -349,6 +351,9 @@ static int list_item(const char *name) | |||
349 | goto listerr; | 351 | goto listerr; |
350 | 352 | ||
351 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { | 353 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { |
354 | #ifdef BB_FEATURE_AUTOWIDTH | ||
355 | column_width = toplevel_column_width; | ||
356 | #endif | ||
352 | list_single(name, &info, name); | 357 | list_single(name, &info, name); |
353 | return 0; | 358 | return 0; |
354 | } | 359 | } |
@@ -407,6 +412,15 @@ static int list_item(const char *name) | |||
407 | list_single(entry->d_name, &info, fullname); | 412 | list_single(entry->d_name, &info, fullname); |
408 | } | 413 | } |
409 | closedir(dir); | 414 | closedir(dir); |
415 | |||
416 | if (opts & DISP_DIRNAME) { /* separate the directory */ | ||
417 | if (column) { | ||
418 | wr("\n", 1); | ||
419 | } | ||
420 | wr("\n", 1); | ||
421 | column = 0; | ||
422 | } | ||
423 | |||
410 | return 0; | 424 | return 0; |
411 | 425 | ||
412 | direrr: | 426 | direrr: |
@@ -530,8 +544,8 @@ extern int ls_main(int argc, char **argv) | |||
530 | for (i = argi; i < argc; i++) { | 544 | for (i = argi; i < argc; i++) { |
531 | int len = strlen(argv[i]); | 545 | int len = strlen(argv[i]); |
532 | 546 | ||
533 | if (column_width < len) | 547 | if (toplevel_column_width < len) |
534 | column_width = len; | 548 | toplevel_column_width = len; |
535 | } | 549 | } |
536 | #endif | 550 | #endif |
537 | 551 | ||
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); |