From ecac58c5a28bca764b01de8d96c147d59917463e Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 1 Jan 2014 15:04:29 +0000 Subject: [PATCH] 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 --- WHATSNEW | 4 ++ .../org/apache/tools/ant/taskdefs/Concat.java | 7 ++-- src/tests/antunit/taskdefs/concat-test.xml | 42 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) 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} + + + + + + + + + + + + + + +