Add debug versions of path_to_utf8() and path_from_utf8() which allows to report...
authorLaurent Monin <geeqie@norz.org>
Fri, 6 Mar 2009 15:04:35 +0000 (15:04 +0000)
committerLaurent Monin <geeqie@norz.org>
Fri, 6 Mar 2009 15:04:35 +0000 (15:04 +0000)
configure.in
src/ui_fileops.c
src/ui_fileops.h

index d3f0fbe..05bde6b 100644 (file)
@@ -73,7 +73,7 @@ then
     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
index c30e372..2c8d48c 100644 (file)
@@ -127,7 +127,11 @@ static void encoding_dialog(const gchar *path)
        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 @@ gchar *path_to_utf8(const gchar *path)
        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 @@ gchar *path_to_utf8(const gchar *path)
        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 @@ gchar *path_from_utf8(const gchar *utf8)
        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)
index c00b335..fc449d7 100644 (file)
@@ -31,8 +31,15 @@ void print_term(const gchar *text_utf8);
                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);