Submitted by Stephen Goetze git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@417584 13f79535-47bb-0310-9956-ffa450edef68master
@@ -219,6 +219,7 @@ Stephane Bailliez | |||||
stephan | stephan | ||||
Stephan Michels | Stephan Michels | ||||
Stephen Chin | Stephen Chin | ||||
Stephen Goetze | |||||
Steve Cohen | Steve Cohen | ||||
Steve Loughran | Steve Loughran | ||||
Steve Morin | Steve Morin | ||||
@@ -442,6 +442,8 @@ Other changes: | |||||
* <scriptdef>-created scripts have support for nested text. All text | * <scriptdef>-created scripts have support for nested text. All text | ||||
passed to a scripted task can be accessed via self.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 | Changes from Ant 1.6.4 to Ant 1.6.5 | ||||
=================================== | =================================== | ||||
@@ -121,6 +121,13 @@ | |||||
<td align="center">No; defaults to default JVM encoding.</td> | <td align="center">No; defaults to default JVM encoding.</td> | ||||
<td bgcolor="#CCCCCC"> </td> | <td bgcolor="#CCCCCC"> </td> | ||||
</tr> | </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> | <tr> | ||||
<td valign="top">preservelastmodified</td> | <td valign="top">preservelastmodified</td> | ||||
<td valign="top">Whether to preserve the last modified | <td valign="top">Whether to preserve the last modified | ||||
@@ -143,10 +150,11 @@ | |||||
<li>unix: convert all EOLs to a single LF</li> | <li>unix: convert all EOLs to a single LF</li> | ||||
<li>dos: convert all EOLs to the pair CRLF</li> | <li>dos: convert all EOLs to the pair CRLF</li> | ||||
</ul> | </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> | <p> | ||||
This is the preferred method for specifying EOL. The | This is the preferred method for specifying EOL. The | ||||
"<i><b>cr</b></i>" attribute (see below) is | "<i><b>cr</b></i>" attribute (see below) is | ||||
@@ -298,7 +306,7 @@ | |||||
DOS systems, and are removed if run on Unix systems. | DOS systems, and are removed if run on Unix systems. | ||||
You never know what editor a user will use to browse READMEs.</p> | You never know what editor a user will use to browse READMEs.</p> | ||||
<hr> | <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> | Reserved.</p> | ||||
</body> | </body> | ||||
@@ -117,6 +117,15 @@ | |||||
file2="expected/input.lf.utf16" /> | file2="expected/input.lf.utf16" /> | ||||
</target> | </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"> | <target name="testLongLines" depends="init"> | ||||
<fixcrlf srcdir="input" destdir="result" | <fixcrlf srcdir="input" destdir="result" | ||||
includes="longlines.crlf" | includes="longlines.crlf" | ||||
@@ -0,0 +1,2 @@ | |||||
Line1 | |||||
Line2 |
@@ -52,6 +52,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
* <li>tab | * <li>tab | ||||
* <li>eof | * <li>eof | ||||
* <li>encoding | * <li>encoding | ||||
* <li>targetencoding | |||||
* </ul> | * </ul> | ||||
* Of these arguments, only <b>sourcedir</b> is required. | * Of these arguments, only <b>sourcedir</b> is required. | ||||
* <p> | * <p> | ||||
@@ -98,6 +99,11 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||||
*/ | */ | ||||
private String encoding = null; | private String encoding = null; | ||||
/** | |||||
* Encoding to use for output files | |||||
*/ | |||||
private String outputEncoding = null; | |||||
/** | /** | ||||
* Chain this task as a reader. | * Chain this task as a reader. | ||||
* @param rdr Reader to chain. | * @param rdr Reader to chain. | ||||
@@ -237,6 +243,15 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||||
this.encoding = encoding; | this.encoding = encoding; | ||||
} | } | ||||
/** | |||||
* 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 | * Specify whether a missing EOL will be added | ||||
* to the final line of a file. | * to the final line of a file. | ||||
@@ -288,12 +303,15 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||||
} | } | ||||
} | } | ||||
// log options used | // log options used | ||||
String enc = encoding == null ? "default" : encoding; | |||||
log("options:" | log("options:" | ||||
+ " eol=" + filter.getEol().getValue() | + " eol=" + filter.getEol().getValue() | ||||
+ " tab=" + filter.getTab().getValue() | + " tab=" + filter.getTab().getValue() | ||||
+ " eof=" + filter.getEof().getValue() | + " eof=" + filter.getEof().getValue() | ||||
+ " tablength=" + filter.getTablength() | + " tablength=" + filter.getTablength() | ||||
+ " encoding=" + (encoding == null ? "default" : encoding), | |||||
+ " encoding=" + enc | |||||
+ " outputencoding=" | |||||
+ (outputEncoding == null ? enc : outputEncoding), | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
DirectoryScanner ds = super.getDirectoryScanner(srcDir); | DirectoryScanner ds = super.getDirectoryScanner(srcDir); | ||||
@@ -318,8 +336,9 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||||
File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null); | File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null); | ||||
tmpFile.deleteOnExit(); | tmpFile.deleteOnExit(); | ||||
try { | 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); | File destFile = new File(destD, file); | ||||
@@ -91,6 +91,10 @@ public class FixCrLfTest extends BuildFileTest { | |||||
executeTarget("testEncoding"); | executeTarget("testEncoding"); | ||||
} | } | ||||
public void testOutputEncoding() throws IOException { | |||||
executeTarget("testOutputEncoding"); | |||||
} | |||||
public void testLongLines() throws IOException { | public void testLongLines() throws IOException { | ||||
executeTarget("testLongLines"); | executeTarget("testLongLines"); | ||||
} | } | ||||