From e586397c0569f0b5ed6b7764f1d2ff74fc26d9b3 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 20 Jun 2003 15:32:01 +0000 Subject: clean this up a little and make it deal with "evolution" vs * tools/killev.c (kill_component): clean this up a little and make it deal with "evolution" vs "evolution-1.4" svn path=/trunk/; revision=21499 --- ChangeLog | 5 +++++ tools/killev.c | 37 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45dadec25e..6f5db1dfc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-06-19 Dan Winship + + * tools/killev.c (kill_component): clean this up a little and make + it deal with "evolution" vs "evolution-1.4" + 2003-06-19 Danilo Ĺ egan * configure.in: Added "sr" and "sr@Latn" to ALL_LINGUAS. diff --git a/tools/killev.c b/tools/killev.c index 6904b02243..0c735c0a19 100644 --- a/tools/killev.c +++ b/tools/killev.c @@ -84,36 +84,37 @@ kill_process (const char *proc_name, KillevComponent *comp) return TRUE; }; +static const char *patterns[] = { + "%s", "%.16s", "lt-%s", "lt-%.13s" +}; +static const int n_patterns = G_N_ELEMENTS (patterns); + static gboolean kill_component (gpointer key, gpointer value, gpointer data) { KillevComponent *comp = value; - char *exe_name; - - if (kill_process (comp->location, comp)) - return TRUE; - - exe_name = g_strdup_printf ("lt-%s", comp->location); - if (kill_process (exe_name, comp)) { - g_free (exe_name); - return TRUE; - } + char *base_name, *exe_name, *dash; + int i; - if (strlen (exe_name) > 16) { - exe_name[16] = '\0'; + base_name = g_strdup (comp->location); + try_again: + for (i = 0; i < n_patterns; i++) { + exe_name = g_strdup_printf (patterns[i], base_name); if (kill_process (exe_name, comp)) { - g_free (exe_name); + g_free (exe_name); + g_free (base_name); return TRUE; } + g_free (exe_name); } - g_free (exe_name); - if (strlen (comp->location) > 16) { - exe_name = g_strndup (comp->location, 16); - kill_process (exe_name, comp); - g_free (exe_name); + dash = strrchr (base_name, '-'); + if (dash && !strcmp (dash + 1, BASE_VERSION)) { + *dash = '\0'; + goto try_again; } + g_free (base_name); return TRUE; } -- cgit v1.2.3