git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1554629 13f79535-47bb-0310-9956-ffa450edef68master
@@ -32,6 +32,10 @@ Fixed bugs: | |||||
directory of the given jarfile. | directory of the given jarfile. | ||||
Bugzilla Report 55049 | Bugzilla Report 55049 | ||||
* <concat>'s fixlastline="true" didn't work when using certain filter | |||||
readers. | |||||
Bugzilla Report 54672 | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -255,12 +255,12 @@ public class Concat extends Task implements ResourceCollection { | |||||
*/ | */ | ||||
public int read() throws IOException { | public int read() throws IOException { | ||||
if (needAddSeparator) { | if (needAddSeparator) { | ||||
int ret = eolString.charAt(lastPos++); | |||||
if (lastPos >= eolString.length()) { | if (lastPos >= eolString.length()) { | ||||
lastPos = 0; | lastPos = 0; | ||||
needAddSeparator = false; | needAddSeparator = false; | ||||
} else { | |||||
return eolString.charAt(lastPos++); | |||||
} | } | ||||
return ret; | |||||
} | } | ||||
while (getReader() != null) { | while (getReader() != null) { | ||||
int ch = getReader().read(); | int ch = getReader().read(); | ||||
@@ -268,7 +268,8 @@ public class Concat extends Task implements ResourceCollection { | |||||
nextReader(); | nextReader(); | ||||
if (isFixLastLine() && isMissingEndOfLine()) { | if (isFixLastLine() && isMissingEndOfLine()) { | ||||
needAddSeparator = true; | needAddSeparator = true; | ||||
lastPos = 0; | |||||
lastPos = 1; | |||||
return eolString.charAt(0); | |||||
} | } | ||||
} else { | } else { | ||||
addLastChar((char) ch); | addLastChar((char) ch); | ||||
@@ -76,6 +76,48 @@ | |||||
</au:assertTrue> | </au:assertTrue> | ||||
</target> | </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"> | <target name="testIgnoreEmptyFalseFileIsCreated"> | ||||
<mkdir dir="${input}" /> | <mkdir dir="${input}" /> | ||||
<mkdir dir="${output}" /> | <mkdir dir="${output}" /> | ||||