Browse Source

I knew it was 70 for a reason :-) Need to allow for the end of line bytes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271944 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
70ff2fc795
1 changed files with 17 additions and 8 deletions
  1. +17
    -8
      src/main/org/apache/tools/ant/taskdefs/Manifest.java

+ 17
- 8
src/main/org/apache/tools/ant/taskdefs/Manifest.java View File

@@ -105,7 +105,16 @@ public class Manifest extends Task {


/** The max length of a line in a Manifest */ /** The max length of a line in a Manifest */
public static final int MAX_LINE_LENGTH = 72; 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. * Helper class for Manifest's mode attribute.
*/ */
@@ -317,9 +326,9 @@ public class Manifest extends Task {
String line = name + ": " + value; String line = name + ": " + value;
while (line.getBytes().length > MAX_LINE_LENGTH) { while (line.getBytes().length > MAX_LINE_LENGTH) {
// try to find a MAX_LINE_LENGTH byte section // 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); String section = line.substring(0, breakIndex);
while (section.getBytes().length > MAX_LINE_LENGTH
while (section.getBytes().length > MAX_SECTION_LENGTH
&& breakIndex > 0) { && breakIndex > 0) {
breakIndex--; breakIndex--;
section = line.substring(0, breakIndex); section = line.substring(0, breakIndex);
@@ -328,10 +337,10 @@ public class Manifest extends Task {
throw new IOException("Unable to write manifest line " throw new IOException("Unable to write manifest line "
+ name + ": " + value); + name + ": " + value);
} }
writer.println(section);
writer.print(section + EOL);
line = " " + line.substring(breakIndex); line = " " + line.substring(breakIndex);
} }
writer.println(line);
writer.print(line + EOL);
} }
} }
@@ -478,7 +487,7 @@ public class Manifest extends Task {
Attribute attribute = getAttribute(key); Attribute attribute = getAttribute(key);
attribute.write(writer); attribute.write(writer);
} }
writer.println();
writer.print(EOL);
} }


/** /**
@@ -853,12 +862,12 @@ public class Manifest extends Task {
* @throws IOException if the manifest cannot be written * @throws IOException if the manifest cannot be written
*/ */
public void write(PrintWriter writer) throws IOException { public void write(PrintWriter writer) throws IOException {
writer.println(ATTRIBUTE_MANIFEST_VERSION + ": " + manifestVersion);
writer.print(ATTRIBUTE_MANIFEST_VERSION + ": " + manifestVersion + EOL);
String signatureVersion String signatureVersion
= mainSection.getAttributeValue(ATTRIBUTE_SIGNATURE_VERSION); = mainSection.getAttributeValue(ATTRIBUTE_SIGNATURE_VERSION);
if (signatureVersion != null) { if (signatureVersion != null) {
writer.println(ATTRIBUTE_SIGNATURE_VERSION + ": "
+ signatureVersion);
writer.print(ATTRIBUTE_SIGNATURE_VERSION + ": "
+ signatureVersion + EOL);
mainSection.removeAttribute(ATTRIBUTE_SIGNATURE_VERSION); mainSection.removeAttribute(ATTRIBUTE_SIGNATURE_VERSION);
} }
mainSection.write(writer); mainSection.write(writer);


Loading…
Cancel
Save