ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs FixCRLF.java
Date Tue, 13 Nov 2001 14:02:15 GMT
bodewig     01/11/13 06:02:15

  Modified:    .        WHATSNEW
               src/etc/testcases/taskdefs/fixcrlf build.xml
               src/main/org/apache/tools/ant/taskdefs FixCRLF.java
  Log:
  a little cleanup
  
  Revision  Changes    Path
  1.166     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.165
  retrieving revision 1.166
  diff -u -r1.165 -r1.166
  --- WHATSNEW	2001/11/09 15:48:11	1.165
  +++ WHATSNEW	2001/11/13 14:02:15	1.166
  @@ -59,6 +59,8 @@
   
   * Improved support for Novell NetWare.
   
  +* Added an optional encoding attribute to <fixcrlf>
  +
   Changes from Ant 1.4 to Ant 1.4.1
   ===========================================
   
  
  
  
  1.4       +9 -9      jakarta-ant/src/etc/testcases/taskdefs/fixcrlf/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/fixcrlf/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml	2001/11/13 13:49:03	1.3
  +++ build.xml	2001/11/13 14:02:15	1.4
  @@ -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>
  
  
  
  1.22      +22 -10    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  
  Index: FixCRLF.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- FixCRLF.java	2001/11/13 13:46:04	1.21
  +++ FixCRLF.java	2001/11/13 14:02:15	1.22
  @@ -115,7 +115,7 @@
    *
    * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
    * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
  - * @version $Revision: 1.21 $ $Name:  $
  + * @version $Revision: 1.22 $ $Name:  $
    */
   
   public class FixCRLF extends MatchingTask {
  @@ -393,8 +393,8 @@
        * 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 @@
                    // 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 @@
                   } 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);
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message