Browse Source

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
master
Matthew Jason Benson 18 years ago
parent
commit
d618e1f811
3 changed files with 24 additions and 8 deletions
  1. +3
    -0
      WHATSNEW
  2. +9
    -7
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  3. +12
    -1
      src/tests/antunit/taskdefs/concat-test.xml

+ 3
- 0
WHATSNEW View File

@@ -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:
--------------



+ 9
- 7
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -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 &quot;ignorable whitespace&quot; as well.</p>
*/
private void sanitizeText() {
if (textBuffer != null) {
if (textBuffer.substring(0).trim().length() == 0) {
textBuffer = null;
}
if (textBuffer != null && "".equals(textBuffer.toString().trim())) {
textBuffer = null;
}
}



+ 12
- 1
src/tests/antunit/taskdefs/concat-test.xml View File

@@ -1,4 +1,6 @@
<project xmlns:au="antlib:org.apache.ant.antunit">
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />

<target name="tearDown">
<delete file="binaryAppendDest" />
<delete file="encodeStringDest" />
@@ -35,4 +37,13 @@
</au:assertTrue>
</target>

<target name="testDoNotFixNestedText" description="Bugzilla 42369">
<au:assertTrue>
<resourcesmatch>
<string>foo</string>
<concat fixlastline="true">foo</concat>
</resourcesmatch>
</au:assertTrue>
</target>

</project>

Loading…
Cancel
Save