diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-07 06:04:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-07 06:04:08 +0000 |
commit | ec9fad9a4997bbabaebad3c29a3c9f1ef2068788 (patch) | |
tree | e53a72ff52a23bb99470f811f0a0147b9a32373d | |
parent | a7db19bb81ee37ffeafb1c2e940f7ac9991bc81e (diff) | |
download | busybox-w32-ec9fad9a4997bbabaebad3c29a3c9f1ef2068788.tar.gz busybox-w32-ec9fad9a4997bbabaebad3c29a3c9f1ef2068788.tar.bz2 busybox-w32-ec9fad9a4997bbabaebad3c29a3c9f1ef2068788.zip |
Static-ify a variable. make du work with all the human-readable variants
since my last pass only fixed 'du -h' but left the others broken.
-rw-r--r-- | coreutils/df.c | 2 | ||||
-rw-r--r-- | coreutils/du.c | 21 | ||||
-rw-r--r-- | df.c | 2 | ||||
-rw-r--r-- | du.c | 21 |
4 files changed, 34 insertions, 12 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index 1f5e4b09e..9f8770fe6 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | extern const char mtab_file[]; /* Defined in utility.c */ | 32 | extern const char mtab_file[]; /* Defined in utility.c */ |
33 | #ifdef BB_FEATURE_HUMAN_READABLE | 33 | #ifdef BB_FEATURE_HUMAN_READABLE |
34 | unsigned long disp_hr = KILOBYTE; | 34 | static unsigned long disp_hr = KILOBYTE; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | static int df(char *device, const char *mountPoint) | 37 | static int df(char *device, const char *mountPoint) |
diff --git a/coreutils/du.c b/coreutils/du.c index e6b99a28b..36c4de290 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | 37 | ||
38 | #ifdef BB_FEATURE_HUMAN_READABLE | 38 | #ifdef BB_FEATURE_HUMAN_READABLE |
39 | unsigned long du_disp_hr = KILOBYTE; | 39 | static unsigned long disp_hr = KILOBYTE; |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | typedef void (Display) (long, char *); | 42 | typedef void (Display) (long, char *); |
@@ -48,8 +48,19 @@ static Display *print; | |||
48 | 48 | ||
49 | static void print_normal(long size, char *filename) | 49 | static void print_normal(long size, char *filename) |
50 | { | 50 | { |
51 | unsigned long base; | ||
51 | #ifdef BB_FEATURE_HUMAN_READABLE | 52 | #ifdef BB_FEATURE_HUMAN_READABLE |
52 | printf("%s\t%s\n", format(size, du_disp_hr), filename); | 53 | switch (disp_hr) { |
54 | case MEGABYTE: | ||
55 | base = KILOBYTE; | ||
56 | break; | ||
57 | case KILOBYTE: | ||
58 | base = 1; | ||
59 | break; | ||
60 | default: | ||
61 | base = 0; | ||
62 | } | ||
63 | printf("%s\t%s\n", format(size, base), filename); | ||
53 | #else | 64 | #else |
54 | printf("%ld\t%s\n", size, filename); | 65 | printf("%ld\t%s\n", size, filename); |
55 | #endif | 66 | #endif |
@@ -156,8 +167,8 @@ int du_main(int argc, char **argv) | |||
156 | count_hardlinks = 1; | 167 | count_hardlinks = 1; |
157 | break; | 168 | break; |
158 | #ifdef BB_FEATURE_HUMAN_READABLE | 169 | #ifdef BB_FEATURE_HUMAN_READABLE |
159 | case 'h': du_disp_hr = 0; break; | 170 | case 'h': disp_hr = 0; break; |
160 | case 'm': du_disp_hr = MEGABYTE; break; | 171 | case 'm': disp_hr = MEGABYTE; break; |
161 | #endif | 172 | #endif |
162 | case 'k': break; | 173 | case 'k': break; |
163 | default: | 174 | default: |
@@ -185,7 +196,7 @@ int du_main(int argc, char **argv) | |||
185 | return status; | 196 | return status; |
186 | } | 197 | } |
187 | 198 | ||
188 | /* $Id: du.c,v 1.40 2001/03/07 03:53:40 andersen Exp $ */ | 199 | /* $Id: du.c,v 1.41 2001/03/07 06:04:08 andersen Exp $ */ |
189 | /* | 200 | /* |
190 | Local Variables: | 201 | Local Variables: |
191 | c-file-style: "linux" | 202 | c-file-style: "linux" |
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | extern const char mtab_file[]; /* Defined in utility.c */ | 32 | extern const char mtab_file[]; /* Defined in utility.c */ |
33 | #ifdef BB_FEATURE_HUMAN_READABLE | 33 | #ifdef BB_FEATURE_HUMAN_READABLE |
34 | unsigned long disp_hr = KILOBYTE; | 34 | static unsigned long disp_hr = KILOBYTE; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | static int df(char *device, const char *mountPoint) | 37 | static int df(char *device, const char *mountPoint) |
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | 37 | ||
38 | #ifdef BB_FEATURE_HUMAN_READABLE | 38 | #ifdef BB_FEATURE_HUMAN_READABLE |
39 | unsigned long du_disp_hr = KILOBYTE; | 39 | static unsigned long disp_hr = KILOBYTE; |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | typedef void (Display) (long, char *); | 42 | typedef void (Display) (long, char *); |
@@ -48,8 +48,19 @@ static Display *print; | |||
48 | 48 | ||
49 | static void print_normal(long size, char *filename) | 49 | static void print_normal(long size, char *filename) |
50 | { | 50 | { |
51 | unsigned long base; | ||
51 | #ifdef BB_FEATURE_HUMAN_READABLE | 52 | #ifdef BB_FEATURE_HUMAN_READABLE |
52 | printf("%s\t%s\n", format(size, du_disp_hr), filename); | 53 | switch (disp_hr) { |
54 | case MEGABYTE: | ||
55 | base = KILOBYTE; | ||
56 | break; | ||
57 | case KILOBYTE: | ||
58 | base = 1; | ||
59 | break; | ||
60 | default: | ||
61 | base = 0; | ||
62 | } | ||
63 | printf("%s\t%s\n", format(size, base), filename); | ||
53 | #else | 64 | #else |
54 | printf("%ld\t%s\n", size, filename); | 65 | printf("%ld\t%s\n", size, filename); |
55 | #endif | 66 | #endif |
@@ -156,8 +167,8 @@ int du_main(int argc, char **argv) | |||
156 | count_hardlinks = 1; | 167 | count_hardlinks = 1; |
157 | break; | 168 | break; |
158 | #ifdef BB_FEATURE_HUMAN_READABLE | 169 | #ifdef BB_FEATURE_HUMAN_READABLE |
159 | case 'h': du_disp_hr = 0; break; | 170 | case 'h': disp_hr = 0; break; |
160 | case 'm': du_disp_hr = MEGABYTE; break; | 171 | case 'm': disp_hr = MEGABYTE; break; |
161 | #endif | 172 | #endif |
162 | case 'k': break; | 173 | case 'k': break; |
163 | default: | 174 | default: |
@@ -185,7 +196,7 @@ int du_main(int argc, char **argv) | |||
185 | return status; | 196 | return status; |
186 | } | 197 | } |
187 | 198 | ||
188 | /* $Id: du.c,v 1.40 2001/03/07 03:53:40 andersen Exp $ */ | 199 | /* $Id: du.c,v 1.41 2001/03/07 06:04:08 andersen Exp $ */ |
189 | /* | 200 | /* |
190 | Local Variables: | 201 | Local Variables: |
191 | c-file-style: "linux" | 202 | c-file-style: "linux" |