From 52eeb7286846dedb12e6cbabd936f6ed721957e9 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 5 Jan 2010 10:48:56 +0000 Subject: [PATCH] Bug 126956: Absolute include directives without drive letter --- .../core/parser/scanner/CPreprocessor.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index 6452331ba73..956b4eea8b5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -865,10 +865,20 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private T findInclusion(final String includeDirective, final boolean quoteInclude, final boolean includeNext, final String currentFile, final IIncludeFileTester tester) { T reader = null; - // filename is an absolute path or it is a Linux absolute path on a windows machine - if (new File(includeDirective).isAbsolute() || includeDirective.startsWith("/")) { //$NON-NLS-1$ + // Filename is an absolute path + if (new File(includeDirective).isAbsolute()) { return tester.checkFile(includeDirective, false, null); } + // Filename is a Linux absolute path on a windows machine + if (File.separatorChar == '\\' && includeDirective.length() > 0) { + final char firstChar = includeDirective.charAt(0); + if (firstChar == '\\' || firstChar == '/') { + if (currentFile != null && currentFile.length() > 1 && currentFile.charAt(1) == ':') { + return tester.checkFile(currentFile.substring(0, 2) + includeDirective, false, null); + } + return tester.checkFile(includeDirective, false, null); + } + } if (currentFile != null && quoteInclude && !includeNext) { // Check to see if we find a match in the current directory