diff --git a/WHATSNEW b/WHATSNEW index e4d6fec74..c383573f7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -70,6 +70,9 @@ Fixed bugs: * handle null result of system getProperty(). Bugzilla 42334. +* Regression: concat fixlastline="true" should not have applied to + nested text, but did in Ant 1.7.0. Bugzilla 42369. + 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 5b3c27535..6752af52a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -265,7 +265,7 @@ public class Concat extends Task implements ResourceCollection { int ch = getReader().read(); if (ch == -1) { nextReader(); - if (fixLastLine && isMissingEndOfLine()) { + if (isFixLastLine() && isMissingEndOfLine()) { needAddSeparator = true; lastPos = 0; } @@ -307,12 +307,12 @@ public class Concat extends Task implements ResourceCollection { int nRead = getReader().read(cbuf, off, len); if (nRead == -1 || nRead == 0) { nextReader(); - if (fixLastLine && isMissingEndOfLine()) { + if (isFixLastLine() && isMissingEndOfLine()) { needAddSeparator = true; lastPos = 0; } } else { - if (fixLastLine) { + if (isFixLastLine()) { for (int i = nRead; i > (nRead - lastChars.length); --i) { @@ -369,6 +369,10 @@ public class Concat extends Task implements ResourceCollection { } return false; } + + private boolean isFixLastLine() { + return fixLastLine && textBuffer == null; + } } private class ConcatResource extends Resource { @@ -887,10 +891,8 @@ public class Concat extends Task implements ResourceCollection { * for "ignorable whitespace" as well.
*/ private void sanitizeText() { - if (textBuffer != null) { - if (textBuffer.substring(0).trim().length() == 0) { - textBuffer = null; - } + if (textBuffer != null && "".equals(textBuffer.toString().trim())) { + textBuffer = null; } } diff --git a/src/tests/antunit/taskdefs/concat-test.xml b/src/tests/antunit/taskdefs/concat-test.xml index febe4a214..f4b13a2cb 100644 --- a/src/tests/antunit/taskdefs/concat-test.xml +++ b/src/tests/antunit/taskdefs/concat-test.xml @@ -1,4 +1,6 @@ -