1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

From vlad - PR 60181 - [ScannerConfig] Gets confused on IncludePaths with spaces

This commit is contained in:
David Inglis 2004-05-07 13:02:09 +00:00
parent 02876832bb
commit ee00ba1b15
3 changed files with 49 additions and 26 deletions

View file

@ -300,11 +300,17 @@ public class ScannerInfoCollector implements IScannerInfoCollector {
IPath realPath = new Path(includePath); IPath realPath = new Path(includePath);
if (!realPath.toFile().exists()) { if (!realPath.toFile().exists()) {
String translatedPath = new CygpathTranslator(currentProject, includePath).run(); String translatedPath = new CygpathTranslator(currentProject, includePath).run();
if (!translatedPath.equals(includePath)) { if (translatedPath != null) {
// Check if the translated path exists if (!translatedPath.equals(includePath)) {
IPath transPath = new Path(translatedPath); // Check if the translated path exists
if (transPath.toFile().exists()) { IPath transPath = new Path(translatedPath);
translatedIncludePaths.add(translatedPath); if (transPath.toFile().exists()) {
translatedIncludePaths.add(translatedPath);
}
else {
// TODO VMIR for now add even if it does not exist
translatedIncludePaths.add(translatedPath);
}
} }
else { else {
// TODO VMIR for now add even if it does not exist // TODO VMIR for now add even if it does not exist
@ -312,8 +318,8 @@ public class ScannerInfoCollector implements IScannerInfoCollector {
} }
} }
else { else {
// TODO VMIR for now add even if it does not exist TraceUtil.outputError("CygpathTranslator unable to translate path: ",//$NON-NLS-1$
translatedIncludePaths.add(translatedPath); includePath);
} }
} }
else { else {

View file

@ -10,8 +10,6 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu; package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
@ -21,6 +19,8 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParse
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
@ -67,10 +67,21 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
} }
// Known patterns: // Known patterns:
// (a) gcc|g++ ... -Dxxx -Iyyy ... // (a) gcc|g++ ... -Dxxx -Iyyy ...
StringTokenizer scanner = new StringTokenizer(line); ArrayList allTokens = new ArrayList();
if (scanner.countTokens() <= 1) String[] tokens = line.split("\"");
for (int i = 0; i < tokens.length; ++i) {
if (i % 2 == 0) { // even tokens need further tokenization
String[] sTokens = tokens[i].split("\\s");
allTokens.addAll(Arrays.asList(sTokens));
}
else {
allTokens.add(tokens[i]);
}
}
if (allTokens.size() <= 1)
return false; return false;
String token = scanner.nextToken().toLowerCase(); Iterator I = allTokens.iterator();
String token = ((String) I.next()).toLowerCase();
if (token.endsWith("gcc") || token.endsWith("g++")) {//$NON-NLS-1$ //$NON-NLS-2$ if (token.endsWith("gcc") || token.endsWith("g++")) {//$NON-NLS-1$ //$NON-NLS-2$
// Recognized gcc or g++ compiler invocation // Recognized gcc or g++ compiler invocation
List includes = new ArrayList(); List includes = new ArrayList();
@ -80,45 +91,48 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
rc = true; rc = true;
String fileName = null; String fileName = null;
String cashedToken = null; String cashedToken = null;
while (scanner.hasMoreTokens()) { while (I.hasNext()) {
if (cashedToken == null) { if (cashedToken == null) {
token = scanner.nextToken(); token = (String) I.next();
} }
else { else {
token = cashedToken; token = cashedToken;
cashedToken = null; cashedToken = null;
} }
if (token.length() == 0) {
continue;
}
if (token.startsWith("-D")) {//$NON-NLS-1$ if (token.startsWith("-D")) {//$NON-NLS-1$
String symbol = token.substring(2); String symbol = token.substring(2);
if (symbol.length() == 0) { if (symbol.length() == 0) {
if (scanner.hasMoreTokens()) { if (I.hasNext()) {
symbol = scanner.nextToken(); symbol = (String) I.next();
if (symbol.startsWith("-")) { //$NON-NLS-1$
cashedToken = symbol;
continue;
}
} }
else { else {
continue; continue;
} }
} }
if (symbol.charAt(0) == '-') {
cashedToken = symbol;
continue;
}
if (!symbols.contains(symbol)) if (!symbols.contains(symbol))
symbols.add(symbol); symbols.add(symbol);
} }
else if (token.startsWith("-I")) {//$NON-NLS-1$ else if (token.startsWith("-I")) {//$NON-NLS-1$
String iPath = token.substring(2); String iPath = token.substring(2);
if (iPath.length() == 0) { if (iPath.length() == 0) {
if (scanner.hasMoreTokens()) { if (I.hasNext()) {
iPath = scanner.nextToken(); iPath = (String) I.next();
if (iPath.startsWith("-")) { //$NON-NLS-1$
cashedToken = iPath;
continue;
}
} }
else { else {
continue; continue;
} }
} }
if (iPath.charAt(0) == '-') {
cashedToken = iPath;
continue;
}
String nPath = fUtil.normalizePath(iPath); String nPath = fUtil.normalizePath(iPath);
if (!includes.contains(nPath)) if (!includes.contains(nPath))
includes.add(nPath); includes.add(nPath);

View file

@ -44,6 +44,9 @@ public class CygpathTranslator {
ISafeRunnable runnable = new ISafeRunnable() { ISafeRunnable runnable = new ISafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
transPath = platformRun(); transPath = platformRun();
if (transPath.startsWith("cygpath:")) { //$NON-NLS-1$
transPath = null;
}
} }
public void handleException(Throwable exception) { public void handleException(Throwable exception) {