git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276118 13f79535-47bb-0310-9956-ffa450edef68master
@@ -21,6 +21,8 @@ Fixed bugs: | |||||
* macrodef @@ escaping was broken. Bugzilla Report 27069. | * macrodef @@ escaping was broken. Bugzilla Report 27069. | ||||
* replacestring tokenfilter only replaced the first occurrence. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -67,6 +67,15 @@ | |||||
</concat> | </concat> | ||||
</target> | </target> | ||||
<target name="filterreplacestrings"> | |||||
<concat> | |||||
foo foo foo | |||||
<filterchain> | |||||
<replacestring from="foo" to="bar"/> | |||||
</filterchain> | |||||
</concat> | |||||
</target> | |||||
<target name="stringtokenizer"> | <target name="stringtokenizer"> | ||||
<concat destfile="result/input"> | <concat destfile="result/input"> | ||||
This is a number | This is a number | ||||
@@ -134,6 +143,17 @@ | |||||
</concat> | </concat> | ||||
</target> | </target> | ||||
<target name="replacestrings"> | |||||
<concat> | |||||
foo foo foo | |||||
<filterchain> | |||||
<tokenfilter> | |||||
<replacestring from="foo" to="bar"/> | |||||
</tokenfilter> | |||||
</filterchain> | |||||
</concat> | |||||
</target> | |||||
<target name="containsstring"> | <target name="containsstring"> | ||||
<concat destfile="result/input"> | <concat destfile="result/input"> | ||||
this is a line contains foo | this is a line contains foo | ||||
@@ -527,7 +527,7 @@ public class TokenFilter extends BaseFilterReader | |||||
// search again | // search again | ||||
start = found + from.length(); | start = found + from.length(); | ||||
found = line.indexOf(line, start); | |||||
found = line.indexOf(from, start); | |||||
} | } | ||||
// write the remaining characters | // write the remaining characters | ||||
@@ -82,6 +82,10 @@ public class TokenFilterTest extends BuildFileTest { | |||||
"this is the moon"); | "this is the moon"); | ||||
} | } | ||||
public void testReplaceStrings() throws IOException { | |||||
expectLogContaining("replacestrings", "bar bar bar"); | |||||
} | |||||
public void testContainsString() throws IOException { | public void testContainsString() throws IOException { | ||||
String contents = getFileString( | String contents = getFileString( | ||||
"containsstring", "result/containsstring"); | "containsstring", "result/containsstring"); | ||||
@@ -139,6 +143,10 @@ public class TokenFilterTest extends BuildFileTest { | |||||
assertStringContains(contents, "This is the moon"); | assertStringContains(contents, "This is the moon"); | ||||
} | } | ||||
public void testFilterReplaceStrings() throws IOException { | |||||
expectLogContaining("filterreplacestrings", "bar bar bar"); | |||||
} | |||||
public void testContainsRegex() throws IOException { | public void testContainsRegex() throws IOException { | ||||
if (! hasRegex("testContainsRegex")) | if (! hasRegex("testContainsRegex")) | ||||
return; | return; | ||||