start.exe: put double quotes around arguments with spaces

Lei Zhang thestig at google.com
Tue Jul 10 16:50:11 CDT 2007


Hi,

Running start.exe prog arg1 "arg2 arg3"
should run prog arg1 "arg2 arg3" instead of prog arg1 arg2 arg3
-------------- next part --------------
From e0c47ffff906828955ad016321ea6a9b8c5c94d2 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Tue, 10 Jul 2007 14:47:02 -0700
Subject: start.exe: put double quotes around arguments with spaces
---
 programs/start/start.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/programs/start/start.c b/programs/start/start.c
index 1c437fb..b3a8f1c 100644
--- a/programs/start/start.c
+++ b/programs/start/start.c
@@ -107,12 +107,21 @@ static char *build_args( int argc, char 
 	char *ret, *p;
 
 	for (i = 0; i < argc; i++ )
+	{
 		len += strlen(argv[i]) + 1;
+		if (strchr(argv[i], ' '))
+			len += 2;
+	}
 	ret = HeapAlloc( GetProcessHeap(), 0, len );
 	ret[0] = 0;
 
 	for (i = 0, p = ret; i < argc; i++ )
-		p += sprintf(p, " %s", argv[i]);
+	{
+		if (strchr(argv[i], ' '))
+			p += sprintf(p, " \"%s\"", argv[i]);
+		else
+			p += sprintf(p, " %s", argv[i]);
+	}
 	return ret;
 }
 
-- 
1.4.1


More information about the wine-patches mailing list