aboutsummaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-02-15 06:11:10 +0000
committerdos-reis <gdr@axiomatics.org>2008-02-15 06:11:10 +0000
commit933e278d8db01dee8e057ecdab6a1b91a79c45de (patch)
tree3cb275e1738b96dd00c60f27c893bad52dddbe70 /src/driver
parent8042d68702fdeda99a7e9e240b40e580ec82a8d8 (diff)
downloadopen-axiom-933e278d8db01dee8e057ecdab6a1b91a79c45de.tar.gz
Handle path with embedded space as arguments.
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/utils.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/driver/utils.c b/src/driver/utils.c
index c83937c8..3d5874da 100644
--- a/src/driver/utils.c
+++ b/src/driver/utils.c
@@ -206,12 +206,13 @@ openaxiom_execute_core(const openaxiom_command* command,
command_line_length += cur;
for (i = 0; i < command->rt_argc; ++i)
command_line_length += 1 /* blank char as separator */
+ + 2 /* quotes around every argument. */
+ strlen(command->rt_argv[i]); /* room for each argument */
/* Don't forget room for the doubledash string. */
command_line_length += sizeof("--") - 1;
/* And arguments to the actual command. */
for (i = 1; i < command->core_argc; ++i)
- command_line_length += 1 + strlen(command->core_argv[i]);
+ command_line_length += 1 + 2 + strlen(command->core_argv[i]);
/* Now, build the actual command line. This is done by
concatenating the arguments into a single string. */
@@ -220,13 +221,10 @@ openaxiom_execute_core(const openaxiom_command* command,
for (i = 0; i < command->rt_argc; ++i) {
const int arg_length = strlen(command->rt_argv[i]);
command_line[cur++] = ' ';
- /* Note that strcpy will terminate `command_line' with a NUL
- character, and since the next iteration will write the
- blank precisely where the NUL character is, the whole command
- line string will be a proper C-style string when the loop
- normally exits. */
+ command_line[cur++] = '"';
strcpy(command_line + cur, command->rt_argv[i]);
cur += arg_length;
+ command_line[cur++] = '"';
}
command_line[cur++] = ' ';
command_line[cur++] = '-'; /* start arguments to the core executable. */
@@ -234,9 +232,12 @@ openaxiom_execute_core(const openaxiom_command* command,
for (i = 1; i < command->core_argc; ++i) {
const int arg_length = strlen(command->core_argv[i]);
command_line[cur++] = ' ';
+ command_line[cur++] = '"';
strcpy(command_line + cur, command->core_argv[i]);
cur += arg_length;
+ command_line[cur++] = '"';
}
+ command_line[cur] = '\0'; /* The command line is done. */
if(CreateProcess(/* lpApplicationName */ execpath,
/* lpCommandLine */ command_line,