diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/ls.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 31abbc9b5..d1521529f 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -324,7 +324,6 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f | |||
324 | return cur; | 324 | return cur; |
325 | } | 325 | } |
326 | 326 | ||
327 | |||
328 | /* FYI type values: 1:fifo 2:char 4:dir 6:blk 8:file 10:link 12:socket | 327 | /* FYI type values: 1:fifo 2:char 4:dir 6:blk 8:file 10:link 12:socket |
329 | * (various wacky OSes: 13:Sun door 14:BSD whiteout 5:XENIX named file | 328 | * (various wacky OSes: 13:Sun door 14:BSD whiteout 5:XENIX named file |
330 | * 3/7:multiplexed char/block device) | 329 | * 3/7:multiplexed char/block device) |
@@ -386,7 +385,6 @@ static char append_char(mode_t mode) | |||
386 | } | 385 | } |
387 | #endif | 386 | #endif |
388 | 387 | ||
389 | |||
390 | #define countdirs(A, B) count_dirs((A), (B), 1) | 388 | #define countdirs(A, B) count_dirs((A), (B), 1) |
391 | #define countsubdirs(A, B) count_dirs((A), (B), 0) | 389 | #define countsubdirs(A, B) count_dirs((A), (B), 0) |
392 | static unsigned count_dirs(struct dnode **dn, unsigned nfiles, int notsubdirs) | 390 | static unsigned count_dirs(struct dnode **dn, unsigned nfiles, int notsubdirs) |
@@ -430,10 +428,10 @@ static void dfree(struct dnode **dnp, unsigned nfiles) | |||
430 | for (i = 0; i < nfiles; i++) { | 428 | for (i = 0; i < nfiles; i++) { |
431 | struct dnode *cur = dnp[i]; | 429 | struct dnode *cur = dnp[i]; |
432 | if (cur->fname_allocated) | 430 | if (cur->fname_allocated) |
433 | free((char*)cur->fullname); /* free the filename */ | 431 | free((char*)cur->fullname); |
434 | free(cur); /* free the dnode */ | 432 | free(cur); |
435 | } | 433 | } |
436 | free(dnp); /* free the array holding the dnode pointers */ | 434 | free(dnp); |
437 | } | 435 | } |
438 | #else | 436 | #else |
439 | #define dfree(...) ((void)0) | 437 | #define dfree(...) ((void)0) |
@@ -564,9 +562,10 @@ static void showfiles(struct dnode **dn, unsigned nfiles) | |||
564 | for (row = 0; row < nrows; row++) { | 562 | for (row = 0; row < nrows; row++) { |
565 | for (nc = 0; nc < ncols; nc++) { | 563 | for (nc = 0; nc < ncols; nc++) { |
566 | /* reach into the array based on the column and row */ | 564 | /* reach into the array based on the column and row */ |
567 | i = (nc * nrows) + row; /* assume display by column */ | ||
568 | if (all_fmt & DISP_ROWS) | 565 | if (all_fmt & DISP_ROWS) |
569 | i = (row * ncols) + nc; /* display across row */ | 566 | i = (row * ncols) + nc; /* display across row */ |
567 | else | ||
568 | i = (nc * nrows) + row; /* display by column */ | ||
570 | if (i < nfiles) { | 569 | if (i < nfiles) { |
571 | if (column > 0) { | 570 | if (column > 0) { |
572 | nexttab -= column; | 571 | nexttab -= column; |
@@ -640,21 +639,21 @@ static void showdirs(struct dnode **dn, unsigned ndirs, int first) | |||
640 | /* list all files at this level */ | 639 | /* list all files at this level */ |
641 | dnsort(subdnp, nfiles); | 640 | dnsort(subdnp, nfiles); |
642 | showfiles(subdnp, nfiles); | 641 | showfiles(subdnp, nfiles); |
643 | if (ENABLE_FEATURE_LS_RECURSIVE) { | 642 | if (ENABLE_FEATURE_LS_RECURSIVE |
644 | if (all_fmt & DISP_RECURSIVE) { | 643 | && (all_fmt & DISP_RECURSIVE) |
645 | /* recursive- list the sub-dirs */ | 644 | ) { |
646 | dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); | 645 | /* recursive - list the sub-dirs */ |
647 | dndirs = countsubdirs(subdnp, nfiles); | 646 | dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); |
648 | if (dndirs > 0) { | 647 | dndirs = countsubdirs(subdnp, nfiles); |
649 | dnsort(dnd, dndirs); | 648 | if (dndirs > 0) { |
650 | showdirs(dnd, dndirs, 0); | 649 | dnsort(dnd, dndirs); |
651 | /* free the array of dnode pointers to the dirs */ | 650 | showdirs(dnd, dndirs, 0); |
652 | free(dnd); | 651 | /* free the array of dnode pointers to the dirs */ |
653 | } | 652 | free(dnd); |
654 | } | 653 | } |
655 | /* free the dnodes and the fullname mem */ | ||
656 | dfree(subdnp, nfiles); | ||
657 | } | 654 | } |
655 | /* free the dnodes and the fullname mem */ | ||
656 | dfree(subdnp, nfiles); | ||
658 | } | 657 | } |
659 | } | 658 | } |
660 | } | 659 | } |