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/ls.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/ls.c')
-rw-r--r-- | coreutils/ls.c | 28 |
1 files changed, 21 insertions, 7 deletions
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 | ||