[evolution-patches] killev fix



This fixes killev to be able to deal with both "evolution" and
"evolution-1.4". (Actually, it will deal with evolution-wombat-1.4, etc
too, but whatever.)


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ChangeLog,v
retrieving revision 1.1211
diff -u -r1.1211 ChangeLog
--- ChangeLog	17 Jun 2003 03:40:09 -0000	1.1211
+++ ChangeLog	19 Jun 2003 19:07:09 -0000
@@ -1,3 +1,8 @@
+2003-06-19  Dan Winship  <danw ximian com>
+
+	* tools/killev.c (kill_component): clean this up a little and make
+	it deal with "evolution" vs "evolution-1.4"
+
 2003-06-17  Not Zed  <NotZed Ximian com>
 
 	* NEWS: Updated for current mail stuff.
Index: tools/killev.c
===================================================================
RCS file: /cvs/gnome/evolution/tools/killev.c,v
retrieving revision 1.1
diff -u -r1.1 killev.c
--- tools/killev.c	7 Apr 2003 16:06:50 -0000	1.1
+++ tools/killev.c	19 Jun 2003 19:07:09 -0000
@@ -84,36 +84,37 @@
 	return TRUE;
 };
 
+static const char *patterns[] = {
+	"%s", "%.16s", "lt-%s", "lt-%.13s"
+};
+static const int n_patterns = sizeof (patterns) / sizeof (patterns[0]);
+
 static gboolean
 kill_component (gpointer key, gpointer value, gpointer data)
 {
 	KillevComponent *comp = value;
-	char *exe_name;
-
-	if (kill_process (comp->location, comp))
-		return TRUE;
+	char *base_name, *exe_name, *dash;
+	int i;
 
-	exe_name = g_strdup_printf ("lt-%s", comp->location);
-	if (kill_process (exe_name, comp)) {
-		g_free (exe_name);
-		return TRUE;
-	}
-
-	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;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]