shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile

Ilya Basin basinilya at gmail.com
Wed Mar 17 10:21:00 CDT 2010


1) removes the block of code that splits lpFile into filename and
parameters and removes '"'s from filename . Even without this block
ShellExecute not fails with quoted lpFile.

2) removes 2 corresponding todo_wine's from tests.

The real application affected by this bug is uTorrent: if you have 2
downloads containing, say,
"foo/bar.avi" and "foo 2/baz.avi", when you double click the latter
avi file, it'll open the explorerin folder "foo" instead.

The related bug is:
http://bugs.winehq.org/show_bug.cgi?id=19385 ( the 'wine start'
launcher does not open MS Office documents that have spaces in their
path )
But don't expect this patch to fully fix it, mabe partially.

Ran "make test" before and after from the top level.
Both git and "1.1.40" were unstable in the following tests (sometimes
succeed, sometimes fail):
  dlls/urlmon/tests/url.ok
  dlls/gdi32/tests/font.ok
  dlls/gdiplus/tests/font.ok
  dlls/rpcrt4/tests/rpc.ok
  dlls/rpcrt4/tests/server.ok
So disabled them. Other tests succeed.

---
 dlls/shell32/shlexec.c       |   62 +-----------------------------------------
 dlls/shell32/tests/shlexec.c |   12 +++-----
 2 files changed, 6 insertions(+), 68 deletions(-)

diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index a81cada..b89bb08 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -1678,67 +1678,7 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
     /* Else, try to execute the filename */
     TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
 
-    /* separate out command line arguments from executable file name */
-    if (!*sei_tmp.lpParameters && !appKnownSingular) {
-	/* If the executable path is quoted, handle the rest of the command line as parameters. */
-	if (sei_tmp.lpFile[0] == '"') {
-	    LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
-	    LPWSTR dst = wfileName;
-	    LPWSTR end;
-
-	    /* copy the unquoted executable path to 'wfileName' */
-	    while(*src && *src!='"')
-		*dst++ = *src++;
-
-	    *dst = '\0';
-
-	    if (*src == '"') {
-		end = ++src;
-
-		while(isspace(*src))
-		    ++src;
-	    } else
-		end = src;
-
-	    /* copy the parameter string to 'wszParameters' */
-	    strcpyW(wszParameters, src);
-
-	    /* terminate previous command string after the quote character */
-	    *end = '\0';
-	}
-	else
-	{
-	    /* If the executable name is not quoted, we have to use this search loop here,
-	       that in CreateProcess() is not sufficient because it does not handle shell links. */
-	    WCHAR buffer[MAX_PATH], xlpFile[MAX_PATH];
-	    LPWSTR space, s;
-
-	    LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
-	    for(s=beg; (space=strchrW(s, ' ')); s=space+1) {
-		int idx = space-sei_tmp.lpFile;
-		memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
-		buffer[idx] = '\0';
-
-		/*FIXME This finds directory paths if the targeted file name contains spaces. */
-		if (SearchPathW(*sei_tmp.lpDirectory? sei_tmp.lpDirectory: NULL, buffer, wszExe, sizeof(xlpFile)/sizeof(xlpFile[0]), xlpFile, NULL))
-		{
-		    /* separate out command from parameter string */
-		    LPCWSTR p = space + 1;
-
-		    while(isspaceW(*p))
-			++p;
-
-		    strcpyW(wszParameters, p);
-		    *space = '\0';
-
-		    break;
-		}
-	    }
-
-           lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
-	}
-    } else
-       lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
+    lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
 
     lpFile = wfileName;
 
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index ffdf393..63c6d3b 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -876,12 +876,10 @@ static void test_lpFile_parsed(void)
     testfile = "%s\\drawback_file.noassoc foo.shlexec";
     sprintf(fileA, testfile, tmpdir);
     rc=shell_execute(NULL, fileA, NULL, NULL);
-    todo_wine {
-        ok(rc>32,
-            "expected success (33), got %s (%d), lpFile: %s \n",
-            rc > 32 ? "success" : "failure", rc, fileA
-            );
-    }
+    ok(rc>32,
+        "expected success (33), got %s (%d), lpFile: %s \n",
+        rc > 32 ? "success" : "failure", rc, fileA
+        );
 
     /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" on wine */
     testfile = "\"%s\\drawback_file.noassoc foo.shlexec\"";
@@ -1013,7 +1011,7 @@ static void test_filename(void)
                "%s failed: rc=%d err=%d\n", shell_call,
                rc, GetLastError());
         }
-        else todo_wine
+        else
         {
             ok(rc==test->rc, "%s failed: rc=%d err=%d\n", shell_call,
                rc, GetLastError());
-- 
1.7.0.2




More information about the wine-patches mailing list