diff src/editors.c @ 443:e7361d06d83a

editor_command_one(): tidy up.
author zas_
date Sun, 20 Apr 2008 13:30:36 +0000
parents 4b2d7f9af171
children 452b7ffeb7ad
line wrap: on
line diff
--- a/src/editors.c	Sun Apr 20 13:04:57 2008 +0000
+++ b/src/editors.c	Sun Apr 20 13:30:36 2008 +0000
@@ -545,31 +545,28 @@
 static gint editor_command_one(const gchar *template, GList *list, EditorData *ed)
 {
 	gchar *command;
-	gchar *working_directory;
 	FileData *fd = list->data;
-	gchar *args[4];
 	GPid pid;
 	gint standard_output;
 	gint standard_error;
 	gboolean ok;
 
-
 	ed->pid = -1;
-
-	working_directory = remove_level_from_path(fd->path);
-
 	ed->flags = editor_command_parse(template, list, &command);
 
 	ok = !(ed->flags & EDITOR_ERROR_MASK);
 
-
-	args[0] = COMMAND_SHELL;
-	args[1] = COMMAND_OPT;
-	args[2] = command;
-	args[3] = NULL;
-
 	if (ok)
 		{
+		gchar *working_directory;
+		gchar *args[4];
+
+		working_directory = remove_level_from_path(fd->path);
+		args[0] = COMMAND_SHELL;
+		args[1] = COMMAND_OPT;
+		args[2] = command;
+		args[3] = NULL;
+
 		ok = g_spawn_async_with_pipes(working_directory, args, NULL,
 				      G_SPAWN_DO_NOT_REAP_CHILD, /* GSpawnFlags */
 				      NULL, NULL,
@@ -578,6 +575,8 @@
 				      ed->vd ? &standard_output : NULL,
 				      ed->vd ? &standard_error : NULL,
 				      NULL);
+		
+		g_free(working_directory);
 
 		if (!ok) ed->flags |= EDITOR_ERROR_CANT_EXEC;
 		}
@@ -588,7 +587,6 @@
 		ed->pid = pid;
 		}
 
-
 	if (ed->vd)
 		{
 
@@ -622,10 +620,7 @@
 			}
 		}
 
-
-
 	g_free(command);
-	g_free(working_directory);
 
 	return ed->flags & EDITOR_ERROR_MASK;
 }
@@ -745,6 +740,7 @@
 {
 	editor_command_next_start(ed);
 }
+
 void editor_skip(gpointer ed)
 {
 	editor_command_done(ed);
@@ -770,7 +766,6 @@
 	if ((flags & EDITOR_VERBOSE_MULTI) && list && list->next)
 		flags |= EDITOR_VERBOSE;
 
-
 	if (flags & EDITOR_VERBOSE)
 		editor_verbose_window(ed, text);