glib r7552 - in trunk: . glib glib/pcre glib/tests



Author: danw
Date: Fri Sep 26 16:00:45 2008
New Revision: 7552
URL: http://svn.gnome.org/viewvc/glib?rev=7552&view=rev

Log:
	* glib/gthreadpool.c (wakeup_thread_marker): make this a "const
	gpointer" rather than a gconstpointer to avoid warnings later

	* glib/pcre/pcre_ucp_searchfuncs.c:
	* glib/pcre/pcre_valid_utf8.c: #include "config.h"

	* glib/tests/printf.c (test_d): fool gcc into not warning about
	some printf format strings that we know are dubious


Modified:
   trunk/ChangeLog
   trunk/glib/gthreadpool.c
   trunk/glib/pcre/pcre_ucp_searchfuncs.c
   trunk/glib/pcre/pcre_valid_utf8.c
   trunk/glib/tests/printf.c

Modified: trunk/glib/gthreadpool.c
==============================================================================
--- trunk/glib/gthreadpool.c	(original)
+++ trunk/glib/gthreadpool.c	Fri Sep 26 16:00:45 2008
@@ -51,7 +51,7 @@
 /* The following is just an address to mark the wakeup order for a
  * thread, it could be any address (as long, as it isn't a valid
  * GThreadPool address) */
-static gconstpointer const wakeup_thread_marker = (gconstpointer) &g_thread_pool_new;
+static const gpointer wakeup_thread_marker = (gpointer) &g_thread_pool_new;
 static gint wakeup_thread_serial = 0;
 
 /* Here all unused threads are waiting  */

Modified: trunk/glib/pcre/pcre_ucp_searchfuncs.c
==============================================================================
--- trunk/glib/pcre/pcre_ucp_searchfuncs.c	(original)
+++ trunk/glib/pcre/pcre_ucp_searchfuncs.c	Fri Sep 26 16:00:45 2008
@@ -43,6 +43,10 @@
 /* This module contains code for searching the table of Unicode character
 properties. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "pcre_internal.h"
 
 #include "ucp.h"               /* Category definitions */

Modified: trunk/glib/pcre/pcre_valid_utf8.c
==============================================================================
--- trunk/glib/pcre/pcre_valid_utf8.c	(original)
+++ trunk/glib/pcre/pcre_valid_utf8.c	Fri Sep 26 16:00:45 2008
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "pcre_internal.h"
 
 /*

Modified: trunk/glib/tests/printf.c
==============================================================================
--- trunk/glib/tests/printf.c	(original)
+++ trunk/glib/tests/printf.c	Fri Sep 26 16:00:45 2008
@@ -69,6 +69,7 @@
 {
   gchar buf[128];
   gint res;
+  const gchar *fmt;
 
   /* %d basic formatting */
 
@@ -172,21 +173,28 @@
   g_assert_cmpint (res, ==, 1);
   g_assert_cmpstr (buf, ==, " ");
 
-  res = g_snprintf (buf, 128, "% +d", 5);
-  g_assert_cmpint (res, ==, 2);
-  g_assert_cmpstr (buf, ==, "+5");
-
   res = g_snprintf (buf, 128, "%03d", 5);
   g_assert_cmpint (res, ==, 3);
   g_assert_cmpstr (buf, ==, "005");
 
-  res = g_snprintf (buf, 128, "%-03d", -5);
-  g_assert_cmpint (res, ==, 3);
-  g_assert_cmpstr (buf, ==, "-5 ");
-
   res = g_snprintf (buf, 128, "%03d", -5);
   g_assert_cmpint (res, ==, 3);
   g_assert_cmpstr (buf, ==, "-05");
+
+  /* gcc emits warnings for the following formats, since the C spec
+   * says some of the flags must be ignored. (The " " in "% +d" and
+   * the "0" in "%-03d".) But we need to test that our printf gets
+   * those rules right. So we fool gcc into not warning.
+   */
+  fmt = "% +d";
+  res = g_snprintf (buf, 128, fmt, 5);
+  g_assert_cmpint (res, ==, 2);
+  g_assert_cmpstr (buf, ==, "+5");
+
+  fmt = "%-03d";
+  res = g_snprintf (buf, 128, fmt, -5);
+  g_assert_cmpint (res, ==, 3);
+  g_assert_cmpstr (buf, ==, "-5 ");
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]