1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Protect against NPE.

This commit is contained in:
Sergey Prigogin 2012-09-02 19:21:02 -07:00
parent 9e9c380798
commit 435b10dfdf

View file

@ -398,34 +398,42 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
return array == null ? CharArrayUtils.EMPTY_CHAR_ARRAY : array;
}
/**
* Returns include search path for a given current directory and a IScannerInfo.
* @param directory the current directory
* @param info scanner information, or {@code null} if not available
* @return the include search path
*/
public static IncludeSearchPath configureIncludeSearchPath(File directory, IScannerInfo info) {
boolean inhibitUseOfCurrentFileDirectory= false;
List<IncludeSearchPathElement> elements = new ArrayList<IncludeSearchPathElement>();
// Quote includes first
if (info instanceof IExtendedScannerInfo) {
final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info;
final String[] paths= einfo.getLocalIncludePath();
if (paths != null) {
for (String path : paths) {
if ("-".equals(path)) { //$NON-NLS-1$
inhibitUseOfCurrentFileDirectory= true;
} else {
elements.add(new IncludeSearchPathElement(makeAbsolute(directory, path), true));
}
if (info != null) {
// Quote includes first
if (info instanceof IExtendedScannerInfo) {
final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info;
final String[] paths= einfo.getLocalIncludePath();
if (paths != null) {
for (String path : paths) {
if ("-".equals(path)) { //$NON-NLS-1$
inhibitUseOfCurrentFileDirectory= true;
} else {
elements.add(new IncludeSearchPathElement(makeAbsolute(directory, path), true));
}
}
}
}
// Regular includes
String[] paths= info.getIncludePaths();
if (paths != null) {
for (String path : paths) {
if ("-".equals(path)) { //$NON-NLS-1$
inhibitUseOfCurrentFileDirectory= true;
} else {
elements.add(new IncludeSearchPathElement(makeAbsolute(directory, path), false));
}
}
}
}
// Regular includes
String[] paths= info.getIncludePaths();
if (paths != null) {
for (String path : paths) {
if ("-".equals(path)) { //$NON-NLS-1$
inhibitUseOfCurrentFileDirectory= true;
} else {
elements.add(new IncludeSearchPathElement(makeAbsolute(directory, path), false));
}
}
}
}
return new IncludeSearchPath(elements, inhibitUseOfCurrentFileDirectory);
}