Commit 0e369586 authored by Misha Koshelev's avatar Misha Koshelev Committed by Alexandre Julliard

setupapi: Simplify code as native setupapi does not handle quoted paths.

parent ec4936a6
...@@ -1001,9 +1001,9 @@ void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, I ...@@ -1001,9 +1001,9 @@ void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, I
#endif #endif
static const WCHAR nt_genericW[] = {'.','n','t',0}; static const WCHAR nt_genericW[] = {'.','n','t',0};
WCHAR *s, *d, *path, section[MAX_PATH + sizeof(nt_platformW)/sizeof(WCHAR)]; WCHAR *s, *path, section[MAX_PATH + sizeof(nt_platformW)/sizeof(WCHAR)];
void *callback_context; void *callback_context;
UINT mode, in_quotes, bcount; UINT mode;
HINF hinf; HINF hinf;
TRACE("hwnd %p, handle %p, cmdline %s\n", hwnd, handle, debugstr_w(cmdline)); TRACE("hwnd %p, handle %p, cmdline %s\n", hwnd, handle, debugstr_w(cmdline));
...@@ -1015,47 +1015,10 @@ void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, I ...@@ -1015,47 +1015,10 @@ void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, I
while (*s == ' ') s++; while (*s == ' ') s++;
mode = atoiW( s ); mode = atoiW( s );
/* quoted paths are not allowed on native, the rest of the command line is taken as the path */
if (!(s = strchrW( s, ' ' ))) return; if (!(s = strchrW( s, ' ' ))) return;
while (*s == ' ') s++; while (*s == ' ') s++;
path = s;
/* The inf path may be quoted. Code adapted from CommandLineToArgvW() */
bcount=0;
in_quotes=0;
path=d=s;
while (*s)
{
if (*s==0) {
/* end of this command line argument */
break;
} else if (*s=='\\') {
/* '\\' */
*d++=*s++;
bcount++;
} else if (*s=='"') {
/* '"' */
if ((bcount & 1)==0) {
/* Preceded by an even number of '\', this is half that
* number of '\', plus a quote which we erase.
*/
d-=bcount/2;
in_quotes=!in_quotes;
s++;
} else {
/* Preceded by an odd number of '\', this is half that
* number of '\' followed by a '"'
*/
d=d-bcount/2-1;
*d++='"';
s++;
}
bcount=0;
} else {
/* a regular character */
*d++=*s++;
bcount=0;
}
}
*d=0;
hinf = SetupOpenInfFileW( path, NULL, INF_STYLE_WIN4, NULL ); hinf = SetupOpenInfFileW( path, NULL, INF_STYLE_WIN4, NULL );
if (hinf == INVALID_HANDLE_VALUE) return; if (hinf == INVALID_HANDLE_VALUE) return;
......
...@@ -124,7 +124,7 @@ static void test_cmdline(void) ...@@ -124,7 +124,7 @@ static void test_cmdline(void)
ok_cmdline("DefaultInstall", 128, path, TRUE); ok_cmdline("DefaultInstall", 128, path, TRUE);
sprintf(path, "\"%s\\%s\"", CURR_DIR, infwithspaces); sprintf(path, "\"%s\\%s\"", CURR_DIR, infwithspaces);
todo_wine ok_cmdline("DefaultInstall", 128, path, FALSE); ok_cmdline("DefaultInstall", 128, path, FALSE);
ok(DeleteFile(infwithspaces), "Expected source inf to exist, last error was %d\n", GetLastError()); ok(DeleteFile(infwithspaces), "Expected source inf to exist, last error was %d\n", GetLastError());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment