diff --git a/WHATSNEW b/WHATSNEW index 7c65633a7..6ed7b150e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -32,6 +32,10 @@ Fixed bugs: directory of the given jarfile. Bugzilla Report 55049 + * 's fixlastline="true" didn't work when using certain filter + readers. + Bugzilla Report 54672 + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/Concat.java b/src/main/org/apache/tools/ant/taskdefs/Concat.java index 6ff9b058d..45716f306 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -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); diff --git a/src/tests/antunit/taskdefs/concat-test.xml b/src/tests/antunit/taskdefs/concat-test.xml index 33243ef02..4b285e389 100644 --- a/src/tests/antunit/taskdefs/concat-test.xml +++ b/src/tests/antunit/taskdefs/concat-test.xml @@ -76,6 +76,48 @@ + + + + 1 + 2 + + + + + + 1${line.separator}2${line.separator} + + + + + + + + + + + + + + 1${line.separator}2${line.separator} + + + + + + + + + + + + + + +