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:
parent
9e9c380798
commit
435b10dfdf
1 changed files with 31 additions and 23 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue