mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +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;
|
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) {
|
public static IncludeSearchPath configureIncludeSearchPath(File directory, IScannerInfo info) {
|
||||||
boolean inhibitUseOfCurrentFileDirectory= false;
|
boolean inhibitUseOfCurrentFileDirectory= false;
|
||||||
List<IncludeSearchPathElement> elements = new ArrayList<IncludeSearchPathElement>();
|
List<IncludeSearchPathElement> elements = new ArrayList<IncludeSearchPathElement>();
|
||||||
|
|
||||||
// Quote includes first
|
if (info != null) {
|
||||||
if (info instanceof IExtendedScannerInfo) {
|
// Quote includes first
|
||||||
final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info;
|
if (info instanceof IExtendedScannerInfo) {
|
||||||
final String[] paths= einfo.getLocalIncludePath();
|
final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info;
|
||||||
if (paths != null) {
|
final String[] paths= einfo.getLocalIncludePath();
|
||||||
for (String path : paths) {
|
if (paths != null) {
|
||||||
if ("-".equals(path)) { //$NON-NLS-1$
|
for (String path : paths) {
|
||||||
inhibitUseOfCurrentFileDirectory= true;
|
if ("-".equals(path)) { //$NON-NLS-1$
|
||||||
} else {
|
inhibitUseOfCurrentFileDirectory= true;
|
||||||
elements.add(new IncludeSearchPathElement(makeAbsolute(directory, path), 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);
|
return new IncludeSearchPath(elements, inhibitUseOfCurrentFileDirectory);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue