Use the correct conversion specifier for size_t.

Reported by Jim Meyering.
* src/Sbitset.h (SBITSET__INDEX__CONVERSION_SPEC): New, "zu"
because Sbitset__Index is size_t.
* src/Sbitset.c (Sbitset__fprint): Use it instead of %d.
(cherry picked from commit 47eced3099)
This commit is contained in:
Joel E. Denny
2009-09-29 06:54:38 -04:00
parent 4b7a4c1b1c
commit 17a407dc51
3 changed files with 13 additions and 2 deletions

View File

@@ -65,14 +65,16 @@ Sbitset__fprint(Sbitset self, Sbitset__Index nbits, FILE *file)
Sbitset__Index i;
Sbitset itr;
bool first = true;
fprintf (file, "nbits = %d, set = {", nbits);
fprintf (file,
"nbits = %" SBITSET__INDEX__CONVERSION_SPEC ", set = {",
nbits);
SBITSET__FOR_EACH (self, nbits, itr, i)
{
if (first)
first = false;
else
fprintf (file, ",");
fprintf (file, " %d", i);
fprintf (file, " %" SBITSET__INDEX__CONVERSION_SPEC, i);
}
fprintf (file, " }");
}

View File

@@ -22,6 +22,7 @@
typedef char *Sbitset;
typedef size_t Sbitset__Index;
#define SBITSET__INDEX__CONVERSION_SPEC "zu"
#define Sbitset__nbytes(NBITS) (((NBITS)+7)/8)
#define Sbitset__byteAddress(SELF, INDEX) (((SELF) + (INDEX)/8))