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/testcases/org/apache/tools/ant/taskdefs FixCrLfTest.java
Date Thu, 10 Jan 2002 16:17:12 GMT
bodewig     02/01/10 08:17:12

  Modified:    .        WHATSNEW
               src/etc/testcases/taskdefs/fixcrlf build.xml
               src/main/org/apache/tools/ant/taskdefs FixCRLF.java
               src/testcases/org/apache/tools/ant/taskdefs FixCrLfTest.java
  Added:       src/etc/testcases/taskdefs/fixcrlf/expected Mac2Unix
               src/etc/testcases/taskdefs/fixcrlf/input Mac2Unix
  Log:
  <fixcrlf> failed on Mac files.
  
  Reported by:	Matt McHenry <mmchenry@carnegielearning.com>
  
  Revision  Changes    Path
  1.197     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.196
  retrieving revision 1.197
  diff -u -r1.196 -r1.197
  --- WHATSNEW	7 Jan 2002 12:38:08 -0000	1.196
  +++ WHATSNEW	10 Jan 2002 16:17:11 -0000	1.197
  @@ -60,6 +60,8 @@
   * Some junit formatters incorrectly assumed that all testcases would
     inherit from junit.framework.TestCase.
   
  +* <fixcrlf> dropped the first characters from Mac files.
  +
   Other changes:
   --------------
   * <move> attempts to rename the directory, if everything inside it is
  
  
  
  1.6       +7 -0      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.xml	13 Nov 2001 14:49:47 -0000	1.5
  +++ build.xml	10 Jan 2002 16:17:12 -0000	1.6
  @@ -97,6 +97,13 @@
                />
     </target>
   
  +  <target name="testMacLines" depends="init">
  +    <fixcrlf srcdir="input" destdir="result"
  +             includes="Mac2Unix"
  +             eol="lf"
  +             />
  +  </target>
  +
     <target name="testEncoding" depends="init">
       <fixcrlf srcdir="input" destdir="result"
                includes="input.crlf.utf16"
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/fixcrlf/expected/Mac2Unix
  
  Index: Mac2Unix
  ===================================================================
  line1
  line2
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/fixcrlf/input/Mac2Unix
  
  Index: Mac2Unix
  ===================================================================
  line1
line2
  
  
  1.27      +14 -11    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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FixCRLF.java	10 Jan 2002 13:59:31 -0000	1.26
  +++ FixCRLF.java	10 Jan 2002 16:17:12 -0000	1.27
  @@ -57,6 +57,7 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   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.util.FileUtils;
   
  @@ -115,7 +116,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.26 $ $Name:  $
  + * @version $Revision: 1.27 $ $Name:  $
    */
   
   public class FixCRLF extends MatchingTask {
  @@ -170,20 +171,18 @@
        */
       public FixCRLF () {
           tabs = ASIS;
  -        if (System.getProperty("path.separator").equals(":")) {
  +        if (Os.isFamily("mac")) {
               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;
               eol = CRLF;
               eolstr = "\r\n";
  +        } else {
  +            ctrlz = REMOVE;
  +            eol = LF;
  +            eolstr = "\n";
           }
       }
   
  @@ -853,6 +852,7 @@
                       // Regard \r\r not followed by \n as two lines
                       ++eolcount;
                       eolStr.append('\r');
  +                    reader.mark(2);
                       switch ((char)(ch = reader.read())) {
                       case '\r':
                           if ((char)(ch = reader.read()) == '\n') {
  @@ -863,6 +863,9 @@
                       case '\n':
                           ++eolcount;
                           eolStr.append('\n');
  +                        break;
  +                    default:
  +                        reader.reset();
                           break;
                       } // end of switch ((char)(ch = reader.read()))
                       break;
  
  
  
  1.8       +7 -1      jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java
  
  Index: FixCrLfTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FixCrLfTest.java	10 Jan 2002 10:13:12 -0000	1.7
  +++ FixCrLfTest.java	10 Jan 2002 16:17:12 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
    * 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.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -130,6 +130,12 @@
           executeTarget("test9");
           assertEqualContent(new File("src/etc/testcases/taskdefs/fixcrlf/expected/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 {
  
  
  

--
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