[geany/geany] a3f417: Alter templates.c to use the new spawning module

Dimitar Zhekov git-noreply at xxxxx
Fri May 15 17:07:24 UTC 2015


Branch:      refs/heads/master
Author:      Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer:   Dimitar Zhekov <dimitar.zhekov at gmail.com>
Date:        Sat, 21 Mar 2015 17:36:14 UTC
Commit:      a3f4170a4bd503e26208a5eb5dbab93b4761fbfe
             https://github.com/geany/geany/commit/a3f4170a4bd503e26208a5eb5dbab93b4761fbfe

Log Message:
-----------
Alter templates.c to use the new spawning module


Modified Paths:
--------------
    src/templates.c

Modified: src/templates.c
44 lines changed, 22 insertions(+), 22 deletions(-)
===================================================================
@@ -37,6 +37,7 @@
 #include "geany.h"
 #include "geanymenubuttonaction.h"
 #include "geanyobject.h"
+#include "spawn.h"
 #include "support.h"
 #include "toolbar.h"
 #include "ui_utils.h"
@@ -594,33 +595,32 @@ static void templates_replace_default_dates(GString *text)
 static gchar *run_command(const gchar *command, const gchar *file_name,
 						  const gchar *file_type, const gchar *func_name)
 {
+	GString *output = g_string_new(NULL);
 	gchar *result = NULL;
-	gchar **argv;
+	GError *error = NULL;
+	gchar **env;
 
-	if (g_shell_parse_argv(command, NULL, &argv, NULL))
-	{
-		GError *error = NULL;
-		gchar **env;
+	file_name = (file_name != NULL) ? file_name : "";
+	file_type = (file_type != NULL) ? file_type : "";
+	func_name = (func_name != NULL) ? func_name : "";
 
-		file_name = (file_name != NULL) ? file_name : "";
-		file_type = (file_type != NULL) ? file_type : "";
-		func_name = (func_name != NULL) ? func_name : "";
+	env = utils_copy_environment(NULL,
+		"GEANY_FILENAME", file_name,
+		"GEANY_FILETYPE", file_type,
+		"GEANY_FUNCNAME", func_name,
+		NULL);
 
-		env = utils_copy_environment(NULL,
-			"GEANY_FILENAME", file_name,
-			"GEANY_FILETYPE", file_type,
-			"GEANY_FUNCNAME", func_name,
-			NULL);
-		if (! utils_spawn_sync(NULL, argv, env, G_SPAWN_SEARCH_PATH,
-				NULL, NULL, &result, NULL, NULL, &error))
-		{
-			g_warning("templates_replace_command: %s", error->message);
-			g_error_free(error);
-			result = NULL;
-		}
-		g_strfreev(argv);
-		g_strfreev(env);
+	if (spawn_sync(NULL, command, NULL, env, NULL, output, NULL, NULL, &error))
+	{
+		result = g_string_free(output, FALSE);
 	}
+	else
+	{
+		g_warning("templates_replace_command: %s", error->message);
+		g_error_free(error);
+	}
+
+	g_strfreev(env);
 	return result;
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list