mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
Bug 571472: Don't resolve multi-line strings
Change-Id: Id6a8b208cb6bc965a2c8d781ba41bca3b3094685
This commit is contained in:
parent
f7c88ecd73
commit
cdd00392c1
2 changed files with 19 additions and 0 deletions
|
@ -50,6 +50,15 @@ public class CdtVariableResolverTest extends TestCase {
|
|||
if (macroName.equals("LOOP")) {
|
||||
return "${loop}";
|
||||
}
|
||||
if (macroName.equals("VAR1")) {
|
||||
return "var1";
|
||||
}
|
||||
if (macroName.equals("VAR2")) {
|
||||
return "var\n2";
|
||||
}
|
||||
if (macroName.equals("VAR3")) {
|
||||
return "var3";
|
||||
}
|
||||
if (macroName.equals(acceptedChars)) {
|
||||
return "OK";
|
||||
}
|
||||
|
@ -110,6 +119,8 @@ public class CdtVariableResolverTest extends TestCase {
|
|||
assertEquals("#workspace_loc:#Macro1#/#Macro2##", resolveToString("${workspace_loc:${Macro1}/${Macro2}}"));
|
||||
assertEquals("#workspace_loc:#project_loc:/#Macro###",
|
||||
resolveToString("${workspace_loc:${project_loc:/${Macro}}}"));
|
||||
assertEquals("${ignored}\n${multiline}", resolveToString("${ignored}\n${multiline}"));
|
||||
assertEquals("var1 var\n2 var3", resolveToString("${VAR1} ${VAR2} ${VAR3}"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ public class CdtVariableResolver {
|
|||
* ${workspace_loc:/${ProjName}/} but resolved just once. No recursive
|
||||
* macro names are allowed.
|
||||
* It is not possible to prevent macros from expanding.
|
||||
* For historical reasons (See Bug 571472), macros that are multi-line according to
|
||||
* {@link Pattern}'s Line Terminators are not expanded.
|
||||
*
|
||||
* @param string - macro expression.
|
||||
* @param substitutor - macro resolution provider to retrieve macro values.
|
||||
|
@ -106,6 +108,12 @@ public class CdtVariableResolver {
|
|||
if (string == null) {
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
// Bug 571472 to match historical behaviour, don't substitute multi-line strings
|
||||
for (char ch : string.toCharArray()) {
|
||||
if (ch == '\n' || ch == '\r' || (ch | 1) == '\u2029' || ch == '\u0085') {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
final Pattern pattern = Pattern.compile("(\\$\\{([^${}]*)\\})"); //$NON-NLS-1$
|
||||
final String VARIABLE_PREFIX_MASKED = "$\1"; //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue