diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-04-12 08:03:11 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-04-12 08:03:11 +0000 |
commit | fc5f318896dec8d1bd08eeeef3f017b75c88f1b1 (patch) | |
tree | dbbfaf36d8ad1c6942bb2989f0c4ad9c0d37ccb2 | |
parent | cb44816ba32a3bbf598aab6d7cb1eabfd6619f5f (diff) | |
download | busybox-w32-fc5f318896dec8d1bd08eeeef3f017b75c88f1b1.tar.gz busybox-w32-fc5f318896dec8d1bd08eeeef3f017b75c88f1b1.tar.bz2 busybox-w32-fc5f318896dec8d1bd08eeeef3f017b75c88f1b1.zip |
- use C99 %j format to print intmax.
Closes bugs #802 and #743
-rw-r--r-- | coreutils/stat.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/coreutils/stat.c b/coreutils/stat.c index 57fe3eeba..166ce4824 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
@@ -13,7 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <stdio.h> | 15 | #include <stdio.h> |
16 | #include <inttypes.h> | 16 | #include <stdint.h> |
17 | #include <sys/types.h> | 17 | #include <sys/types.h> |
18 | #include <pwd.h> | 18 | #include <pwd.h> |
19 | #include <grp.h> | 19 | #include <grp.h> |
@@ -146,15 +146,15 @@ static void print_statfs(char *pformat, size_t buf_len, char m, | |||
146 | printf(pformat, human_fstype(statfsbuf->f_type)); | 146 | printf(pformat, human_fstype(statfsbuf->f_type)); |
147 | break; | 147 | break; |
148 | case 'b': | 148 | case 'b': |
149 | strncat(pformat, "ld", buf_len); | 149 | strncat(pformat, "jd", buf_len); |
150 | printf(pformat, (intmax_t) (statfsbuf->f_blocks)); | 150 | printf(pformat, (intmax_t) (statfsbuf->f_blocks)); |
151 | break; | 151 | break; |
152 | case 'f': | 152 | case 'f': |
153 | strncat(pformat, "ld", buf_len); | 153 | strncat(pformat, "jd", buf_len); |
154 | printf(pformat, (intmax_t) (statfsbuf->f_bfree)); | 154 | printf(pformat, (intmax_t) (statfsbuf->f_bfree)); |
155 | break; | 155 | break; |
156 | case 'a': | 156 | case 'a': |
157 | strncat(pformat, "ld", buf_len); | 157 | strncat(pformat, "jd", buf_len); |
158 | printf(pformat, (intmax_t) (statfsbuf->f_bavail)); | 158 | printf(pformat, (intmax_t) (statfsbuf->f_bavail)); |
159 | break; | 159 | break; |
160 | case 'S': | 160 | case 'S': |
@@ -163,11 +163,11 @@ static void print_statfs(char *pformat, size_t buf_len, char m, | |||
163 | printf(pformat, (unsigned long int) (statfsbuf->f_bsize)); | 163 | printf(pformat, (unsigned long int) (statfsbuf->f_bsize)); |
164 | break; | 164 | break; |
165 | case 'c': | 165 | case 'c': |
166 | strncat(pformat, "ld", buf_len); | 166 | strncat(pformat, "jd", buf_len); |
167 | printf(pformat, (intmax_t) (statfsbuf->f_files)); | 167 | printf(pformat, (intmax_t) (statfsbuf->f_files)); |
168 | break; | 168 | break; |
169 | case 'd': | 169 | case 'd': |
170 | strncat(pformat, "ld", buf_len); | 170 | strncat(pformat, "jd", buf_len); |
171 | printf(pformat, (intmax_t) (statfsbuf->f_ffree)); | 171 | printf(pformat, (intmax_t) (statfsbuf->f_ffree)); |
172 | break; | 172 | break; |
173 | default: | 173 | default: |
@@ -208,15 +208,15 @@ static void print_stat(char *pformat, size_t buf_len, char m, | |||
208 | } | 208 | } |
209 | break; | 209 | break; |
210 | case 'd': | 210 | case 'd': |
211 | strncat(pformat, "lu", buf_len); | 211 | strncat(pformat, "ju", buf_len); |
212 | printf(pformat, (uintmax_t) statbuf->st_dev); | 212 | printf(pformat, (uintmax_t) statbuf->st_dev); |
213 | break; | 213 | break; |
214 | case 'D': | 214 | case 'D': |
215 | strncat(pformat, "lx", buf_len); | 215 | strncat(pformat, "jx", buf_len); |
216 | printf(pformat, (uintmax_t) statbuf->st_dev); | 216 | printf(pformat, (uintmax_t) statbuf->st_dev); |
217 | break; | 217 | break; |
218 | case 'i': | 218 | case 'i': |
219 | strncat(pformat, "lu", buf_len); | 219 | strncat(pformat, "ju", buf_len); |
220 | printf(pformat, (uintmax_t) statbuf->st_ino); | 220 | printf(pformat, (uintmax_t) statbuf->st_ino); |
221 | break; | 221 | break; |
222 | case 'a': | 222 | case 'a': |
@@ -268,7 +268,7 @@ static void print_stat(char *pformat, size_t buf_len, char m, | |||
268 | printf(pformat, (unsigned long int) minor(statbuf->st_rdev)); | 268 | printf(pformat, (unsigned long int) minor(statbuf->st_rdev)); |
269 | break; | 269 | break; |
270 | case 's': | 270 | case 's': |
271 | strncat(pformat, "lu", buf_len); | 271 | strncat(pformat, "ju", buf_len); |
272 | printf(pformat, (uintmax_t) (statbuf->st_size)); | 272 | printf(pformat, (uintmax_t) (statbuf->st_size)); |
273 | break; | 273 | break; |
274 | case 'B': | 274 | case 'B': |
@@ -276,7 +276,7 @@ static void print_stat(char *pformat, size_t buf_len, char m, | |||
276 | printf(pformat, (unsigned long int) 512); //ST_NBLOCKSIZE | 276 | printf(pformat, (unsigned long int) 512); //ST_NBLOCKSIZE |
277 | break; | 277 | break; |
278 | case 'b': | 278 | case 'b': |
279 | strncat(pformat, "lu", buf_len); | 279 | strncat(pformat, "ju", buf_len); |
280 | printf(pformat, (uintmax_t) statbuf->st_blocks); | 280 | printf(pformat, (uintmax_t) statbuf->st_blocks); |
281 | break; | 281 | break; |
282 | case 'o': | 282 | case 'o': |
@@ -405,8 +405,8 @@ static int do_statfs(char const *filename, char const *format) | |||
405 | format = (flags & OPT_TERSE | 405 | format = (flags & OPT_TERSE |
406 | ? "%lu %ld %ld %ld %ld %ld\n" | 406 | ? "%lu %ld %ld %ld %ld %ld\n" |
407 | : "Block size: %-10lu\n" | 407 | : "Block size: %-10lu\n" |
408 | "Blocks: Total: %-10ld Free: %-10ld Available: %ld\n" | 408 | "Blocks: Total: %-10jd Free: %-10jd Available: %jd\n" |
409 | "Inodes: Total: %-10ld Free: %ld\n"); | 409 | "Inodes: Total: %-10jd Free: %jd\n"); |
410 | printf(format, | 410 | printf(format, |
411 | (unsigned long int) (statfsbuf.f_bsize), | 411 | (unsigned long int) (statfsbuf.f_bsize), |
412 | (intmax_t) (statfsbuf.f_blocks), | 412 | (intmax_t) (statfsbuf.f_blocks), |
@@ -455,7 +455,7 @@ static int do_stat(char const *filename, char const *format) | |||
455 | print_it(format, filename, print_stat, &statbuf); | 455 | print_it(format, filename, print_stat, &statbuf); |
456 | #else | 456 | #else |
457 | if (flags & OPT_TERSE) { | 457 | if (flags & OPT_TERSE) { |
458 | printf("%s %"PRIuMAX" %"PRIuMAX" %lx %lu %lu %"PRIxMAX" %"PRIuMAX" %lu %lx %lx %lu %lu %lu %lu\n", | 458 | printf("%s %ju %ju %lx %lu %lu %jx %ju %lu %lx %lx %lu %lu %lu %lu\n", |
459 | filename, | 459 | filename, |
460 | (uintmax_t) (statbuf.st_size), | 460 | (uintmax_t) (statbuf.st_size), |
461 | (uintmax_t) statbuf.st_blocks, | 461 | (uintmax_t) statbuf.st_blocks, |
@@ -489,8 +489,8 @@ static int do_stat(char const *filename, char const *format) | |||
489 | else | 489 | else |
490 | printf(" File: \"%s\"\n", filename); | 490 | printf(" File: \"%s\"\n", filename); |
491 | 491 | ||
492 | printf(" Size: %-10"PRIuMAX"\tBlocks: %-10"PRIuMAX" IO Block: %-6lu %s\n" | 492 | printf(" Size: %-10ju\tBlocks: %-10ju IO Block: %-6lu %s\n" |
493 | "Device: %"PRIxMAX"h/%"PRIuMAX"d\tInode: %-10"PRIuMAX" Links: %-5lu", | 493 | "Device: %jxh/%jud\tInode: %-10ju Links: %-5lu", |
494 | (uintmax_t) (statbuf.st_size), | 494 | (uintmax_t) (statbuf.st_size), |
495 | (uintmax_t) statbuf.st_blocks, | 495 | (uintmax_t) statbuf.st_blocks, |
496 | (unsigned long int) statbuf.st_blksize, | 496 | (unsigned long int) statbuf.st_blksize, |