Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2011-11-30 20:39:15 +0000
committerAndrew Gvozdev2011-11-30 20:39:15 +0000
commit3bd4f3d0fcb4407ef8eb7e8972126d9f272e31c4 (patch)
tree71609db3bc98c9455fdfd7819285ece5eb3bbb39 /build/org.eclipse.cdt.managedbuilder.gnu.ui/src
parent3099ae40a1d83721e3ac4b2b2d49985449443cc1 (diff)
downloadorg.eclipse.cdt-3bd4f3d0fcb4407ef8eb7e8972126d9f272e31c4.tar.gz
org.eclipse.cdt-3bd4f3d0fcb4407ef8eb7e8972126d9f272e31c4.tar.xz
org.eclipse.cdt-3bd4f3d0fcb4407ef8eb7e8972126d9f272e31c4.zip
bug 299376: Console/Problem view UTF-8 character encoding problem with
Cygwin 1.7
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.gnu.ui/src')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java57
1 files changed, 42 insertions, 15 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
index 90f9b69d47f..dafa734e209 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 Intel Corporation and others.
+ * Copyright (c) 2005, 2011 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,27 +22,50 @@ import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
*/
public class GnuCygwinConfigurationEnvironmentSupplier implements
IConfigurationEnvironmentVariableSupplier {
+
+ private static final String PATH = "PATH"; //$NON-NLS-1$
+ private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
+ private static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
+ private static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$
+
+ private static final String LANG = "LANG"; //$NON-NLS-1$
+ private static final String LC_ALL = "LC_ALL"; //$NON-NLS-1$
+ private static final String LC_MESSAGES = "LC_MESSAGES"; //$NON-NLS-1$
- static final String VARNAME = "PATH"; //$NON-NLS-1$
- static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
- static final String PROPERTY_DELIMITER = "path.separator"; //$NON-NLS-1$
- static final String PROPERTY_OSNAME = "os.name"; //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariable(java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
*/
@Override
public IBuildEnvironmentVariable getVariable(String variableName,
IConfiguration configuration, IEnvironmentVariableProvider provider) {
+
+ if (variableName == null)
+ return null;
if (!System.getProperty(PROPERTY_OSNAME).toLowerCase().startsWith("windows ")) //$NON-NLS-1$
return null;
+
+ if (variableName.equalsIgnoreCase(PATH)) {
+ String p = CygwinPathResolver.getBinPath();
+ if (p != null)
+ return new BuildEnvVar(PATH, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX));
+ } else if (variableName.equalsIgnoreCase(LANG)) {
+ // Workaround for not being able to select encoding for CDT console -> change codeset to Latin1
+ String langValue = System.getenv(LANG);
+ if (langValue == null || langValue.length() == 0)
+ langValue = System.getenv(LC_ALL);
+ if (langValue == null || langValue.length() == 0)
+ langValue = System.getenv(LC_MESSAGES);
+ if (langValue != null && langValue.length() > 0)
+ // langValue is [language[_territory][.codeset][@modifier]], i.e. "en_US.UTF-8@dict"
+ // we replace codeset with Latin1 as CDT console garbles UTF
+ // and ignore modifier which is not used by LANG
+ langValue = langValue.replaceFirst("([^.@]*)(\\..*)?(@.*)?", "$1.ISO-8859-1"); //$NON-NLS-1$ //$NON-NLS-2$
+ else
+ langValue = "C.ISO-8859-1"; //$NON-NLS-1$
- if (variableName == null) return null;
- if (!VARNAME.equalsIgnoreCase(variableName)) return null;
-
- String p = CygwinPathResolver.getBinPath();
- if (p != null)
- return new BuildEnvVar(VARNAME, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX));
+ return new BuildEnvVar(LANG, langValue);
+ }
return null;
}
@@ -53,9 +76,13 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements
public IBuildEnvironmentVariable[] getVariables(
IConfiguration configuration, IEnvironmentVariableProvider provider) {
- IBuildEnvironmentVariable[] tmp = new IBuildEnvironmentVariable[1];
- tmp[0] = getVariable(VARNAME, configuration, provider);
- if (tmp[0] != null) return tmp;
- return null;
+ IBuildEnvironmentVariable varLang = getVariable(LANG, configuration, provider);
+ IBuildEnvironmentVariable varPath = getVariable(PATH, configuration, provider);
+
+ if (varPath != null) {
+ return new IBuildEnvironmentVariable[] {varLang, varPath};
+ } else {
+ return new IBuildEnvironmentVariable[] {varLang};
+ }
}
}

Back to the top