Browse Source

replacetokens failed if stream ends in begintoken. PR 47306.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@781357 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
76aa472311
3 changed files with 27 additions and 1 deletions
  1. +4
    -0
      WHATSNEW
  2. +5
    -1
      src/main/org/apache/tools/ant/filters/ReplaceTokens.java
  3. +18
    -0
      src/tests/antunit/filters/replacetokens-test.xml

+ 4
- 0
WHATSNEW View File

@@ -371,6 +371,10 @@ Fixed bugs:
errors. errors.
Bugzilla Report 46829. Bugzilla Report 46829.


* The <replacetokens> filter threw an exception if the stream to
filter ended with a begin token.
Bugzilla Report 47306.

Other changes: Other changes:
-------------- --------------
* A HostInfo task was added performing information on hosts, including info on * A HostInfo task was added performing information on hosts, including info on


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

@@ -153,7 +153,11 @@ public final class ReplaceTokens
queuedData queuedData
= key.toString() + queuedData.substring(queueIndex); = key.toString() + queuedData.substring(queueIndex);
} }
queueIndex = 0;
if (queuedData.length() > 0) {
queueIndex = 0;
} else {
queueIndex = -1;
}
return beginToken; return beginToken;
} else { } else {
key.setLength(key.length() - 1); key.setLength(key.length() - 1);


+ 18
- 0
src/tests/antunit/filters/replacetokens-test.xml View File

@@ -47,4 +47,22 @@ world=Ant
resource="${output}/text.txt" value="Hello, Ant!"/> resource="${output}/text.txt" value="Hello, Ant!"/>
</target> </target>


<target name="testFileEndsWithToken"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=47306"
depends="setUp">
<mkdir dir="${output}"/>
<echo file="${input}/test47306.txt">Hello@</echo>
<copy todir="${output}">
<fileset dir="${input}"/>
<filterchain>
<replacetokens>
<token key="foo" value="bar"/>
</replacetokens>
</filterchain>
</copy>
<au:assertFilesMatch
expected="${input}/test47306.txt"
actual="${output}/test47306.txt"/>
</target>

</project> </project>

Loading…
Cancel
Save