Added G_GSIZE_FORMAT and friends.
authorManish Singh <yosh@gimp.org>
Thu, 20 Nov 2003 23:12:05 +0000 (23:12 +0000)
committerManish Singh <yosh@src.gnome.org>
Thu, 20 Nov 2003 23:12:05 +0000 (23:12 +0000)
Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>

        * configure.in: Added G_GSIZE_FORMAT and friends.

        * tests/printf-test.c
        * tests/testglib.c
        * tests/type-test.c: Add tests for the above.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
tests/printf-test.c
tests/testglib.c
tests/type-test.c

index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 9b6c1b243e66cfba5f98114ab4ce254f49a15a5b..a5bd4219d1624e04a138f61505c2dbdf0caee6ef 100644 (file)
@@ -1,3 +1,11 @@
+Thu Nov 20 15:09:40 2003  Manish Singh  <yosh@gimp.org>
+
+       * configure.in: Added G_GSIZE_FORMAT and friends.
+
+       * tests/printf-test.c
+       * tests/testglib.c
+       * tests/type-test.c: Add tests for the above.
+
 Mon Nov 17 17:28:10 2003  Manish Singh  <yosh@gimp.org>
 
        * tests/thread-test.c (test_g_thread_once): Use GUINT_TO_POINTER
index 768f0d4bf6cc021056afe9b13dd149270722f9e3..91d87c5d5f6171bdf9a7a6eaaa966a3347c4a312 100644 (file)
@@ -2083,8 +2083,13 @@ _______EOF
 
 _______EOF
 
-echo "typedef signed $glib_size_type_define gssize;" >> $outfile
-echo "typedef unsigned $glib_size_type_define gsize;" >> $outfile
+        cat >>$outfile <<_______EOF
+typedef signed $glib_size_type_define gssize;
+typedef unsigned $glib_size_type_define gsize;
+#define G_GSIZE_MODIFIER $gsize_modifier
+#define G_GSSIZE_FORMAT $gssize_format
+#define G_GSIZE_FORMAT $gsize_format
+_______EOF
 
        if test -z "$glib_unknown_void_p"; then
          cat >>$outfile <<_______EOF
@@ -2396,6 +2401,24 @@ glib_size_type_define=$glib_size_type
 glib_void_p=$ac_cv_sizeof_long
 glib_long=$ac_cv_sizeof_void_p
 
+case $glib_size_type in
+short)
+  gsize_modifier='"h"'
+  gsize_format='"hu"'
+  gssize_format='"hi"'
+  ;;
+int)
+  gsize_modifier='""'
+  gsize_format='"u"'
+  gssize_format='"i"'
+  ;;
+long)
+  gsize_modifier='"l"'
+  gsize_format='"lu"'
+  gssize_format='"li"'
+  ;;
+esac
+
 gintbits=`expr $ac_cv_sizeof_int \* 8`
 glongbits=`expr $ac_cv_sizeof_long \* 8`
 
index b9b061c0769cb982824b8d06adafd21de9886d63..5dabe077b465022408af34291b7884603893372d 100644 (file)
@@ -93,6 +93,8 @@ main (int   argc,
   TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT32_FORMAT, (guint32)5) == 1 && !strcmp (buf, "5"));
   TEST (NULL, g_snprintf (buf, 128, "%" G_GINT64_FORMAT, (gint64)-5) == 2 && !strcmp (buf, "-5"));
   TEST (NULL, g_snprintf (buf, 128, "%" G_GUINT64_FORMAT, (guint64)5) == 1 && !strcmp (buf, "5"));
+  TEST (NULL, g_snprintf (buf, 128, "%" G_GSSIZE_FORMAT, (gssize)-5) == 2 && !strcmp (buf, "-5"));
+  TEST (NULL, g_snprintf (buf, 128, "%" G_GSIZE_FORMAT, (gsize)5) == 1 && !strcmp (buf, "5"));
   /* %d, flags */
   TEST (NULL, g_snprintf (buf, 128, "%-d", 5) == 1 && !strcmp (buf, "5"));
   TEST (NULL, g_snprintf (buf, 128, "%-+d", 5) == 2 && !strcmp (buf, "+5"));
index 2bc2d8bd9f484b57f7d19d0296e4585167f506d6..c4a8c2c45967a9b04cc90abf4e1bda9edf47de88 100644 (file)
@@ -425,14 +425,14 @@ main (int   argc,
   g_print ("tmp-dir: %s\n", g_get_tmp_dir ());
 
   /* type sizes */
-  g_print ("checking size of gint8: %d", (int)sizeof (gint8));
+  g_print ("checking size of gint8: %"    G_GSIZE_FORMAT, sizeof (gint8));
   TEST (NULL, sizeof (gint8) == 1);
-  g_print ("\nchecking size of gint16: %d", (int)sizeof (gint16));
+  g_print ("\nchecking size of gint16: %" G_GSIZE_FORMAT, sizeof (gint16));
   TEST (NULL, sizeof (gint16) == 2);
-  g_print ("\nchecking size of gint32: %d", (int)sizeof (gint32));
+  g_print ("\nchecking size of gint32: %" G_GSIZE_FORMAT, sizeof (gint32));
   TEST (NULL, sizeof (gint32) == 4);
-  g_print ("\nchecking size of gsize: %d", (int)sizeof (gsize));
-  g_print ("\nchecking size of gint64: %d", (int)sizeof (gint64));
+  g_print ("\nchecking size of gsize: %"  G_GSIZE_FORMAT, sizeof (gsize));
+  g_print ("\nchecking size of gint64: %" G_GSIZE_FORMAT, sizeof (gint64));
   TEST (NULL, sizeof (gint64) == 8);
   g_print ("\n");
 
index e0d17d0a076ecd3609cb5fc2fd595fb2e29bdebd..5163b1f82a8cacaac390e237ecc4750f6ffd3ade 100644 (file)
@@ -54,6 +54,10 @@ main (int   argc,
          gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU);
   gint64 gi64t1;
   gint64 gi64t2;
+  gssize gsst1;
+  gssize gsst2;
+  gsize  gst1;
+  gsize  gst2;
 
   /* type sizes */
   g_assert (sizeof (gint8) == 1);
@@ -117,6 +121,16 @@ main (int   argc,
   g_free (string);
   g_assert (gi64t1 == gi64t2);
   g_assert (gu64t1 == gu64t2);
+
+  gsst1 = -0x3AFAFAFA;
+  gst1 = 0xFAFAFAFA; 
+
+#define FORMATSIZE "%" G_GSSIZE_FORMAT " %" G_GSIZE_FORMAT "\n"
+  string = g_strdup_printf (FORMATSIZE, gsst1, gst1);
+  sscanf (string, FORMAT64, &gsst2, &gst2);
+  g_free (string);
+  g_assert (gsst1 == gsst2);
+  g_assert (gst1 == gst2);
   
   return 0;
 }