Browse Source

fixlastline didn't work when the no-arg read() method of MultiReader was used. PR 54672

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1554629 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
ecac58c5a2
3 changed files with 50 additions and 3 deletions
  1. +4
    -0
      WHATSNEW
  2. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  3. +42
    -0
      src/tests/antunit/taskdefs/concat-test.xml

+ 4
- 0
WHATSNEW View File

@@ -32,6 +32,10 @@ Fixed bugs:
directory of the given jarfile.
Bugzilla Report 55049

* <concat>'s fixlastline="true" didn't work when using certain filter
readers.
Bugzilla Report 54672

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



+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -255,12 +255,12 @@ public class Concat extends Task implements ResourceCollection {
*/
public int read() throws IOException {
if (needAddSeparator) {
int ret = eolString.charAt(lastPos++);
if (lastPos >= eolString.length()) {
lastPos = 0;
needAddSeparator = false;
} else {
return eolString.charAt(lastPos++);
}
return ret;
}
while (getReader() != null) {
int ch = getReader().read();
@@ -268,7 +268,8 @@ public class Concat extends Task implements ResourceCollection {
nextReader();
if (isFixLastLine() && isMissingEndOfLine()) {
needAddSeparator = true;
lastPos = 0;
lastPos = 1;
return eolString.charAt(0);
}
} else {
addLastChar((char) ch);


+ 42
- 0
src/tests/antunit/taskdefs/concat-test.xml View File

@@ -76,6 +76,48 @@
</au:assertTrue>
</target>

<target name="-fixlastline-setup">
<mkdir dir="${input}"/>
<mkdir dir="${output}"/>
<echo file="${input}/1">1</echo>
<echo file="${input}/2">2</echo>
</target>

<target name="testFixLastLineActuallyFixes" depends="-fixlastline-setup">
<au:assertTrue>
<resourcesmatch>
<string>1${line.separator}2${line.separator}</string>
<concat fixlastline="true">
<filelist dir="${input}">
<file name="1"/>
<file name="2"/>
</filelist>
</concat>
</resourcesmatch>
</au:assertTrue>
</target>

<target name="testFixLastLineActuallyFixesWithFilterChain"
depends="-fixlastline-setup"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=54672">
<au:assertTrue>
<resourcesmatch>
<string>1${line.separator}2${line.separator}</string>
<concat fixlastline="true">
<filelist dir="${input}">
<file name="1"/>
<file name="2"/>
</filelist>
<filterchain>
<tokenfilter>
<ignoreblank/>
</tokenfilter>
</filterchain>
</concat>
</resourcesmatch>
</au:assertTrue>
</target>

<target name="testIgnoreEmptyFalseFileIsCreated">
<mkdir dir="${input}" />
<mkdir dir="${output}" />


Loading…
Cancel
Save