You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2006/06/27 22:47:32 UTC
svn commit: r417584 - in /ant/core/trunk: ./ docs/manual/CoreTasks/
src/etc/testcases/taskdefs/fixcrlf/
src/etc/testcases/taskdefs/fixcrlf/expected/
src/main/org/apache/tools/ant/taskdefs/
src/testcases/org/apache/tools/ant/taskdefs/
Author: mbenson
Date: Tue Jun 27 13:47:31 2006
New Revision: 417584
URL: http://svn.apache.org/viewvc?rev=417584&view=rev
Log:
<fixcrlf> now supports an outputencoding attribute. Bugzilla report 39697.
Submitted by Stephen Goetze
Added:
ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/expected/input.lf.ascii
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/fixcrlf.html
ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/build.xml
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java
Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Jun 27 13:47:31 2006
@@ -442,6 +442,8 @@
* <scriptdef>-created scripts have support for nested text. All text
passed to a scripted task can be accessed via self.text.
+* <fixcrlf> now supports an outputencoding attribute. Bugzilla report 39697.
+
Changes from Ant 1.6.4 to Ant 1.6.5
===================================
Modified: ant/core/trunk/docs/manual/CoreTasks/fixcrlf.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/fixcrlf.html?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/fixcrlf.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/fixcrlf.html Tue Jun 27 13:47:31 2006
@@ -122,6 +122,13 @@
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
+ <td valign="top">outputencoding</td>
+ <td valign="top">The encoding to use when writing the files.
+ <b>Since Ant 1.7</b></td>
+ <td align="center">No; defaults to the value of the encoding attribute.</td>
+ <td bgcolor="#CCCCCC"> </td>
+ </tr>
+ <tr>
<td valign="top">preservelastmodified</td>
<td valign="top">Whether to preserve the last modified
date of source files. <b>Since Ant 1.6.3</b></td>
@@ -143,10 +150,11 @@
<li>unix: convert all EOLs to a single LF</li>
<li>dos: convert all EOLs to the pair CRLF</li>
</ul>
- Default is based on the platform on which you are running
- this task. For Unix platforms, the default is "lf".
- For DOS based systems (including Windows), the default is
- "crlf". For Mac OS, the default is "cr".
+ Default is based on the platform on which you are running this task.
+ For Unix platforms (including Mac OS X), the default is "lf".
+ For DOS-based systems (including Windows), the default is
+ "crlf".
+ For Mac environments other than OS X, the default is "cr".
<p>
This is the preferred method for specifying EOL. The
"<i><b>cr</b></i>" attribute (see below) is
@@ -298,7 +306,7 @@
DOS systems, and are removed if run on Unix systems.
You never know what editor a user will use to browse READMEs.</p>
<hr>
-<p align="center">Copyright © 2000-2005 The Apache Software Foundation. All rights
+<p align="center">Copyright © 2000-2006 The Apache Software Foundation. All rights
Reserved.</p>
</body>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/build.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/build.xml?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/build.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/build.xml Tue Jun 27 13:47:31 2006
@@ -117,6 +117,15 @@
file2="expected/input.lf.utf16" />
</target>
+ <target name="testOutputEncoding" depends="init">
+ <fixcrlf srcdir="input" destdir="result"
+ includes="input.crlf.utf16"
+ javafiles="false" eol="lf" encoding="UnicodeBig"
+ outputencoding="ascii" />
+ <assertequal file1="result/input.crlf.utf16"
+ file2="expected/input.lf.ascii" />
+ </target>
+
<target name="testLongLines" depends="init">
<fixcrlf srcdir="input" destdir="result"
includes="longlines.crlf"
Added: ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/expected/input.lf.ascii
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/expected/input.lf.ascii?rev=417584&view=auto
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/expected/input.lf.ascii (added)
+++ ant/core/trunk/src/etc/testcases/taskdefs/fixcrlf/expected/input.lf.ascii Tue Jun 27 13:47:31 2006
@@ -0,0 +1,2 @@
+Line1
+Line2
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java Tue Jun 27 13:47:31 2006
@@ -52,6 +52,7 @@
* <li>tab
* <li>eof
* <li>encoding
+ * <li>targetencoding
* </ul>
* Of these arguments, only <b>sourcedir</b> is required.
* <p>
@@ -99,6 +100,11 @@
private String encoding = null;
/**
+ * Encoding to use for output files
+ */
+ private String outputEncoding = null;
+
+ /**
* Chain this task as a reader.
* @param rdr Reader to chain.
* @return a Reader.
@@ -238,6 +244,15 @@
}
/**
+ * Specifies the encoding that the files are
+ * to be written in--same as input encoding by default.
+ * @param outputEncoding String outputEncoding name.
+ */
+ public void setOutputEncoding(String outputEncoding) {
+ this.outputEncoding = outputEncoding;
+ }
+
+ /**
* Specify whether a missing EOL will be added
* to the final line of a file.
* @param fixlast whether to fix the last line.
@@ -288,12 +303,15 @@
}
}
// log options used
+ String enc = encoding == null ? "default" : encoding;
log("options:"
+ " eol=" + filter.getEol().getValue()
+ " tab=" + filter.getTab().getValue()
+ " eof=" + filter.getEof().getValue()
+ " tablength=" + filter.getTablength()
- + " encoding=" + (encoding == null ? "default" : encoding),
+ + " encoding=" + enc
+ + " outputencoding="
+ + (outputEncoding == null ? enc : outputEncoding),
Project.MSG_VERBOSE);
DirectoryScanner ds = super.getDirectoryScanner(srcDir);
@@ -318,8 +336,9 @@
File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null);
tmpFile.deleteOnExit();
try {
- FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false,
- false, encoding, getProject());
+ FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, false,
+ encoding, outputEncoding == null ? encoding : outputEncoding,
+ getProject());
File destFile = new File(destD, file);
Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java?rev=417584&r1=417583&r2=417584&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java Tue Jun 27 13:47:31 2006
@@ -91,6 +91,10 @@
executeTarget("testEncoding");
}
+ public void testOutputEncoding() throws IOException {
+ executeTarget("testOutputEncoding");
+ }
+
public void testLongLines() throws IOException {
executeTarget("testLongLines");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org