1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

Commit for Vlad Hirsl -- The default external scanner info collector was having problems with the output of GCC in non-utf8 locales. It now makes sure the locale is set to utf-8 when it runs GCC on *nix systems

This commit is contained in:
Sean Evoy 2004-07-29 12:56:33 +00:00
parent 490592ff55
commit d1e09a669d
2 changed files with 13 additions and 0 deletions

View file

@ -52,6 +52,7 @@ public class DefaultExternalScannerInfoProvider implements IExternalScannerInfoP
private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
private static final String LANG_ENV_VAR = "LANG";
private IPath fWorkingDirectory;
private IPath fCompileCommand;
@ -224,6 +225,14 @@ public class DefaultExternalScannerInfoProvider implements IExternalScannerInfoP
Properties props = launcher.getEnvironment();
props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
// On POSIX (Linux, UNIX) systems reset LANG variable to English with UTF-8 encoding
// since GNU compilers can handle only UTF-8 characters. English language is chosen
// beacuse GNU compilers inconsistently handle different locales when generating
// output of the 'gcc -v' command. Include paths with locale characters will be
// handled properly regardless of the language as long as the encoding is set to UTF-8.
if (props.containsKey(LANG_ENV_VAR)) {
props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
}
String[] env = null;
ArrayList envList = new ArrayList();
Enumeration names = props.propertyNames();

View file

@ -36,6 +36,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
@ -372,6 +373,9 @@ public class ScannerInfoCollector implements IScannerInfoCollector {
* @param monitor
*/
public synchronized void updateScannerConfiguration(IProject project, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
currentProject = project;
String projectName = project.getName();
// check TSO for the project