Module: wine Branch: master Commit: 6f123e84244245f63524b817fa193a40bf3e83a8 URL: https://gitlab.winehq.org/wine/wine/-/commit/6f123e84244245f63524b817fa193a4...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Jan 16 20:41:52 2023 +0100
tools: Always fall back to argv[0] to find the tools directory.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54319
---
tools/widl/widl.c | 6 ++---- tools/winegcc/winegcc.c | 6 ++---- tools/wmc/wmc.c | 8 ++------ tools/wrc/wrc.c | 8 ++------ 4 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 79d895b52bf..8d07bf61dba 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -483,7 +483,7 @@ void write_id_data(const statement_list_t *stmts) static void init_argv0_dir( const char *argv0 ) { #ifndef _WIN32 - char *dir; + char *dir = NULL;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) dir = realpath( "/proc/self/exe", NULL ); @@ -494,10 +494,8 @@ static void init_argv0_dir( const char *argv0 ) if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); free( path ); -#else - dir = realpath( argv0, NULL ); #endif - if (!dir) return; + if (!dir && !(dir = realpath( argv0, NULL ))) return; includedir = strmake( "%s/%s", get_dirname( dir ), BIN_TO_INCLUDEDIR ); dlldir = strmake( "%s/%s", get_dirname( dir ), BIN_TO_DLLDIR ); #endif diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 2e656f7ea83..3891974c6c1 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -647,7 +647,7 @@ static char *get_lib_dir( struct options *opts ) static void init_argv0_dir( const char *argv0 ) { #ifndef _WIN32 - char *dir; + char *dir = NULL;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) dir = realpath( "/proc/self/exe", NULL ); @@ -658,10 +658,8 @@ static void init_argv0_dir( const char *argv0 ) if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); free( path ); -#else - dir = realpath( argv0, NULL ); #endif - if (!dir) return; + if (!dir && !(dir = realpath( argv0, NULL ))) return; bindir = get_dirname( dir ); includedir = strmake( "%s/%s", bindir, BIN_TO_INCLUDEDIR ); libdir = strmake( "%s/%s", bindir, BIN_TO_LIBDIR ); diff --git a/tools/wmc/wmc.c b/tools/wmc/wmc.c index 145acb5d718..76251637a4b 100644 --- a/tools/wmc/wmc.c +++ b/tools/wmc/wmc.c @@ -150,7 +150,7 @@ static void exit_on_signal( int sig ) static void init_argv0_dir( const char *argv0 ) { #ifndef _WIN32 - char *dir; + char *dir = NULL;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) dir = realpath( "/proc/self/exe", NULL ); @@ -160,13 +160,9 @@ static void init_argv0_dir( const char *argv0 ) char *path = xmalloc( path_size ); if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); - else - dir = NULL; free( path ); -#else - dir = realpath( argv0, NULL ); #endif - if (!dir) return; + if (!dir && !(dir = realpath( argv0, NULL ))) return; dir = get_dirname( dir ); if (strendswith( dir, "/tools/wmc" )) nlsdirs[0] = strmake( "%s/../../nls", dir ); else nlsdirs[0] = strmake( "%s/%s", dir, BIN_TO_NLSDIR ); diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index 9f231603ad4..fc217afec6c 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -295,7 +295,7 @@ static int load_file( const char *input_name, const char *output_name ) static void init_argv0_dir( const char *argv0 ) { #ifndef _WIN32 - char *dir; + char *dir = NULL;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) dir = realpath( "/proc/self/exe", NULL ); @@ -305,13 +305,9 @@ static void init_argv0_dir( const char *argv0 ) char *path = xmalloc( path_size ); if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); - else - dir = NULL; free( path ); -#else - dir = realpath( argv0, NULL ); #endif - if (!dir) return; + if (!dir && !(dir = realpath( argv0, NULL ))) return; dir = get_dirname( dir ); includedir = strmake( "%s/%s", dir, BIN_TO_INCLUDEDIR ); if (strendswith( dir, "/tools/wrc" )) nlsdirs[0] = strmake( "%s/../../nls", dir );