diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2018-08-01 01:39:47 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2018-08-01 01:39:47 -0700 |
commit | 4c14b51587b3bf484f7ca26a92dcfc0f8559201b (patch) | |
tree | fc1d336d4aefe38c3bec8004c833c324828447a6 | |
parent | 194e558efefe58866c88519708a7ff836b2c66be (diff) | |
download | zlib-4c14b51587b3bf484f7ca26a92dcfc0f8559201b.tar.gz zlib-4c14b51587b3bf484f7ca26a92dcfc0f8559201b.tar.bz2 zlib-4c14b51587b3bf484f7ca26a92dcfc0f8559201b.zip |
Use a macro for the printf format of big_t in enough.c.
-rw-r--r-- | examples/enough.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/examples/enough.c b/examples/enough.c index b1be6f0..d6f8e25 100644 --- a/examples/enough.c +++ b/examples/enough.c | |||
@@ -108,6 +108,7 @@ | |||
108 | 108 | ||
109 | /* special data types */ | 109 | /* special data types */ |
110 | typedef unsigned long long big_t; /* type for code counting */ | 110 | typedef unsigned long long big_t; /* type for code counting */ |
111 | #define PRIbig "llu" /* printf format for big_t */ | ||
111 | typedef unsigned long long code_t; /* type for bit pattern counting */ | 112 | typedef unsigned long long code_t; /* type for bit pattern counting */ |
112 | struct tab { /* type for been here check */ | 113 | struct tab { /* type for been here check */ |
113 | size_t len; /* length of bit vector in char's */ | 114 | size_t len; /* length of bit vector in char's */ |
@@ -452,11 +453,6 @@ local void enough(int syms) | |||
452 | 453 | ||
453 | For the deflate literal/length code, use "enough". For the deflate distance | 454 | For the deflate literal/length code, use "enough". For the deflate distance |
454 | code, use "enough 30 6". | 455 | code, use "enough 30 6". |
455 | |||
456 | This uses the %llu printf format to print big_t numbers, which assumes that | ||
457 | big_t is an unsigned long long. If the big_t type is changed (for example | ||
458 | to a multiple precision type), the method of printing will also need to be | ||
459 | updated. | ||
460 | */ | 456 | */ |
461 | int main(int argc, char **argv) | 457 | int main(int argc, char **argv) |
462 | { | 458 | { |
@@ -543,9 +539,9 @@ int main(int argc, char **argv) | |||
543 | cleanup(); | 539 | cleanup(); |
544 | return 1; | 540 | return 1; |
545 | } | 541 | } |
546 | printf("%llu %d-codes\n", got, n); | 542 | printf("%"PRIbig" %d-codes\n", got, n); |
547 | } | 543 | } |
548 | printf("%llu total codes for 2 to %d symbols", sum, syms); | 544 | printf("%"PRIbig" total codes for 2 to %d symbols", sum, syms); |
549 | if (g.max < syms - 1) | 545 | if (g.max < syms - 1) |
550 | printf(" (%d-bit length limit)\n", g.max); | 546 | printf(" (%d-bit length limit)\n", g.max); |
551 | else | 547 | else |