changeset 1386:4da6d326919c

Add debug versions of path_to_utf8() and path_from_utf8() which allows to report the caller file and line, this is enabled with --enable-debug-flags (and developer mode too).
author zas_
date Fri, 06 Mar 2009 15:04:35 +0000
parents b4e6fee484f7
children 6f31fa931d3f
files configure.in src/ui_fileops.c src/ui_fileops.h
diffstat 3 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Fri Mar 06 14:53:32 2009 +0000
+++ b/configure.in	Fri Mar 06 15:04:35 2009 +0000
@@ -73,7 +73,7 @@
     CXXFLAGS="${CXXFLAGS} -Wall"
     CFLAGS="${CFLAGS} -Wstrict-prototypes -Wall"
   fi
-  __COMMONFLAGS="-g -O0 -Wextra -Wunused-value -Wunused-variable -Wunused-function -Wunused-label -Wcomment -Wmissing-braces -Wparentheses -Wreturn-type -Wswitch -Wstrict-aliasing -Wno-unused-parameter -Wformat -Wformat-security"
+  __COMMONFLAGS="-g -O0 -Wextra -Wunused-value -Wunused-variable -Wunused-function -Wunused-label -Wcomment -Wmissing-braces -Wparentheses -Wreturn-type -Wswitch -Wstrict-aliasing -Wno-unused-parameter -Wformat -Wformat-security -DGQ_DEBUG_PATH_UTF8=1"
   CXXFLAGS="${CXXFLAGS} ${__COMMONFLAGS}"
   CFLAGS="${CFLAGS} ${__COMMONFLAGS} -Wimplicit-int -Werror-implicit-function-declaration"
   __IS_DEBUG_FLAGS=yes
--- a/src/ui_fileops.c	Fri Mar 06 14:53:32 2009 +0000
+++ b/src/ui_fileops.c	Fri Mar 06 15:04:35 2009 +0000
@@ -127,7 +127,11 @@
 	g_string_free(string, TRUE);
 }
 
+#if GQ_DEBUG_PATH_UTF8
+gchar *path_to_utf8_debug(const gchar *path, const gchar *file, gint line)
+#else
 gchar *path_to_utf8(const gchar *path)
+#endif
 {
 	gchar *utf8;
 	GError *error = NULL;
@@ -137,7 +141,11 @@
 	utf8 = g_filename_to_utf8(path, -1, NULL, NULL, &error);
 	if (error)
 		{
+#if GQ_DEBUG_PATH_UTF8
+		log_printf("%s:%d: Unable to convert filename to UTF-8:\n%s\n%s\n", file, line, path, error->message);
+#else
 		log_printf("Unable to convert filename to UTF-8:\n%s\n%s\n", path, error->message);
+#endif
 		g_error_free(error);
 		encoding_dialog(path);
 		}
@@ -150,7 +158,11 @@
 	return utf8;
 }
 
+#if GQ_DEBUG_PATH_UTF8
+gchar *path_from_utf8_debug(const gchar *utf8, const gchar *file, gint line)
+#else
 gchar *path_from_utf8(const gchar *utf8)
+#endif
 {
 	gchar *path;
 	GError *error = NULL;
@@ -160,7 +172,11 @@
 	path = g_filename_from_utf8(utf8, -1, NULL, NULL, &error);
 	if (error)
 		{
+#if GQ_DEBUG_PATH_UTF8
+		log_printf("%s:%d: Unable to convert filename to locale from UTF-8:\n%s\n%s\n", file, line, utf8, error->message);
+#else
 		log_printf("Unable to convert filename to locale from UTF-8:\n%s\n%s\n", utf8, error->message);
+#endif
 		g_error_free(error);
 		}
 	if (!path)
--- a/src/ui_fileops.h	Fri Mar 06 14:53:32 2009 +0000
+++ b/src/ui_fileops.h	Fri Mar 06 15:04:35 2009 +0000
@@ -31,8 +31,15 @@
 		g_free(msg); \
 	} while (0)
 
+#if GQ_DEBUG_PATH_UTF8
+#define path_to_utf8(path) path_to_utf8_debug(path, __FILE__, __LINE__)
+#define path_from_utf8(utf8) path_from_utf8_debug(utf8, __FILE__, __LINE__)
+gchar *path_to_utf8_debug(const gchar *path, const gchar *file, gint line);
+gchar *path_from_utf8_debug(const gchar *utf8, const gchar *file, gint line);
+#else
 gchar *path_to_utf8(const gchar *path);
-gchar *path_from_utf8(const gchar *path);
+gchar *path_from_utf8(const gchar *utf8);
+#endif
 
 const gchar *xdg_data_home_get(void);
 const gchar *xdg_config_home_get(void);