diff options
author | Jim Meyering <jim@meyering.net> | 2002-04-15 08:50:57 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-04-15 08:50:57 +0000 |
commit | b214c8214ceb898ec72b7faa409f44998187cb0c (patch) | |
tree | 1cf57cfeb39a9443e8ffad6f6e5ea302d83b1c1d /src | |
parent | 68f054be8f03a1d45ed3db7240185fda818be918 (diff) | |
download | coreutils-b214c8214ceb898ec72b7faa409f44998187cb0c.tar.xz |
Handle "lld" vs "ld" printf formats the same way Bash does.
Include inttypes.h.
(PRIdMAX, PRIuMAX): Define, if not already defined.
(print_statfs): Use those macros, not the literal strings.
(print_stat): Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/stat.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/stat.c b/src/stat.c index e818d7e50..045f97b83 100644 --- a/src/stat.c +++ b/src/stat.c @@ -16,6 +16,26 @@ #include <malloc.h> #include <ctype.h> +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#if ! defined PRIdMAX +# if HAVE_LONG_LONG +# define PRIdMAX "lld" +# else +# define PRIdMAX "ld" +# endif +#endif + +#if ! defined PRIuMAX +# if HAVE_LONG_LONG +# define PRIuMAX "llu" +# else +# define PRIuMAX "lu" +# endif +#endif + #include "system.h" #include "closeout.h" @@ -329,7 +349,7 @@ print_statfs (char *pformat, char m, char const *filename, break; case 'l': - strcat (pformat, "llu"); + strcat (pformat, PRIuMAX); printf (pformat, (uintmax_t) (statfsbuf->f_namelen)); break; case 't': @@ -341,15 +361,15 @@ print_statfs (char *pformat, char m, char const *filename, print_human_fstype (statfsbuf); break; case 'b': - strcat (pformat, "lld"); + strcat (pformat, PRIdMAX); printf (pformat, (intmax_t) (statfsbuf->f_blocks)); break; case 'f': - strcat (pformat, "lld"); + strcat (pformat, PRIdMAX); printf (pformat, (intmax_t) (statfsbuf->f_bfree)); break; case 'a': - strcat (pformat, "lld"); + strcat (pformat, PRIdMAX); printf (pformat, (intmax_t) (statfsbuf->f_bavail)); break; case 's': @@ -357,11 +377,11 @@ print_statfs (char *pformat, char m, char const *filename, printf (pformat, (long int) (statfsbuf->f_bsize)); break; case 'c': - strcat (pformat, "lld"); + strcat (pformat, PRIdMAX); printf (pformat, (intmax_t) (statfsbuf->f_files)); break; case 'd': - strcat (pformat, "lld"); + strcat (pformat, PRIdMAX); printf (pformat, (intmax_t) (statfsbuf->f_ffree)); break; #ifdef FLASK_LINUX @@ -502,8 +522,8 @@ print_stat (char *pformat, char m, char const *filename, printf (pformat, minor (statbuf->st_rdev)); break; case 's': - strcat (pformat, "llu"); - printf (pformat, (unsigned long long) statbuf->st_size); + strcat (pformat, PRIuMAX); + printf (pformat, (uintmax_t) (statbuf->st_size)); break; case 'b': strcat (pformat, "u"); |