Revision: 2028 http://geany.svn.sourceforge.net/geany/?rev=2028&view=rev Author: eht16 Date: 2007-11-06 09:07:26 -0800 (Tue, 06 Nov 2007)
Log Message: ----------- Quote first element of command line when using Compile, Build and Make commands on Windows to avoid problems if the tools are specified with full path.
Modified Paths: -------------- trunk/ChangeLog trunk/src/build.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-11-06 16:59:01 UTC (rev 2027) +++ trunk/ChangeLog 2007-11-06 17:07:26 UTC (rev 2028) @@ -1,6 +1,9 @@ 2007-11-06 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/build.c: Enable stopping of Run command on Windows. + * src/build.c: Quote first element of command line when using Compile, + Build and Make commands on Windows to avoid problems + if the tools are specified with full path.
2007-11-06 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2007-11-06 16:59:01 UTC (rev 2027) +++ trunk/src/build.c 2007-11-06 17:07:26 UTC (rev 2028) @@ -468,6 +468,29 @@ }
+#ifdef G_OS_WIN32 +/* cmd is a command line separated with spaces, first element will be escaped with double quotes + * and a newly allocated string will be returned */ +static gchar *quote_executable(const gchar *cmd) +{ + gchar **fields; + gchar *result; + + if (! NZV(cmd)) + return NULL; + + fields = g_strsplit(cmd, " ", 2); + if (fields == NULL || g_strv_length(fields) != 2) + return g_strdup(cmd); + + result = g_strconcat(""", fields[0], "" ", fields[1], NULL); + + g_strfreev(fields); + return result; +} +#endif + + /* dir is the UTF-8 working directory to run cmd in. It can be NULL to use the * idx document directory */ static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir) @@ -503,6 +526,10 @@ g_free(executable);
#ifdef G_OS_WIN32 + // due to g_shell_parse_argv() we need to enclose the command(first element) of cmd_string with + // "" if the command contains a full path(i.e. backslashes) otherwise the backslashes will be + // eaten by g_shell_parse_argv(). + setptr(cmd_string, quote_executable(cmd_string)); if (! g_shell_parse_argv(cmd_string, NULL, &argv, NULL)) // if automatic parsing failed, fall back to simple, unsafe argv creation argv = g_strsplit(cmd_string, " ", 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.