Browse Source

Previous fix for filterset broke the infinite filter testing

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275863 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
7b0865572e
3 changed files with 36 additions and 3 deletions
  1. +14
    -0
      src/etc/testcases/taskdefs/copy.xml
  2. +17
    -3
      src/main/org/apache/tools/ant/types/FilterSet.java
  3. +5
    -0
      src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java

+ 14
- 0
src/etc/testcases/taskdefs/copy.xml View File

@@ -28,6 +28,20 @@ PRODUCT_BUILD=6.5 (BLD_65036)
<concat><path path="copy.filter.out"/></concat>
</target>

<target name="infinitetest">
<delete quiet="yes" file="copy.filter.out"/>
<delete quiet="yes" file="copy.filter.inp"/>
<concat destfile="copy.filter.inp">
a=b=
</concat>
<copy file="copy.filter.inp" tofile="copy.filter.out">
<filterset begintoken="=" endtoken="=">
<filter token="b" value="=b="/>
</filterset>
</copy>
<concat><path path="copy.filter.out"/></concat>
</target>

<target name="test3">
<!-- create an empty file -->
<touch file="copytest3.tmp"/>


+ 17
- 3
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -351,14 +351,28 @@ public class FilterSet extends DataType implements Cloneable {

/**
* Does replacement on the given string with token matching.
* This uses the defined begintoken and endtoken values which default to @ for both.
* This uses the defined begintoken and endtoken values which default
* to @ for both.
* This resets the passedTokens and calls iReplaceTokens to
* do the actual replacements.
*
* @param line The line to process the tokens in.
* @return The string with the tokens replaced.
*/
public String replaceTokens(String line) {
passedTokens = null; // reset for new line
return iReplaceTokens(line);
}

/**
* Does replacement on the given string with token matching.
* This uses the defined begintoken and endtoken values which default
* to @ for both.
*
* @param line The line to process the tokens in.
* @return The string with the tokens replaced.
*/
private String iReplaceTokens(String line) {
String beginToken = getBeginToken();
String endToken = getEndToken();
int index = line.indexOf(beginToken);
@@ -439,7 +453,7 @@ public class FilterSet extends DataType implements Cloneable {
return parent;
}
passedTokens.addElement(parent);
String value = this.replaceTokens(line);
String value = iReplaceTokens(line);
if (value.indexOf(getBeginToken()) == -1 && !duplicateToken) {
duplicateToken = false;
passedTokens = null;


+ 5
- 0
src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -130,6 +130,11 @@ public class CopyTest extends BuildFileTest {
executeTarget("filtertest");
assertTrue(getOutput().indexOf("loop in tokens") == -1);
}

public void testInfiniteFilter() {
executeTarget("infinitetest");
assertTrue(getOutput().indexOf("loop in tokens") != -1);
}
public void testFilterSet() throws IOException {
executeTarget("testFilterSet");


Loading…
Cancel
Save