From 1d4cf78a0f53d5c179923086c3730920e6342bc4 Mon Sep 17 00:00:00 2001 From: Ghaith Hachem Date: Tue, 21 Feb 2017 15:50:28 +0100 Subject: [PATCH] Bug 447643 Modified the CommandLauncher to consider Win32 Env variables Added a check on the parseEnvironment() method to store keys in upper case if the platform is windows Added a method to fetch a property directly from the fEnvironment or using the EnvironmentReader class instead of fetching the map and redirecting the call to that map. This would ensure normalization as the getEnvVar(key) is implemented to use the normalized map. Bug: 447643 Change-Id: Ic664d81781f80663ce18854209077a2f38ec7c3a Signed-off-by: Ghaith Hachem --- .../org/eclipse/cdt/core/CommandLauncher.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index 0fdd28032b8..e446fb85eca 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -106,6 +106,17 @@ public class CommandLauncher implements ICommandLauncher { } return fEnvironment; } + + /** + * Returns a property from the given environment. + * Asks the Environment reader directly for its key instead of retrieving this entire property map + */ + private String getEnvironmentProperty(String key) { + if (fEnvironment == null) { + return EnvironmentReader.getEnvVar(key); + } + return fEnvironment.getProperty(key); + } /* (non-Javadoc) * @see org.eclipse.cdt.core.ICommandLauncher#getCommandLine() @@ -138,6 +149,9 @@ public class CommandLauncher implements ICommandLauncher { if (pos < 0) pos = envStr.length(); String key = envStr.substring(0, pos); + if (Platform.getOS().equals(Platform.OS_WIN32)) { + key = key.toUpperCase(); + } String value = envStr.substring(pos + 1); fEnvironment.put(key, value); } @@ -166,7 +180,7 @@ public class CommandLauncher implements ICommandLauncher { @Override public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException { parseEnvironment(env); - String envPathValue = (String) getEnvironment().get(PATH_ENV); + String envPathValue = getEnvironmentProperty(PATH_ENV); Boolean isFound = null; String command = commandPath.toOSString();