changeset 4607:829c30fc87ba

Check that we have proper GNU libc version before enabling backtrace functionality in str_assert_utf8().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jun 2008 23:26:23 +0300
parents 6b76f8589f5d
children 23a9ded30c70
files src/audacious/strings.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/strings.c	Wed Jun 04 23:17:47 2008 +0300
+++ b/src/audacious/strings.c	Wed Jun 04 23:26:23 2008 +0300
@@ -296,7 +296,6 @@
     return str_to_utf8_fallback(str);
 }
 
-
 /* This function is here to ASSERT that a given string IS valid UTF-8.
  * If it is, a copy of the string is returned (use g_free() to deallocate it.)
  *
@@ -307,7 +306,10 @@
  * and will be eventually removed...
  * -- ccr
  */
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+#define HAVE_EXECINFO 1
 #include <execinfo.h>
+#endif
 
 gchar *
 str_assert_utf8(const gchar * str)
@@ -318,20 +320,23 @@
 
     /* already UTF-8? */
     if (!g_utf8_validate(str, -1, NULL)) {
+#ifdef HAVE_EXECINFO
 		gint i, nsymbols;
 		const gint nsymmax = 50;
 		void *addrbuf[nsymmax];
 		gchar **symbols;
 		nsymbols = backtrace(addrbuf, nsymmax);
 		symbols = backtrace_symbols(addrbuf, nsymbols);
-		
+#endif
+
 		fprintf(stderr, "WARNING! String '%s' was not UTF-8! Backtrace (%d):\n", str, nsymbols);
-		
+
+#ifdef HAVE_EXECINFO
 		for (i = 0; i < nsymbols; i++)
 			fprintf(stderr, "#%d > %s\n", i, symbols[i]);
 		
 		free(symbols);
-		
+#endif
 		return str_to_utf8(str);
     } else
     	return g_strdup(str);