diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c index 54607a1cf29..1b146b837fa 100644 --- a/dlls/msvcrt/data.c +++ b/dlls/msvcrt/data.c @@ -142,8 +142,13 @@ void MSVCRT_init_args(void) int xargc,end,last_arg,afterlastspace; DWORD version; - MSVCRT__acmdln = cmdline = MSVCRT__strdup( GetCommandLineA() ); - MSVCRT__wcmdln = wcmdline = wstrdupa(cmdline); + MSVCRT__acmdln = MSVCRT__strdup( GetCommandLineA() ); + MSVCRT__wcmdln = wcmdline = wstrdupa(MSVCRT__acmdln); + + /* Make a copy of MSVCRT__acmdln to be able modify it. + We will free it at the end of processing. */ + cmdline = MSVCRT__strdup(MSVCRT__acmdln); + TRACE("got '%s', wide = '%s'\n", cmdline, debugstr_w(wcmdline)); version = GetVersion(); @@ -207,6 +212,9 @@ void MSVCRT_init_args(void) MSVCRT___argv = xargv; MSVCRT___wargv = wxargv; + /* Free a no more needed copy of the command line */ + MSVCRT_free( cmdline ); + TRACE("found %d arguments\n",MSVCRT___argc); MSVCRT__environ = GetEnvironmentStringsA(); MSVCRT___initenv = &MSVCRT__environ; @@ -224,25 +232,25 @@ void MSVCRT_free_args(void) /********************************************************************* * __getmainargs (MSVCRT.@) */ -char** __cdecl MSVCRT___getmainargs(DWORD *argc,char ***argv,char **environ,DWORD flag) +void __cdecl MSVCRT___getmainargs(int *argc, char ***argv, char **environ, + int expand_wildcards, void *_startupinfo) { - TRACE("(%p,%p,%p,%ld).\n",argc,argv,environ,flag); + TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, environ, expand_wildcards, _startupinfo); *argc = MSVCRT___argc; *argv = MSVCRT___argv; *environ = MSVCRT__environ; - return environ; } /********************************************************************* * __wgetmainargs (MSVCRT.@) */ -WCHAR** __cdecl MSVCRT___wgetmainargs(DWORD *argc,WCHAR ***wargv,WCHAR **wenviron,DWORD flag) +void __cdecl MSVCRT___wgetmainargs(int *argc, WCHAR ***wargv, WCHAR **wenviron, + int expand_wildcards, void *_startupinfo) { - TRACE("(%p,%p,%p,%ld).\n",argc,wargv,wenviron,flag); + TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenviron, expand_wildcards, _startupinfo); *argc = MSVCRT___argc; *wargv = MSVCRT___wargv; *wenviron = MSVCRT__wenviron; - return wenviron; } /********************************************************************* diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index a81d1ab35aa..d433c91235f 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -96,7 +96,7 @@ debug_channels (msvcrt) @ cdecl __dllonexit(ptr ptr ptr) MSVCRT___dllonexit @ cdecl __doserrno() MSVCRT___doserrno @ stub __fpecode #() -@ cdecl __getmainargs(ptr ptr ptr long) MSVCRT___getmainargs +@ cdecl __getmainargs(ptr ptr ptr long ptr) MSVCRT___getmainargs @ extern __initenv MSVCRT___initenv @ cdecl __isascii(long) MSVCRT___isascii @ cdecl __iscsym(long) MSVCRT___iscsym @@ -147,7 +147,7 @@ debug_channels (msvcrt) @ cdecl __unDNameEx() MSVCRT___unDNameEx #FIXME @ extern __unguarded_readlc_active MSVCRT___unguarded_readlc_active @ extern __wargv MSVCRT___wargv -@ cdecl __wgetmainargs(ptr ptr ptr long) MSVCRT___wgetmainargs +@ cdecl __wgetmainargs(ptr ptr ptr long ptr) MSVCRT___wgetmainargs @ extern __winitenv MSVCRT___winitenv @ cdecl _abnormal_termination() MSVCRT__abnormal_termination @ cdecl _access(str long) MSVCRT__access