diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-07 03:48:02 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-07 03:48:02 +0000 |
commit | d04b3cfadde43faf4a63ff57fc293e62e93b02cb (patch) | |
tree | 2db2611e4e682a2530e6f31e4bd5fbebe5d7b5eb | |
parent | 8ef41ca0b54e174c402b635ea65e2b8e2d6add69 (diff) | |
download | busybox-w32-d04b3cfadde43faf4a63ff57fc293e62e93b02cb.tar.gz busybox-w32-d04b3cfadde43faf4a63ff57fc293e62e93b02cb.tar.bz2 busybox-w32-d04b3cfadde43faf4a63ff57fc293e62e93b02cb.zip |
Fix up ls.c to ensure human readable works properly in all cases
git-svn-id: svn://busybox.net/trunk/busybox@1992 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/ls.c | 10 | ||||
-rw-r--r-- | ls.c | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index d8666152e..f9e0b2538 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -186,7 +186,7 @@ static unsigned short column_width = COLUMN_WIDTH; | |||
186 | static int status = EXIT_SUCCESS; | 186 | static int status = EXIT_SUCCESS; |
187 | 187 | ||
188 | #ifdef BB_FEATURE_HUMAN_READABLE | 188 | #ifdef BB_FEATURE_HUMAN_READABLE |
189 | unsigned long ls_disp_hr = KILOBYTE; | 189 | unsigned long ls_disp_hr = 0; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | static int my_stat(struct dnode *cur) | 192 | static int my_stat(struct dnode *cur) |
@@ -610,7 +610,7 @@ int list_single(struct dnode *dn) | |||
610 | break; | 610 | break; |
611 | case LIST_BLOCKS: | 611 | case LIST_BLOCKS: |
612 | #ifdef BB_FEATURE_HUMAN_READABLE | 612 | #ifdef BB_FEATURE_HUMAN_READABLE |
613 | fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, 1)); | 613 | fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, (ls_disp_hr==TRUE)? 0: 1)); |
614 | #else | 614 | #else |
615 | #if _FILE_OFFSET_BITS == 64 | 615 | #if _FILE_OFFSET_BITS == 64 |
616 | printf("%4lld ", dn->dstat.st_blocks>>1); | 616 | printf("%4lld ", dn->dstat.st_blocks>>1); |
@@ -647,7 +647,7 @@ int list_single(struct dnode *dn) | |||
647 | printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); | 647 | printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); |
648 | } else { | 648 | } else { |
649 | #ifdef BB_FEATURE_HUMAN_READABLE | 649 | #ifdef BB_FEATURE_HUMAN_READABLE |
650 | fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr)); | 650 | fprintf(stdout, "%9s ", format(dn->dstat.st_size, (ls_disp_hr==TRUE)? 0: 1)); |
651 | #else | 651 | #else |
652 | #if _FILE_OFFSET_BITS == 64 | 652 | #if _FILE_OFFSET_BITS == 64 |
653 | printf("%9lld ", dn->dstat.st_size>>1); | 653 | printf("%9lld ", dn->dstat.st_size>>1); |
@@ -779,7 +779,7 @@ extern int ls_main(int argc, char **argv) | |||
779 | style_fmt = STYLE_LONG; | 779 | style_fmt = STYLE_LONG; |
780 | list_fmt |= LIST_LONG; | 780 | list_fmt |= LIST_LONG; |
781 | #ifdef BB_FEATURE_HUMAN_READABLE | 781 | #ifdef BB_FEATURE_HUMAN_READABLE |
782 | ls_disp_hr = 1; | 782 | ls_disp_hr = FALSE; |
783 | #endif | 783 | #endif |
784 | break; | 784 | break; |
785 | case 'n': list_fmt |= LIST_ID_NUMERIC; break; | 785 | case 'n': list_fmt |= LIST_ID_NUMERIC; break; |
@@ -826,7 +826,7 @@ extern int ls_main(int argc, char **argv) | |||
826 | case 'w': terminal_width= atoi(optarg); break; | 826 | case 'w': terminal_width= atoi(optarg); break; |
827 | #endif | 827 | #endif |
828 | #ifdef BB_FEATURE_HUMAN_READABLE | 828 | #ifdef BB_FEATURE_HUMAN_READABLE |
829 | case 'h': ls_disp_hr = 0; break; | 829 | case 'h': ls_disp_hr = TRUE; break; |
830 | #endif | 830 | #endif |
831 | case 'k': break; | 831 | case 'k': break; |
832 | default: | 832 | default: |
@@ -186,7 +186,7 @@ static unsigned short column_width = COLUMN_WIDTH; | |||
186 | static int status = EXIT_SUCCESS; | 186 | static int status = EXIT_SUCCESS; |
187 | 187 | ||
188 | #ifdef BB_FEATURE_HUMAN_READABLE | 188 | #ifdef BB_FEATURE_HUMAN_READABLE |
189 | unsigned long ls_disp_hr = KILOBYTE; | 189 | unsigned long ls_disp_hr = 0; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | static int my_stat(struct dnode *cur) | 192 | static int my_stat(struct dnode *cur) |
@@ -610,7 +610,7 @@ int list_single(struct dnode *dn) | |||
610 | break; | 610 | break; |
611 | case LIST_BLOCKS: | 611 | case LIST_BLOCKS: |
612 | #ifdef BB_FEATURE_HUMAN_READABLE | 612 | #ifdef BB_FEATURE_HUMAN_READABLE |
613 | fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, 1)); | 613 | fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, (ls_disp_hr==TRUE)? 0: 1)); |
614 | #else | 614 | #else |
615 | #if _FILE_OFFSET_BITS == 64 | 615 | #if _FILE_OFFSET_BITS == 64 |
616 | printf("%4lld ", dn->dstat.st_blocks>>1); | 616 | printf("%4lld ", dn->dstat.st_blocks>>1); |
@@ -647,7 +647,7 @@ int list_single(struct dnode *dn) | |||
647 | printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); | 647 | printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); |
648 | } else { | 648 | } else { |
649 | #ifdef BB_FEATURE_HUMAN_READABLE | 649 | #ifdef BB_FEATURE_HUMAN_READABLE |
650 | fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr)); | 650 | fprintf(stdout, "%9s ", format(dn->dstat.st_size, (ls_disp_hr==TRUE)? 0: 1)); |
651 | #else | 651 | #else |
652 | #if _FILE_OFFSET_BITS == 64 | 652 | #if _FILE_OFFSET_BITS == 64 |
653 | printf("%9lld ", dn->dstat.st_size>>1); | 653 | printf("%9lld ", dn->dstat.st_size>>1); |
@@ -779,7 +779,7 @@ extern int ls_main(int argc, char **argv) | |||
779 | style_fmt = STYLE_LONG; | 779 | style_fmt = STYLE_LONG; |
780 | list_fmt |= LIST_LONG; | 780 | list_fmt |= LIST_LONG; |
781 | #ifdef BB_FEATURE_HUMAN_READABLE | 781 | #ifdef BB_FEATURE_HUMAN_READABLE |
782 | ls_disp_hr = 1; | 782 | ls_disp_hr = FALSE; |
783 | #endif | 783 | #endif |
784 | break; | 784 | break; |
785 | case 'n': list_fmt |= LIST_ID_NUMERIC; break; | 785 | case 'n': list_fmt |= LIST_ID_NUMERIC; break; |
@@ -826,7 +826,7 @@ extern int ls_main(int argc, char **argv) | |||
826 | case 'w': terminal_width= atoi(optarg); break; | 826 | case 'w': terminal_width= atoi(optarg); break; |
827 | #endif | 827 | #endif |
828 | #ifdef BB_FEATURE_HUMAN_READABLE | 828 | #ifdef BB_FEATURE_HUMAN_READABLE |
829 | case 'h': ls_disp_hr = 0; break; | 829 | case 'h': ls_disp_hr = TRUE; break; |
830 | #endif | 830 | #endif |
831 | case 'k': break; | 831 | case 'k': break; |
832 | default: | 832 | default: |