# HG changeset patch # User Matti Hamalainen # Date 1212611183 -10800 # Node ID 829c30fc87ba1fc699d626b7a5c55da1d7d0a200 # Parent 6b76f8589f5db31475422730bc11fb50ab04777c Check that we have proper GNU libc version before enabling backtrace functionality in str_assert_utf8(). diff -r 6b76f8589f5d -r 829c30fc87ba src/audacious/strings.c --- 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 +#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);