From 996baf6379eafa89b5a76fab3aeca94c005ecaae Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 9 Oct 2002 18:35:01 +0000 Subject: [PATCH] Transmit the Windows PATH to child processes using the WINEPATH variable. --- files/directory.c | 20 ++++++++++++-------- memory/environ.c | 11 +++++++++-- scheduler/process.c | 13 ++++++++++--- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/files/directory.c b/files/directory.c index c9d2f19b52d..ed7156ae53a 100644 --- a/files/directory.c +++ b/files/directory.c @@ -160,17 +160,21 @@ int DIR_Init(void) DRIVE_Chdir( drive, DIR_Windows.short_name + 2 ); } - PROFILE_GetWineIniString(wineW, pathW, path_dirW, longpath, MAX_PATHNAME_LEN); - if (strchrW(longpath, '/')) + /* Set the environment variables */ + + /* set PATH only if not set already */ + if (!GetEnvironmentVariableW( path_capsW, longpath, MAX_PATHNAME_LEN )) { - MESSAGE("Fix your wine config to use DOS drive syntax in [wine] 'Path=' statement! (no '/' allowed)\n"); - PROFILE_UsageWineIni(); - ExitProcess(1); + PROFILE_GetWineIniString(wineW, pathW, path_dirW, longpath, MAX_PATHNAME_LEN); + if (strchrW(longpath, '/')) + { + MESSAGE("Fix your wine config to use DOS drive syntax in [wine] 'Path=' statement! (no '/' allowed)\n"); + PROFILE_UsageWineIni(); + ExitProcess(1); + } + SetEnvironmentVariableW( path_capsW, longpath ); } - /* Set the environment variables */ - - SetEnvironmentVariableW( path_capsW, longpath ); SetEnvironmentVariableW( temp_capsW, tmp_dir.short_name ); SetEnvironmentVariableW( tmp_capsW, tmp_dir.short_name ); SetEnvironmentVariableW( windirW, DIR_Windows.short_name ); diff --git a/memory/environ.c b/memory/environ.c index 99dc6577349..e5f6630f5f6 100644 --- a/memory/environ.c +++ b/memory/environ.c @@ -152,7 +152,11 @@ static BOOL build_environment(void) /* Compute the total size of the Unix environment */ size = sizeof(BYTE) + sizeof(WORD) + sizeof(ENV_program_name); - for (e = environ; *e; e++) size += strlen(*e) + 1; + for (e = environ; *e; e++) + { + if (!memcmp( *e, "PATH=", 5 )) continue; + size += strlen(*e) + 1; + } /* Now allocate the environment */ @@ -164,7 +168,10 @@ static BOOL build_environment(void) for (e = environ; *e; e++) { - strcpy( p, *e ); + /* skip Unix PATH and store WINEPATH as PATH */ + if (!memcmp( *e, "PATH=", 5 )) continue; + if (!memcmp( *e, "WINEPATH=", 9 )) strcpy( p, *e + 4 ); + else strcpy( p, *e ); p += strlen(p) + 1; } diff --git a/scheduler/process.c b/scheduler/process.c index 26959c4af7e..18a8202a4aa 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -820,9 +820,16 @@ static char **build_envp( const char *env, const char *extra_env ) /* now put the Windows environment strings */ for (p = env; *p; p += strlen(p) + 1) { - if (memcmp( p, "PATH=", 5 ) && - memcmp( p, "HOME=", 5 ) && - memcmp( p, "WINEPREFIX=", 11 )) *envptr++ = (char *)p; + if (!memcmp( p, "PATH=", 5 )) /* store PATH as WINEPATH */ + { + char *winepath = malloc( strlen(p) + 5 ); + strcpy( winepath, "WINE" ); + strcpy( winepath + 4, p ); + *envptr++ = winepath; + } + else if (memcmp( p, "HOME=", 5 ) && + memcmp( p, "WINEPATH=", 9 ) && + memcmp( p, "WINEPREFIX=", 11 )) *envptr++ = (char *)p; } *envptr = 0; } -- 2.11.4.GIT