From f5d3adaf59b06a9693c3f90b5a2ca2a784ac94e3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 3 Apr 2006 12:07:20 +0200 Subject: [PATCH] ntdll: Process --help and --version args earlier on during startup. --- dlls/kernel/process.c | 23 ----------------------- dlls/ntdll/loader.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c index 7b656ac997b..7b9b328427d 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -592,22 +592,6 @@ static BOOL build_command_line( WCHAR **argv ) } -static void version(void) -{ - MESSAGE( "%s\n", PACKAGE_STRING ); - ExitProcess(0); -} - -static void usage(void) -{ - MESSAGE( "%s\n", PACKAGE_STRING ); - MESSAGE( "Usage: wine PROGRAM [ARGUMENTS...] Run the specified program\n" ); - MESSAGE( " wine --help Display this help and exit\n"); - MESSAGE( " wine --version Output version information and exit\n"); - ExitProcess(0); -} - - /*********************************************************************** * init_current_directory * @@ -881,13 +865,6 @@ void __wine_kernel_init(void) { WCHAR exe_nameW[MAX_PATH]; - if (!__wine_main_argv[0]) usage(); - if (__wine_main_argc == 1) - { - if (strcmp(__wine_main_argv[0], "--help") == 0) usage(); - if (strcmp(__wine_main_argv[0], "--version") == 0) version(); - } - MultiByteToWideChar( CP_UNIXCP, 0, __wine_main_argv[0], -1, exe_nameW, MAX_PATH ); if (!SearchPathW( NULL, exe_nameW, exeW, MAX_PATH, main_exe_name, NULL ) && !get_builtin_path( exe_nameW, exeW, main_exe_name, MAX_PATH )) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 88878c43a4a..5f21e4304d7 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2290,9 +2290,40 @@ void __wine_init_windows_dir( const WCHAR *windir, const WCHAR *sysdir ) /*********************************************************************** + * check_command_line + * + * Check if command line is one that needs to be handled specially. + */ +static void check_command_line( int argc, char *argv[] ) +{ + static const char version[] = PACKAGE_STRING "\n"; + static const char usage[] = + "Usage: wine PROGRAM [ARGUMENTS...] Run the specified program\n" + " wine --help Display this help and exit\n" + " wine --version Output version information and exit\n"; + + if (argc <= 1) + { + write( 2, usage, sizeof(usage) - 1 ); + exit(1); + } + if (!strcmp( argv[1], "--help" )) + { + write( 1, usage, sizeof(usage) - 1 ); + exit(0); + } + if (!strcmp( argv[1], "--version" )) + { + write( 1, version, sizeof(version) - 1 ); + exit(0); + } +} + + +/*********************************************************************** * __wine_process_init */ -void __wine_process_init( int argc, char *argv[] ) +void __wine_process_init(void) { static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0}; @@ -2302,6 +2333,7 @@ void __wine_process_init( int argc, char *argv[] ) void (* DECLSPEC_NORETURN init_func)(void); extern mode_t FILE_umask; + check_command_line( __wine_main_argc, __wine_main_argv ); main_exe_file = thread_init(); /* retrieve current umask */ -- 2.11.4.GIT