From d55270e287c70e94c286c4f29f60264fb26715c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Wed, 1 Nov 2006 20:45:35 +0000 Subject: [PATCH] Fix gnc_history_generate_label to search for the correct dir separator and not to crash when there is none. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15068 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-plugin-file-history.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gnome-utils/gnc-plugin-file-history.c b/src/gnome-utils/gnc-plugin-file-history.c index 7118d949de..5de199e45b 100644 --- a/src/gnome-utils/gnc-plugin-file-history.c +++ b/src/gnome-utils/gnc-plugin-file-history.c @@ -251,17 +251,19 @@ gnc_history_generate_label (int index, const gchar *filename) dst += g_sprintf(result, "_%d ", (index + 1) % 10); /* Find the filename portion of the path */ - src = g_utf8_strrchr(filename, -1, '/'); - src = g_utf8_next_char(src); + src = g_utf8_strrchr(filename, -1, G_DIR_SEPARATOR); + if (src) { + src = g_utf8_next_char(src); - /* Fix up any underline characters so they aren't mistaken as - * command accelerator keys. */ - for ( ; *src; src = g_utf8_next_char(src)) { - unichar = g_utf8_get_char(src); - dst += g_unichar_to_utf8 (unichar, dst); + /* Fix up any underline characters so they aren't mistaken as + * command accelerator keys. */ + for ( ; *src; src = g_utf8_next_char(src)) { + unichar = g_utf8_get_char(src); + dst += g_unichar_to_utf8 (unichar, dst); - if (unichar == '_') - dst += g_unichar_to_utf8 ('_', dst); + if (unichar == '_') + dst += g_unichar_to_utf8 ('_', dst); + } } *dst = '\0';