ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Manifest.java
Date Thu, 21 Mar 2002 11:00:30 GMT
conor       02/03/21 03:00:30

  Modified:    src/main/org/apache/tools/ant/taskdefs Manifest.java
  Log:
  I knew it was 70 for a reason :-) Need to allow for the end of line bytes
  
  Revision  Changes    Path
  1.27      +17 -8     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  
  Index: Manifest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -u -r1.26 -r1.27
  --- Manifest.java	20 Mar 2002 12:23:42 -0000	1.26
  +++ Manifest.java	21 Mar 2002 11:00:30 -0000	1.27
  @@ -107,6 +107,15 @@
       public static final int MAX_LINE_LENGTH = 72;
   
       /**
  +     * Max length of a line section which is continued. need to allow 
  +     * for the CRLF
  +     */
  +    public static final int MAX_SECTION_LENGTH = MAX_LINE_LENGTH - 2;
  +
  +    /** The End-Of-Line marker in manifests */
  +    public static final String EOL = "\r\n";
  +    
  +    /**
        * Helper class for Manifest's mode attribute.
        */
       public static class Mode extends EnumeratedAttribute {
  @@ -317,9 +326,9 @@
               String line = name + ": " + value;
               while (line.getBytes().length > MAX_LINE_LENGTH) {
                   // try to find a MAX_LINE_LENGTH byte section
  -                int breakIndex = MAX_LINE_LENGTH;
  +                int breakIndex = MAX_SECTION_LENGTH;
                   String section = line.substring(0, breakIndex);
  -                while (section.getBytes().length > MAX_LINE_LENGTH 
  +                while (section.getBytes().length > MAX_SECTION_LENGTH 
                        && breakIndex > 0) {
                       breakIndex--;
                       section = line.substring(0, breakIndex);
  @@ -328,10 +337,10 @@
                       throw new IOException("Unable to write manifest line " 
                           + name + ": " + value);
                   }
  -                writer.println(section);
  +                writer.print(section + EOL);
                   line = " " + line.substring(breakIndex);
               }
  -            writer.println(line);
  +            writer.print(line + EOL);
           }
       }
       
  @@ -478,7 +487,7 @@
                   Attribute attribute = getAttribute(key);
                   attribute.write(writer);
               }
  -            writer.println();
  +            writer.print(EOL);
           }
   
           /**
  @@ -853,12 +862,12 @@
       * @throws IOException if the manifest cannot be written
       */
       public void write(PrintWriter writer) throws IOException {
  -        writer.println(ATTRIBUTE_MANIFEST_VERSION + ": " + manifestVersion);
  +        writer.print(ATTRIBUTE_MANIFEST_VERSION + ": " + manifestVersion + EOL);
           String signatureVersion 
               = mainSection.getAttributeValue(ATTRIBUTE_SIGNATURE_VERSION);
           if (signatureVersion != null) {
  -            writer.println(ATTRIBUTE_SIGNATURE_VERSION + ": " 
  -                + signatureVersion);
  +            writer.print(ATTRIBUTE_SIGNATURE_VERSION + ": " 
  +                + signatureVersion + EOL);
               mainSection.removeAttribute(ATTRIBUTE_SIGNATURE_VERSION);
           }
           mainSection.write(writer);
  
  
  

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