tools: Always fall back to argv[0] to find the tools directory.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54319
This commit is contained in:
Alexandre Julliard 2023-01-16 20:41:52 +01:00
parent 5ca22f551d
commit 6f123e8424
4 changed files with 8 additions and 20 deletions

View file

@ -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

View file

@ -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 );

View file

@ -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 );

View file

@ -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 );