cmd: Identify the program name using more appropriate parsing.

This commit is contained in:
Jason Edmeades 2012-10-13 22:11:03 +01:00 committed by Alexandre Julliard
parent 25cf0aa046
commit 4236c2007d
2 changed files with 26 additions and 29 deletions

View File

@ -48,37 +48,37 @@ var=33@space@
------ Testing invocation of batch files ----------
0@space@
1@space@
@todo_wine@1@space@
1@space@
@todo_wine@1@space@
1@space@
1@space@
0@space@
@todo_wine@1@space@
@todo_wine@2@space@
1@space@
2@space@
0@space@
3@space@
@todo_wine@3@space@
3@space@
@todo_wine@4@space@
------ Testing invocation with CMD /C -------------
0@space@
1@space@
@todo_wine@0@space@
0@space@
@todo_wine@1@space@
0@space@
@todo_wine@1@space@
@todo_wine@2@space@
1@space@
0@space@
@todo_wine@3@space@
1@space@
2@space@
0@space@
3@space@
@todo_wine@4@space@
---------- Testing CMD /C quoting -----------------
"hi"
@todo_wine@1@space@
1@space@
"\"\\"\\\"\\\\"@space@"\"\\"\\\"\\\\"
1@space@
0@space@
1@space@
0@space@
@todo_wine@0@space@
0@space@
0@space@@or_broken@3@space@
3@space@
2@space@
@ -100,7 +100,7 @@ THIS FAILS: cmd ignoreme/c say one
{@space@
}@space@
0@space@
@todo_wine@0@space@
0@space@
!@space@
@todo_wine@0@space@@or_broken@!@space@
@todo_wine@0@space@
@ -117,8 +117,8 @@ THIS FAILS: cmd ignoreme/c say one
@todo_wine@1:((1)),2:@space@
@todo_wine@1:(1)(2),2:@space@
@todo_wine@1:(1),2:(2)@space@
@todo_wine@1:1,2:2@space@
@todo_wine@1:1,2:2@space@
@todo_wine@1:1,2:2@space@
1:1,2:2@space@
1:1,2:2@space@
1:1,2:2@space@
1:"p@space@"1,2:p"@space@"2@space@
1:p"1@space@p",2:2@space@

View File

@ -1008,6 +1008,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
MAX_PATH, including null character */
WCHAR *lastSlash;
WCHAR pathext[MAXSTRING];
WCHAR *firstParam;
BOOL extensionsupplied = FALSE;
BOOL launched = FALSE;
BOOL status;
@ -1016,17 +1017,13 @@ void WCMD_run_program (WCHAR *command, BOOL called)
static const WCHAR envPath[] = {'P','A','T','H','\0'};
static const WCHAR delims[] = {'/','\\',':','\0'};
/* Quick way to get the filename
* (but handle leading / as part of program name, not qualifier)
*/
for (len = 0; command[len] == '/'; len++) param1[len] = '/';
WCMD_parse (command + len, quals, param1 + len, param2);
if (!(*param1) && !(*param2))
return;
/* Quick way to get the filename is to extract the first argument. */
WINE_TRACE("Running '%s' (%d)\n", wine_dbgstr_w(command), called);
firstParam = WCMD_parameter(command, 0, NULL, NULL, FALSE);
if (!firstParam) return;
/* Calculate the search path and stem to search for */
if (strpbrkW (param1, delims) == NULL) { /* No explicit path given, search path */
if (strpbrkW (firstParam, delims) == NULL) { /* No explicit path given, search path */
static const WCHAR curDir[] = {'.',';','\0'};
strcpyW(pathtosearch, curDir);
len = GetEnvironmentVariableW(envPath, &pathtosearch[2], (sizeof(pathtosearch)/sizeof(WCHAR))-2);
@ -1034,19 +1031,19 @@ void WCMD_run_program (WCHAR *command, BOOL called)
static const WCHAR curDir[] = {'.','\0'};
strcpyW (pathtosearch, curDir);
}
if (strchrW(param1, '.') != NULL) extensionsupplied = TRUE;
if (strlenW(param1) >= MAX_PATH)
if (strchrW(firstParam, '.') != NULL) extensionsupplied = TRUE;
if (strlenW(firstParam) >= MAX_PATH)
{
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_LINETOOLONG));
return;
}
strcpyW(stemofsearch, param1);
strcpyW(stemofsearch, firstParam);
} else {
/* Convert eg. ..\fred to include a directory by removing file part */
GetFullPathNameW(param1, sizeof(pathtosearch)/sizeof(WCHAR), pathtosearch, NULL);
GetFullPathNameW(firstParam, sizeof(pathtosearch)/sizeof(WCHAR), pathtosearch, NULL);
lastSlash = strrchrW(pathtosearch, '\\');
if (lastSlash && strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE;
strcpyW(stemofsearch, lastSlash+1);