From 4ae976759285d73d6994b282ee195fa50e860143 Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Thu, 26 Jun 2003 15:21:13 +0000 Subject: [PATCH] Make filtersets preserve line endings git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274720 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 ++ src/main/org/apache/tools/ant/util/FileUtils.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 370af45e3..4a4e520d6 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -44,6 +44,8 @@ Fixed bugs: * Filter readers were not handling line endings properly. Bugzilla Report 18476. +* Filtersets were also not handling line endings properly. + * Expand tasks did not behave as expected with PatternSets. * now works on OS/400. diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index 6def257d7..318ff99e8 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -80,6 +80,7 @@ import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.filters.util.ChainReaderHelper; +import org.apache.tools.ant.filters.TokenFilter; import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.types.FilterSetCollection; @@ -432,21 +433,19 @@ public class FileUtils { in = new BufferedReader(rdr); } + TokenFilter.LineTokenizer lineTokenizer = new TokenFilter.LineTokenizer(); + lineTokenizer.setIncludeDelims(true); String newline = null; - String line = in.readLine(); + String line = lineTokenizer.getToken(in); while (line != null) { if (line.length() == 0) { + // this should not happen, because the lines are returned with the end of line delimiter out.newLine(); } else { - if (filterSetsAvailable) { - newline = filters.replaceTokens(line); - } else { - newline = line; - } + newline = filters.replaceTokens(line); out.write(newline); - out.newLine(); } - line = in.readLine(); + line = lineTokenizer.getToken(in); } } finally { if (out != null) {