aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-10-22 12:20:36 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-10-22 12:20:36 +0000
commite9f13d771c0e175743c323b596ec61f4c8bec99f (patch)
tree531c5ef5853d82d97487605fcc26fdf48835e06f
parent0c0cec7e69ccd4c83f079751bfda2176c2b7afe4 (diff)
g_strcmp0 first occures in GLIB 2.16 define it localy if it does not exist
to make builds on Fedora 8 with GTK 2.12 work. svn path=/trunk/; revision=45707
-rw-r--r--epan/strutil.c29
-rw-r--r--epan/strutil.h8
-rw-r--r--fileset.c1
3 files changed, 38 insertions, 0 deletions
diff --git a/epan/strutil.c b/epan/strutil.c
index fa6b6aa0e4..1e1c12b4df 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -1084,3 +1084,32 @@ gchar *string_replace(const gchar* str, const gchar *old_val, const gchar *new_v
return new_str;
}
+
+
+/**
+ * g_strcmp0 appears first in GLIB 2.16, define it locally for earlier versions.
+ * Copied from gtestutils.c in glib
+ * g_strcmp0:
+ * @str1: (allow-none): a C string or %NULL
+ * @str2: (allow-none): another C string or %NULL
+ *
+ * Compares @str1 and @str2 like strcmp(). Handles %NULL
+ * gracefully by sorting it before non-%NULL strings.
+ * Comparing two %NULL pointers returns 0.
+ *
+ * Returns: -1, 0 or 1, if @str1 is <, == or > than @str2.
+ *
+ * Since: 2.16
+ */
+#if !GLIB_CHECK_VERSION(2,16,0)
+int
+g_strcmp0 (const char *str1,
+ const char *str2)
+{
+ if (!str1)
+ return -(str1 != str2);
+ if (!str2)
+ return str1 != str2;
+ return strcmp (str1, str2);
+}
+#endif /* GLIB_CHECK_VERSION(2,16,0) */
diff --git a/epan/strutil.h b/epan/strutil.h
index 2cc8b80d7b..f64316ed86 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -272,6 +272,14 @@ gchar* ws_strdup_unescape_char (const gchar *str, const gchar chr);
*/
gchar *string_replace(const gchar* str, const gchar *old_val, const gchar *new_val);
+/**
+ * g_strcmp0 appears first in GLIB 2.16, define it locally for earlier versions.
+ */
+
+#if !GLIB_CHECK_VERSION(2,16,0)
+int g_strcmp0 (const char *str1,
+ const char *str2);
+#endif /* GLIB_CHECK_VERSION(2,16,0) */
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/fileset.c b/fileset.c
index 66f28a6a0b..869ae26b09 100644
--- a/fileset.c
+++ b/fileset.c
@@ -54,6 +54,7 @@
#include "globals.h"
#include <epan/filesystem.h>
+#include <epan/strutil.h>
#include "fileset.h"