mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Fix for [Bug 185091] Include paths are not quoted when adding from "Paths and symbols" tab
This commit is contained in:
parent
7d445dd496
commit
6a2f91110e
1 changed files with 42 additions and 8 deletions
|
@ -296,21 +296,55 @@ public class BuildEntryStorage extends AbstractEntryStorage {
|
|||
}
|
||||
|
||||
private String entryValueToOptionStringValue(IOption option, ICLanguageSettingEntry entry){
|
||||
String result;
|
||||
boolean checkQuote = true;
|
||||
if(entry.getKind() == ICLanguageSettingEntry.MACRO && entry.getValue().length() > 0){
|
||||
return new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
||||
result = new StringBuffer(entry.getName()).append('=').append(entry.getValue()).toString();
|
||||
} else if(entry instanceof ICLanguageSettingPathEntry){
|
||||
IOptionPathConverter converter = fLangData.getTool().getOptionPathConverter();
|
||||
if(converter instanceof IReverseOptionPathConverter){
|
||||
return ((IReverseOptionPathConverter)converter).convertToOptionValue(entry, option, fLangData.getTool());
|
||||
}
|
||||
ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
|
||||
if(pathEntry.isValueWorkspacePath()){
|
||||
return ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
|
||||
result = ((IReverseOptionPathConverter)converter).convertToOptionValue(entry, option, fLangData.getTool());
|
||||
checkQuote = false;
|
||||
} else {
|
||||
ICLanguageSettingPathEntry pathEntry = (ICLanguageSettingPathEntry)entry;
|
||||
if(pathEntry.isValueWorkspacePath()){
|
||||
result = ManagedBuildManager.fullPathToLocation(pathEntry.getValue());
|
||||
} else {
|
||||
result = entry.getName();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = entry.getName();
|
||||
}
|
||||
return entry.getName();
|
||||
|
||||
if(checkQuote){
|
||||
result = doubleQuotePath(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String doubleQuotePath(String pathName) {
|
||||
/* Trim */
|
||||
pathName = pathName.trim();
|
||||
|
||||
/* Check if path is already double-quoted */
|
||||
boolean bStartsWithQuote = pathName.indexOf('"') == 0;
|
||||
boolean bEndsWithQuote = pathName.lastIndexOf('"') == pathName.length() - 1;
|
||||
|
||||
/* Check for spaces, backslashes or macros */
|
||||
int i = pathName.indexOf(' ') + pathName.indexOf('\\') //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ pathName.indexOf("${"); //$NON-NLS-1$
|
||||
|
||||
/* If indexof didn't fail all three times, double-quote path */
|
||||
if (i != -3) {
|
||||
if (!bStartsWithQuote)
|
||||
pathName = "\"" + pathName; //$NON-NLS-1$
|
||||
if (!bEndsWithQuote)
|
||||
pathName = pathName + "\""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return pathName;
|
||||
}
|
||||
|
||||
|
||||
public static String[] macroNameValueFromValue(String value){
|
||||
String nv[] = new String[2];
|
||||
|
|
Loading…
Add table
Reference in a new issue