From 2a3bf25a5f0dc2424cdf9f9c3dcc15e59c75f258 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Wauthy?= <pollux@xfce.org>
Date: Thu, 14 Oct 2004 08:26:20 +0000
Subject: [PATCH] fix #395

(Old svn revision: 12070)
---
 mcs-plugin/xfwm4_shortcuteditor.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/mcs-plugin/xfwm4_shortcuteditor.c b/mcs-plugin/xfwm4_shortcuteditor.c
index 08945c669..92eff51b9 100644
--- a/mcs-plugin/xfwm4_shortcuteditor.c
+++ b/mcs-plugin/xfwm4_shortcuteditor.c
@@ -1113,7 +1113,9 @@ cb_compose_shortcut (GtkWidget * widget, GdkEventKey * event, gpointer data)
     GdkModifierType consumed_modifiers = 0;
     guint keyval;
     gchar *accelerator;
-    gchar **shortcut;
+    gint i;
+    gchar **shortcuts;
+    gchar **current_shortcut;
 
     if (is_modifier (event->hardware_keycode))
       return TRUE;
@@ -1137,22 +1139,28 @@ cb_compose_shortcut (GtkWidget * widget, GdkEventKey * event, gpointer data)
 
     accelerator = gtk_accelerator_name (keyval, event->state & ~consumed_modifiers);
 
-    shortcut = g_strsplit_set (accelerator, "<>", 0);
+    for (i = 0; i < strlen (accelerator); i++)
+    {
+	if (accelerator[i] == '>')
+	    accelerator[i] = '<';
+    }
 
-    while (*shortcut)
+    shortcuts = g_strsplit (accelerator, "<", 0);
+
+    current_shortcut = shortcuts;
+    while (*current_shortcut)
     {
-        if (strlen (*shortcut) > 0 && (strcmp (*shortcut, "Mod2") != 0))
+        if (strlen (*current_shortcut) > 0 && (strcmp (*current_shortcut, "Mod2") != 0))
         {
-            strcat (shortcut_string, *shortcut);
+            strcat (shortcut_string, *current_shortcut);
             strcat (shortcut_string, "+");
         }
-        g_free(*shortcut);
-        *shortcut++;
+        *current_shortcut++;
     }
      
-    shortcut_string[strlen (shortcut_string) - 1] = '\0';
+    shortcut_string[strlen (shortcut_string) - 1] = '\0'; /* replace the trailing '+' */
     g_free (accelerator);
-   
+    g_strfreev (shortcuts);
 
     selection3 = gtk_tree_view_get_selection (GTK_TREE_VIEW (itf->treeview3));
     selection4 = gtk_tree_view_get_selection (GTK_TREE_VIEW (itf->treeview4));
-- 
GitLab