Reported by: Matt McHenry <mmchenry@carnegielearning.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270662 13f79535-47bb-0310-9956-ffa450edef68master
@@ -60,6 +60,8 @@ Fixed bugs: | |||||
* Some junit formatters incorrectly assumed that all testcases would | * Some junit formatters incorrectly assumed that all testcases would | ||||
inherit from junit.framework.TestCase. | inherit from junit.framework.TestCase. | ||||
* <fixcrlf> dropped the first characters from Mac files. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
* <move> attempts to rename the directory, if everything inside it is | * <move> attempts to rename the directory, if everything inside it is | ||||
@@ -97,6 +97,13 @@ | |||||
/> | /> | ||||
</target> | </target> | ||||
<target name="testMacLines" depends="init"> | |||||
<fixcrlf srcdir="input" destdir="result" | |||||
includes="Mac2Unix" | |||||
eol="lf" | |||||
/> | |||||
</target> | |||||
<target name="testEncoding" depends="init"> | <target name="testEncoding" depends="init"> | ||||
<fixcrlf srcdir="input" destdir="result" | <fixcrlf srcdir="input" destdir="result" | ||||
includes="input.crlf.utf16" | includes="input.crlf.utf16" | ||||
@@ -0,0 +1,2 @@ | |||||
line1 | |||||
line2 |
@@ -0,0 +1 @@ | |||||
line1 line2 |
@@ -57,6 +57,7 @@ package org.apache.tools.ant.taskdefs; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
@@ -170,20 +171,18 @@ public class FixCRLF extends MatchingTask { | |||||
*/ | */ | ||||
public FixCRLF () { | public FixCRLF () { | ||||
tabs = ASIS; | tabs = ASIS; | ||||
if (System.getProperty("path.separator").equals(":")) { | |||||
if (Os.isFamily("mac")) { | |||||
ctrlz = REMOVE; | ctrlz = REMOVE; | ||||
if (System.getProperty("os.name").indexOf("Mac") > -1) { | |||||
eol = CR; | |||||
eolstr = "\r"; | |||||
} else { | |||||
eol = LF; | |||||
eolstr = "\n"; | |||||
} | |||||
} | |||||
else { | |||||
eol = CR; | |||||
eolstr = "\r"; | |||||
} else if (Os.isFamily("dos")) { | |||||
ctrlz = ASIS; | ctrlz = ASIS; | ||||
eol = CRLF; | eol = CRLF; | ||||
eolstr = "\r\n"; | eolstr = "\r\n"; | ||||
} else { | |||||
ctrlz = REMOVE; | |||||
eol = LF; | |||||
eolstr = "\n"; | |||||
} | } | ||||
} | } | ||||
@@ -853,6 +852,7 @@ public class FixCRLF extends MatchingTask { | |||||
// Regard \r\r not followed by \n as two lines | // Regard \r\r not followed by \n as two lines | ||||
++eolcount; | ++eolcount; | ||||
eolStr.append('\r'); | eolStr.append('\r'); | ||||
reader.mark(2); | |||||
switch ((char)(ch = reader.read())) { | switch ((char)(ch = reader.read())) { | ||||
case '\r': | case '\r': | ||||
if ((char)(ch = reader.read()) == '\n') { | if ((char)(ch = reader.read()) == '\n') { | ||||
@@ -864,6 +864,9 @@ public class FixCRLF extends MatchingTask { | |||||
++eolcount; | ++eolcount; | ||||
eolStr.append('\n'); | eolStr.append('\n'); | ||||
break; | break; | ||||
default: | |||||
reader.reset(); | |||||
break; | |||||
} // end of switch ((char)(ch = reader.read())) | } // end of switch ((char)(ch = reader.read())) | ||||
break; | break; | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -132,6 +132,12 @@ public class FixCrLfTest extends BuildFileTest { | |||||
new File("src/etc/testcases/taskdefs/fixcrlf/result/Junk9.java")); | new File("src/etc/testcases/taskdefs/fixcrlf/result/Junk9.java")); | ||||
} | } | ||||
public void testMacLines() throws IOException { | |||||
executeTarget("testMacLines"); | |||||
assertEqualContent(new File("src/etc/testcases/taskdefs/fixcrlf/expected/Mac2Unix"), | |||||
new File("src/etc/testcases/taskdefs/fixcrlf/result/Mac2Unix")); | |||||
} | |||||
public void testNoOverwrite() throws IOException { | public void testNoOverwrite() throws IOException { | ||||
executeTarget("test1"); | executeTarget("test1"); | ||||
File result = | File result = | ||||