Browse Source

a little cleanup

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269906 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
7e8bb3f17d
3 changed files with 33 additions and 19 deletions
  1. +2
    -0
      WHATSNEW
  2. +9
    -9
      src/etc/testcases/taskdefs/fixcrlf/build.xml
  3. +22
    -10
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java

+ 2
- 0
WHATSNEW View File

@@ -59,6 +59,8 @@ Other changes:

* Improved support for Novell NetWare.

* Added an optional encoding attribute to <fixcrlf>

Changes from Ant 1.4 to Ant 1.4.1
===========================================



+ 9
- 9
src/etc/testcases/taskdefs/fixcrlf/build.xml View File

@@ -23,7 +23,7 @@
includes="Junk2.java"
javafiles="true"
tab="add"
cr="add"
cr="add"
eol="crlf"
eof="asis"
/>
@@ -62,7 +62,7 @@
<fixcrlf srcdir="input" destdir="result"
includes="Junk6.java"
tab="add"
cr="remove"
cr="remove"
eol="crlf"
eof="asis"
/>
@@ -72,7 +72,7 @@
<fixcrlf srcdir="input" destdir="result"
includes="Junk7.java"
tab="add"
cr="add"
cr="add"
eof="asis"
/>
</target>
@@ -80,9 +80,9 @@
<target name="test8" depends="init">
<fixcrlf srcdir="input" destdir="result"
includes="Junk8.java"
javafiles="true"
javafiles="true"
tab="add"
cr="add"
cr="add"
eof="add"
/>
</target>
@@ -90,9 +90,9 @@
<target name="test9" depends="init">
<fixcrlf srcdir="input" destdir="result"
includes="Junk9.java"
javafiles="true"
javafiles="true"
tab="remove"
cr="remove"
cr="remove"
eof="remove"
/>
</target>
@@ -100,8 +100,8 @@
<target name="testEncoding" depends="init">
<fixcrlf srcdir="input" destdir="result"
includes="input.crlf.utf16"
javafiles="false"
cr="remove"
javafiles="false"
cr="remove"
encoding="UTF16"
/>
</target>


+ 22
- 10
src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -393,8 +393,8 @@ public class FixCRLF extends MatchingTask {
* Checks for the inequality of two files
*/
private boolean filesEqual(File file1, File file2) {
BufferedReader reader1;
BufferedReader reader2;
BufferedReader reader1 = null;
BufferedReader reader2 = null;
char buf1[] = new char[INBUFLEN];
char buf2[] = new char[INBUFLEN];
int buflen;
@@ -415,20 +415,26 @@ public class FixCRLF extends MatchingTask {
// know what it is
for (int i = 0; i < buflen; i++) {
if (buf1[i] != buf2[i]) {
reader1.close();
reader2.close();
return false;
} // end of if (buf1[i] != buf2[i])
}
}
reader1.close();
reader2.close();
return true; // equal
} catch (IOException e) {
throw new BuildException("IOException in filesEqual: " +
file1 + " : " + file2);
} // end of try-catch
} finally {
if (reader1 != null) {
try {
reader1.close();
} catch (IOException e) {}
}
if (reader2 != null) {
try {
reader2.close();
} catch (IOException e) {}
}
}
}


@@ -572,10 +578,16 @@ public class FixCRLF extends MatchingTask {
} else if (ctrlz == ADD){
outWriter.write(CTRLZ);
}
outWriter.close();
} catch (IOException e) {
throw new BuildException(e);
} // end of try-catch
} finally {
try {
outWriter.close();
} catch (IOException e) {
throw new BuildException(e);
}
}
File destFile = new File(destD, file);



Loading…
Cancel
Save