peterreilly 2004/01/07 02:25:08
Modified: src/main/org/apache/tools/ant/types FilterSet.java
src/testcases/org/apache/tools/ant/taskdefs CopyTest.java
src/etc/testcases/taskdefs copy.xml
Log:
Previous fix for filterset broke the infinite filter testing
Revision Changes Path
1.25 +17 -3 ant/src/main/org/apache/tools/ant/types/FilterSet.java
Index: FilterSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/FilterSet.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- FilterSet.java 7 Jan 2004 10:10:36 -0000 1.24
+++ FilterSet.java 7 Jan 2004 10:25:07 -0000 1.25
@@ -351,14 +351,28 @@
/**
* 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 @@
return parent;
}
passedTokens.addElement(parent);
- String value = this.replaceTokens(line);
+ String value = iReplaceTokens(line);
if (value.indexOf(getBeginToken()) == -1 && !duplicateToken) {
duplicateToken = false;
passedTokens = null;
1.14 +5 -0
ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
Index: CopyTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- CopyTest.java 7 Jan 2004 10:10:36 -0000 1.13
+++ CopyTest.java 7 Jan 2004 10:25:07 -0000 1.14
@@ -130,6 +130,11 @@
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");
1.13 +14 -0 ant/src/etc/testcases/taskdefs/copy.xml
Index: copy.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/copy.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- copy.xml 7 Jan 2004 10:10:36 -0000 1.12
+++ copy.xml 7 Jan 2004 10:25:08 -0000 1.13
@@ -28,6 +28,20 @@
<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"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]