wscript.exe: Improved argument parsing.

This commit is contained in:
Jacek Caban 2010-08-20 14:57:37 +02:00 committed by Alexandre Julliard
parent 3bae9b725c
commit bfdfae1c7f
2 changed files with 24 additions and 7 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = wscript.exe
APPMODE = -mwindows -municode
IMPORTS = uuid oleaut32 ole32 advapi32
IMPORTS = uuid shell32 oleaut32 ole32 advapi32
EXTRADEFS = -DWINE_NO_UNICODE_MACROS
RC_SRCS = \

View File

@ -320,21 +320,38 @@ static void run_script(const WCHAR *filename, IActiveScript *script, IActiveScri
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
{
const WCHAR *ext, *filename = NULL;
IActiveScriptParse *parser;
IActiveScript *script;
const WCHAR *ext;
WCHAR **argv;
CLSID clsid;
int argc, i;
WINE_TRACE("(%p %p %s %x)\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow);
if(!*cmdline)
argv = CommandLineToArgvW(cmdline, &argc);
if(!argv)
return 1;
ext = strchrW(cmdline, '.');
for(i=0; i<argc; i++) {
if(*argv[i] == '/' || *argv[i] == '-') {
WINE_FIXME("Unsupported argument %s\n", wine_dbgstr_w(argv[i]));
}else {
filename = argv[i];
break;
}
}
if(!filename) {
WINE_FIXME("No file name specified\n");
return 1;
}
ext = strchrW(filename, '.');
if(!ext)
ext = cmdline;
ext = filename;
if(!get_engine_clsid(ext, &clsid)) {
WINE_FIXME("Could not fine engine for %s\n", wine_dbgstr_w(ext));
WINE_FIXME("Could not find engine for %s\n", wine_dbgstr_w(ext));
return 1;
}
@ -347,7 +364,7 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cm
}
if(init_engine(script, parser)) {
run_script(cmdline, script, parser);
run_script(filename, script, parser);
IActiveScript_Close(script);
ITypeInfo_Release(host_ti);
}else {