From 651f8c04ef62ec4987156933ac4e1cc8d313562a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 7 Mar 2001 03:48:02 +0000 Subject: [PATCH] Fix up ls.c to ensure human readable works properly in all cases --- coreutils/ls.c | 10 +++++----- ls.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/coreutils/ls.c b/coreutils/ls.c index d866615..f9e0b25 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -186,7 +186,7 @@ static unsigned short column_width = COLUMN_WIDTH; static int status = EXIT_SUCCESS; #ifdef BB_FEATURE_HUMAN_READABLE -unsigned long ls_disp_hr = KILOBYTE; +unsigned long ls_disp_hr = 0; #endif static int my_stat(struct dnode *cur) @@ -610,7 +610,7 @@ int list_single(struct dnode *dn) break; case LIST_BLOCKS: #ifdef BB_FEATURE_HUMAN_READABLE - fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, 1)); + fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, (ls_disp_hr==TRUE)? 0: 1)); #else #if _FILE_OFFSET_BITS == 64 printf("%4lld ", dn->dstat.st_blocks>>1); @@ -647,7 +647,7 @@ int list_single(struct dnode *dn) printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); } else { #ifdef BB_FEATURE_HUMAN_READABLE - fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr)); + fprintf(stdout, "%9s ", format(dn->dstat.st_size, (ls_disp_hr==TRUE)? 0: 1)); #else #if _FILE_OFFSET_BITS == 64 printf("%9lld ", dn->dstat.st_size>>1); @@ -779,7 +779,7 @@ extern int ls_main(int argc, char **argv) style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; #ifdef BB_FEATURE_HUMAN_READABLE - ls_disp_hr = 1; + ls_disp_hr = FALSE; #endif break; case 'n': list_fmt |= LIST_ID_NUMERIC; break; @@ -826,7 +826,7 @@ extern int ls_main(int argc, char **argv) case 'w': terminal_width= atoi(optarg); break; #endif #ifdef BB_FEATURE_HUMAN_READABLE - case 'h': ls_disp_hr = 0; break; + case 'h': ls_disp_hr = TRUE; break; #endif case 'k': break; default: diff --git a/ls.c b/ls.c index d866615..f9e0b25 100644 --- a/ls.c +++ b/ls.c @@ -186,7 +186,7 @@ static unsigned short column_width = COLUMN_WIDTH; static int status = EXIT_SUCCESS; #ifdef BB_FEATURE_HUMAN_READABLE -unsigned long ls_disp_hr = KILOBYTE; +unsigned long ls_disp_hr = 0; #endif static int my_stat(struct dnode *cur) @@ -610,7 +610,7 @@ int list_single(struct dnode *dn) break; case LIST_BLOCKS: #ifdef BB_FEATURE_HUMAN_READABLE - fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, 1)); + fprintf(stdout, "%5s ", format(dn->dstat.st_blocks>>1, (ls_disp_hr==TRUE)? 0: 1)); #else #if _FILE_OFFSET_BITS == 64 printf("%4lld ", dn->dstat.st_blocks>>1); @@ -647,7 +647,7 @@ int list_single(struct dnode *dn) printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev)); } else { #ifdef BB_FEATURE_HUMAN_READABLE - fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr)); + fprintf(stdout, "%9s ", format(dn->dstat.st_size, (ls_disp_hr==TRUE)? 0: 1)); #else #if _FILE_OFFSET_BITS == 64 printf("%9lld ", dn->dstat.st_size>>1); @@ -779,7 +779,7 @@ extern int ls_main(int argc, char **argv) style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; #ifdef BB_FEATURE_HUMAN_READABLE - ls_disp_hr = 1; + ls_disp_hr = FALSE; #endif break; case 'n': list_fmt |= LIST_ID_NUMERIC; break; @@ -826,7 +826,7 @@ extern int ls_main(int argc, char **argv) case 'w': terminal_width= atoi(optarg); break; #endif #ifdef BB_FEATURE_HUMAN_READABLE - case 'h': ls_disp_hr = 0; break; + case 'h': ls_disp_hr = TRUE; break; #endif case 'k': break; default: -- 2.7.4