Browse Source

Macrodef can only see lower case attribute names due to its

use of DynamicConfigurator.
Fix the doc and the code to at least make this consistent.
PR: 25687
Obtained from: Geoffrey Wiseman


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275830 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
6aba7c5074
5 changed files with 26 additions and 3 deletions
  1. +5
    -1
      docs/manual/CoreTasks/macrodef.html
  2. +11
    -0
      src/etc/testcases/taskdefs/macrodef.xml
  3. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  4. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
  5. +6
    -0
      src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java

+ 5
- 1
docs/manual/CoreTasks/macrodef.html View File

@@ -59,7 +59,11 @@
AT this location").
The escape sequence @@{x} is used to allow @{x} to be
placed in the text without substitution of x.
This corresponds to the $${x} escape sequence for properties
This corresponds to the $${x} escape sequence for properties.
</p>
<p>
The case of the attribute is ignored, so @{myAttribute} is treated the
same as @{MyAttribute}.
</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">


+ 11
- 0
src/etc/testcases/taskdefs/macrodef.xml View File

@@ -75,4 +75,15 @@
<property name="property" value="A property value"/>
<double prop="property"/>
</target>

<target name="ignorecase">
<macrodef name="ignore">
<attribute name="MyAttribute"/>
<sequential>
<echo>@{myattribute} is @{MYATTRIBUTE}</echo>
</sequential>
</macrodef>
<ignore myattribute="a"/>
<ignore Myattribute="b"/>
</target>
</project>

+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -57,6 +57,7 @@ package org.apache.tools.ant.taskdefs;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Locale;
import java.util.HashMap;

import org.apache.tools.ant.AntTypeDefinition;
@@ -293,7 +294,7 @@ public class MacroDef extends AntlibDefinition {
throw new BuildException(
"Illegal name [" + name + "] for attribute");
}
this.name = name;
this.name = name.toLowerCase(Locale.US);
}

/**


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/MacroInstance.java View File

@@ -57,6 +57,7 @@ package org.apache.tools.ant.taskdefs;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
@@ -200,7 +201,7 @@ public class MacroInstance extends Task implements DynamicConfigurator {
case STATE_EXPECT_NAME:
if (ch == '}') {
state = STATE_NORMAL;
String name = macroName.toString();
String name = macroName.toString().toLowerCase(Locale.US);
String value = (String) macroMapping.get(name);
if (value == null) {
ret.append("@{" + name + "}");


+ 6
- 0
src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java View File

@@ -103,5 +103,11 @@ public class MacroDefTest extends BuildFileTest {
"double",
"@{prop} is 'property', value of ${property} is 'A property value'");
}

public void testIgnoreCase() {
expectLog(
"ignorecase",
"a is ab is b");
}
}


Loading…
Cancel
Save