From d618e1f811b3b248d492609633657d787f9c03c8 Mon Sep 17 00:00:00 2001
From: Matthew Jason Benson
Date: Wed, 9 May 2007 17:12:26 +0000
Subject: [PATCH] concat fixlastline/nested text regression; PR 42369
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@536592 13f79535-47bb-0310-9956-ffa450edef68
---
WHATSNEW | 3 +++
.../org/apache/tools/ant/taskdefs/Concat.java | 16 +++++++++-------
src/tests/antunit/taskdefs/concat-test.xml | 13 ++++++++++++-
3 files changed, 24 insertions(+), 8 deletions(-)
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 @@
-
+
+
+
@@ -35,4 +37,13 @@
+
+
+
+ foo
+ foo
+
+
+
+