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 ConcatTest.java
Date Mon, 18 Nov 2002 15:22:53 GMT
bodewig     2002/11/18 07:22:52

  Modified:    .        WHATSNEW
               src/etc/testcases/taskdefs concat.xml
               src/main/org/apache/tools/ant/taskdefs Concat.java
               src/testcases/org/apache/tools/ant/taskdefs ConcatTest.java
  Added:       src/etc/testcases/taskdefs/concat-input A B
  Log:
  Don't add newlines in <concat> that haven't been in the files
  originally - no matter what encoding.
  
  PR: 12511
  
  Revision  Changes    Path
  1.322     +4 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.321
  retrieving revision 1.322
  diff -u -r1.321 -r1.322
  --- WHATSNEW	18 Nov 2002 12:02:27 -0000	1.321
  +++ WHATSNEW	18 Nov 2002 15:22:51 -0000	1.322
  @@ -55,6 +55,10 @@
   
   * <cvschangelog> could miss today's changes.
   
  +* entity includes would cause exceptions if path names included spaces.
  +
  +* <concat> could append newline characters between concatenated files.
  +
   Other changes:
   --------------
   * <setproxy> lets you set the username and password for proxies that want authentication
  
  
  
  1.5       +12 -0     jakarta-ant/src/etc/testcases/taskdefs/concat.xml
  
  Index: concat.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/concat.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- concat.xml	12 Nov 2002 11:58:28 -0000	1.4
  +++ concat.xml	18 Nov 2002 15:22:52 -0000	1.5
  @@ -40,4 +40,16 @@
             if="TESTDEST.was.created"/>
     </target>
   
  +  <target name="testConcatNoNewline">
  +    <concat>
  +      <fileset dir="concat-input"/>
  +    </concat>
  +  </target>
  +
  +  <target name="testConcatNoNewlineEncoding">
  +    <concat encoding="ASCII">
  +      <fileset dir="concat-input"/>
  +    </concat>
  +  </target>
  +
   </project>
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/concat-input/A
  
  Index: A
  ===================================================================
  a
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/concat-input/B
  
  Index: B
  ===================================================================
  b
  
  
  1.12      +21 -17    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Concat.java
  
  Index: Concat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Concat.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Concat.java	12 Nov 2002 11:58:28 -0000	1.11
  +++ Concat.java	18 Nov 2002 15:22:52 -0000	1.12
  @@ -63,8 +63,8 @@
   import java.io.InputStreamReader;
   import java.io.OutputStream;
   import java.io.OutputStreamWriter;
  -import java.io.PrintWriter;
   import java.io.StringReader;
  +import java.io.Writer;
   import java.util.Enumeration;
   import java.util.Vector;
   import org.apache.tools.ant.BuildException;
  @@ -360,7 +360,7 @@
                       }
   
                       is = new FileInputStream(input[i]);
  -                    byte[] buffer = new byte[8096];
  +                    byte[] buffer = new byte[8192];
                       while (true) {
                           int bytesRead = is.read(buffer);
                           if (bytesRead == -1) { // EOF
  @@ -390,24 +390,22 @@
                   }
               }
   
  -        } else { // user specified encoding, assume line oriented input
  +        } else { // user specified encoding
   
  -            PrintWriter out = null;
  +            Writer out = null;
               BufferedReader in = null;
   
               try {
                   if (destinationFile == null) {
                       // Log using WARN so it displays in 'quiet' mode.
  -                    out = new PrintWriter(
  -                              new OutputStreamWriter(
  -                                  new LogOutputStream(this, Project.MSG_WARN)));
  +                    out = new OutputStreamWriter(
  +                              new LogOutputStream(this, Project.MSG_WARN));
                   } else {
  -                    out = new PrintWriter(
  -                              new OutputStreamWriter(
  -                                  new FileOutputStream(destinationFile
  -                                                       .getAbsolutePath(),
  -                                                       append),
  -                                  encoding));
  +                    out = new OutputStreamWriter(
  +                              new FileOutputStream(destinationFile
  +                                                   .getAbsolutePath(),
  +                                                   append),
  +                              encoding);
                       
                       // This flag should only be recognized for the first
                       // file. In the context of a single 'cat', we always
  @@ -421,11 +419,17 @@
                                   encoding));
   
                       String line;
  -                    while ((line = in.readLine()) != null) {
  -                        // Log the line, using WARN so it displays in
  -                        // 'quiet' mode.
  -                        out.println(line);
  +                    char[] buffer = new char[4096];
  +                    while (true) {
  +                        int charsRead = in.read(buffer);
  +                        if (charsRead == -1) { // EOF
  +                            break;
  +                        }
  +                        
  +                        // Write the read data.
  +                        out.write(buffer, 0, charsRead);
                       }
  +                    out.flush();
                       in.close();
                       in = null;
                   }
  
  
  
  1.3       +7 -0      jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ConcatTest.java
  
  Index: ConcatTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ConcatTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConcatTest.java	8 Nov 2002 13:10:22 -0000	1.2
  +++ ConcatTest.java	18 Nov 2002 15:22:52 -0000	1.3
  @@ -166,4 +166,11 @@
                               "src/etc/testcases/taskdefs/thisfiledoesnotexist does not exist.");
       }
   
  +    public void testConcatNoNewline() {
  +        expectLog("testConcatNoNewline", "ab");
  +    }
  +
  +    public void testConcatNoNewlineEncoding() {
  +        expectLog("testConcatNoNewlineEncoding", "ab");
  +    }
   }
  
  
  

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