mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 07:35:24 +02:00
bug 299376: Console/Problem view UTF-8 character encoding problem with
Cygwin 1.7
This commit is contained in:
parent
726e835448
commit
5a5124dd04
1 changed files with 43 additions and 16 deletions
|
@ -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
|
||||
|
@ -23,25 +23,48 @@ import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
|
|||
public class GnuCygwinConfigurationEnvironmentSupplier implements
|
||||
IConfigurationEnvironmentVariableSupplier {
|
||||
|
||||
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$
|
||||
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$
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
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 == null) return null;
|
||||
if (!VARNAME.equalsIgnoreCase(variableName)) return null;
|
||||
|
||||
if (variableName.equalsIgnoreCase(PATH)) {
|
||||
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(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$
|
||||
|
||||
return new BuildEnvVar(LANG, langValue);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -51,9 +74,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};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue