Browse Source

TokenFilter.ReplaceString only replaced the first occurrence.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276118 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 21 years ago
parent
commit
f6c034b007
4 changed files with 31 additions and 1 deletions
  1. +2
    -0
      WHATSNEW
  2. +20
    -0
      src/etc/testcases/filters/tokenfilter.xml
  3. +1
    -1
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  4. +8
    -0
      src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java

+ 2
- 0
WHATSNEW View File

@@ -21,6 +21,8 @@ Fixed bugs:

* macrodef @@ escaping was broken. Bugzilla Report 27069.

* replacestring tokenfilter only replaced the first occurrence.

Other changes:
--------------



+ 20
- 0
src/etc/testcases/filters/tokenfilter.xml View File

@@ -67,6 +67,15 @@
</concat>
</target>

<target name="filterreplacestrings">
<concat>
foo foo foo
<filterchain>
<replacestring from="foo" to="bar"/>
</filterchain>
</concat>
</target>

<target name="stringtokenizer">
<concat destfile="result/input">
This is a number
@@ -134,6 +143,17 @@
</concat>
</target>

<target name="replacestrings">
<concat>
foo foo foo
<filterchain>
<tokenfilter>
<replacestring from="foo" to="bar"/>
</tokenfilter>
</filterchain>
</concat>
</target>

<target name="containsstring">
<concat destfile="result/input">
this is a line contains foo


+ 1
- 1
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -527,7 +527,7 @@ public class TokenFilter extends BaseFilterReader

// search again
start = found + from.length();
found = line.indexOf(line, start);
found = line.indexOf(from, start);
}

// write the remaining characters


+ 8
- 0
src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java View File

@@ -82,6 +82,10 @@ public class TokenFilterTest extends BuildFileTest {
"this is the moon");
}

public void testReplaceStrings() throws IOException {
expectLogContaining("replacestrings", "bar bar bar");
}

public void testContainsString() throws IOException {
String contents = getFileString(
"containsstring", "result/containsstring");
@@ -139,6 +143,10 @@ public class TokenFilterTest extends BuildFileTest {
assertStringContains(contents, "This is the moon");
}

public void testFilterReplaceStrings() throws IOException {
expectLogContaining("filterreplacestrings", "bar bar bar");
}

public void testContainsRegex() throws IOException {
if (! hasRegex("testContainsRegex"))
return;


Loading…
Cancel
Save