Use the correct conversion specifier for size_t.
authorJoel E. Denny <jdenny@clemson.edu>
Tue, 29 Sep 2009 10:54:38 +0000 (06:54 -0400)
committerJoel E. Denny <jdenny@clemson.edu>
Tue, 29 Sep 2009 12:31:14 +0000 (08:31 -0400)
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 47eced3099712180364f4e01b839242027d9a9d8)

ChangeLog
src/Sbitset.c
src/Sbitset.h

index 4b233db..12f3016 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-29  Joel E. Denny  <jdenny@clemson.edu>
+
+       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.
+
 2009-09-27  Joel E. Denny  <jdenny@clemson.edu>
 
        tests: don't abuse AT_BISON_CHECK.
index 0c1fedf..af8600b 100644 (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, " }");
 }
index 4b4b750..a025040 100644 (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))