SF.net SVN: geany: [2012] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Nov 4 09:57:47 UTC 2007


Revision: 2012
          http://geany.svn.sourceforge.net/geany/?rev=2012&view=rev
Author:   eht16
Date:     2007-11-04 01:57:47 -0800 (Sun, 04 Nov 2007)

Log Message:
-----------
Fix error in Compile and Build commands on Windows if the command contains double quotes. Fix error in Build command when the executable file name contains spaces(Linux and Windows).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-11-02 17:44:05 UTC (rev 2011)
+++ trunk/ChangeLog	2007-11-04 09:57:47 UTC (rev 2012)
@@ -1,3 +1,12 @@
+2007-11-04  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/build.c:
+   Fix error in Compile and Build commands on Windows if the command
+   contains double quotes.
+   Fix error in Build command when the executable file name contains
+   spaces(Linux and Windows).
+
+
 2007-11-02  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/sciwrappers.c:

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2007-11-02 17:44:05 UTC (rev 2011)
+++ trunk/src/build.c	2007-11-04 09:57:47 UTC (rev 2012)
@@ -403,18 +403,19 @@
 	if (doc_list[idx].file_type->id == GEANY_FILETYPES_D)
 	{	// the dmd compiler needs -of instead of -o and it accepts no whitespace after -of
 		gchar *tmp = g_path_get_basename(executable);
-
-		g_string_append(cmdstr, "-of");
+		// add double quotes around the executable file name in case of filenames with spaces
+		g_string_append(cmdstr, "-of \"");
 		g_string_append(cmdstr, tmp);
+		g_string_append_c(cmdstr, '\"');
 		g_free(tmp);
 	}
 	else
 	{
 		gchar *tmp = g_path_get_basename(executable);
-
-		g_string_append(cmdstr, "-o");
-		g_string_append_c(cmdstr, ' ');
+		// add double quotes around the executable file name in case of filenames with spaces
+		g_string_append(cmdstr, "-o \"");
 		g_string_append(cmdstr, tmp);
+		g_string_append_c(cmdstr, '\"');
 		g_free(tmp);
 	}
 
@@ -492,7 +493,9 @@
 	g_free(executable);
 
 #ifdef G_OS_WIN32
-	argv = g_strsplit(cmd_string, " ", 0);
+	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);
 #else
 	argv = g_new0(gchar *, 4);
 	argv[0] = g_strdup("/bin/sh");
@@ -751,7 +754,7 @@
 		if (term_argv[0] != NULL)
 		{
 			gchar *tmp = term_argv[0];
-			// g_find_program_in_path checks tmp exists and is executable
+			// g_find_program_in_path checks whether tmp exists and is executable
 			term_argv[0] = g_find_program_in_path(tmp);
 			g_free(tmp);
 		}
@@ -771,8 +774,13 @@
 		}
 #ifdef G_OS_WIN32
 		// command line arguments for cmd.exe
-		argv[term_argv_len   ]  = g_strdup("/Q /C");
-		argv[term_argv_len + 1] = g_path_get_basename(RUN_SCRIPT_CMD);
+		if (strstr(argv[0], "cmd.exe") != NULL)
+		{
+			argv[term_argv_len   ]  = g_strdup("/Q /C");
+			argv[term_argv_len + 1] = g_path_get_basename(RUN_SCRIPT_CMD);
+		}
+		else
+			argv[term_argv_len] = NULL;
 #else
 		argv[term_argv_len   ]  = g_strdup("-e");
 		argv[term_argv_len + 1] = g_strdup(RUN_SCRIPT_CMD);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list