Browse Source

restyled

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270312 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
4058f2a97f
68 changed files with 1418 additions and 1392 deletions
  1. +0
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  2. +0
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/And.java
  3. +1
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  4. +2
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java
  5. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java
  6. +2
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java
  7. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  8. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/Commandline.java
  9. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/FileList.java
  10. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java
  11. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java
  12. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java
  13. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
  14. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java
  15. +7
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/util/SourceFileScanner.java
  16. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/bzip2/BZip2Constants.java
  17. +131
    -129
      proposal/myrmidon/src/main/org/apache/tools/bzip2/CBZip2InputStream.java
  18. +331
    -329
      proposal/myrmidon/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
  19. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/bzip2/CRC.java
  20. +9
    -7
      proposal/myrmidon/src/main/org/apache/tools/mail/MailMessage.java
  21. +1
    -0
      proposal/myrmidon/src/main/org/apache/tools/mail/SmtpResponseReader.java
  22. +24
    -23
      proposal/myrmidon/src/main/org/apache/tools/tar/TarBuffer.java
  23. +9
    -9
      proposal/myrmidon/src/main/org/apache/tools/tar/TarConstants.java
  24. +16
    -17
      proposal/myrmidon/src/main/org/apache/tools/tar/TarEntry.java
  25. +50
    -45
      proposal/myrmidon/src/main/org/apache/tools/tar/TarInputStream.java
  26. +19
    -19
      proposal/myrmidon/src/main/org/apache/tools/tar/TarOutputStream.java
  27. +18
    -18
      proposal/myrmidon/src/main/org/apache/tools/tar/TarUtils.java
  28. +19
    -16
      proposal/myrmidon/src/main/org/apache/tools/zip/AsiExtraField.java
  29. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/zip/UnrecognizedExtraField.java
  30. +12
    -11
      proposal/myrmidon/src/main/org/apache/tools/zip/ZipEntry.java
  31. +1
    -0
      proposal/myrmidon/src/main/org/apache/tools/zip/ZipExtraField.java
  32. +11
    -11
      proposal/myrmidon/src/main/org/apache/tools/zip/ZipLong.java
  33. +23
    -22
      proposal/myrmidon/src/main/org/apache/tools/zip/ZipOutputStream.java
  34. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/zip/ZipShort.java
  35. +0
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  36. +0
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/condition/And.java
  37. +1
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  38. +2
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java
  39. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java
  40. +2
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java
  41. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  42. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/Commandline.java
  43. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileList.java
  44. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java
  45. +3
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java
  46. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java
  47. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java
  48. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java
  49. +7
    -7
      proposal/myrmidon/src/todo/org/apache/tools/ant/util/SourceFileScanner.java
  50. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/bzip2/BZip2Constants.java
  51. +131
    -129
      proposal/myrmidon/src/todo/org/apache/tools/bzip2/CBZip2InputStream.java
  52. +331
    -329
      proposal/myrmidon/src/todo/org/apache/tools/bzip2/CBZip2OutputStream.java
  53. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/bzip2/CRC.java
  54. +9
    -7
      proposal/myrmidon/src/todo/org/apache/tools/mail/MailMessage.java
  55. +1
    -0
      proposal/myrmidon/src/todo/org/apache/tools/mail/SmtpResponseReader.java
  56. +24
    -23
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarBuffer.java
  57. +9
    -9
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarConstants.java
  58. +16
    -17
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarEntry.java
  59. +50
    -45
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarInputStream.java
  60. +19
    -19
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarOutputStream.java
  61. +18
    -18
      proposal/myrmidon/src/todo/org/apache/tools/tar/TarUtils.java
  62. +19
    -16
      proposal/myrmidon/src/todo/org/apache/tools/zip/AsiExtraField.java
  63. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/zip/UnrecognizedExtraField.java
  64. +12
    -11
      proposal/myrmidon/src/todo/org/apache/tools/zip/ZipEntry.java
  65. +1
    -0
      proposal/myrmidon/src/todo/org/apache/tools/zip/ZipExtraField.java
  66. +11
    -11
      proposal/myrmidon/src/todo/org/apache/tools/zip/ZipLong.java
  67. +23
    -22
      proposal/myrmidon/src/todo/org/apache/tools/zip/ZipOutputStream.java
  68. +6
    -6
      proposal/myrmidon/src/todo/org/apache/tools/zip/ZipShort.java

+ 0
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -437,7 +437,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
Execute exe = new Execute( new LogStreamHandler( attributes, Execute exe = new Execute( new LogStreamHandler( attributes,
Project.MSG_INFO, Project.MSG_INFO,
Project.MSG_WARN ) ); Project.MSG_WARN ) );
exe.setAntRun( project );
exe.setWorkingDirectory( project.getBaseDir() ); exe.setWorkingDirectory( project.getBaseDir() );
exe.setCommandline( commandArray ); exe.setCommandline( commandArray );
exe.execute(); exe.execute();


+ 0
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/And.java View File

@@ -7,7 +7,6 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import java.util.Iterator;
import java.util.Enumeration; import java.util.Enumeration;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;




+ 1
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java View File

@@ -7,10 +7,9 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.apache.myrmidon.framework.Os; import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.taskdefs.Available; import org.apache.tools.ant.taskdefs.Available;


+ 2
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java View File

@@ -10,10 +10,9 @@ package org.apache.tools.ant.taskdefs.file;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java View File

@@ -457,8 +457,8 @@ public class Delete
if( dirCount > 0 ) if( dirCount > 0 )
{ {
getLogger().info( "Deleted " + dirCount + " director" + getLogger().info( "Deleted " + dirCount + " director" +
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
} }
} }
} }


+ 2
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java View File

@@ -9,16 +9,15 @@ package org.apache.tools.ant.taskdefs.file;


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.Iterator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.FilterSet; import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection; import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Moves a file or directory to a new file or directory. By default, the * Moves a file or directory to a new file or directory. By default, the


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.taskdefs.rmic; package org.apache.tools.ant.taskdefs.rmic;


import java.io.File; import java.io.File;
import java.util.Random;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Rmic; import org.apache.tools.ant.taskdefs.Rmic;


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/Commandline.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.StringTokenizer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;


/** /**


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/FileList.java View File

@@ -8,9 +8,9 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Stack; import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.Stack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Stack;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner; import org.apache.tools.ant.FileScanner;


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -10,11 +10,11 @@ package org.apache.tools.ant.types;// java io classes
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.Properties;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java View File

@@ -9,8 +9,8 @@ package org.apache.tools.ant.types;// java io classes


// java util classes // java util classes


import java.util.Iterator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;


// ant classes // ant classes


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java View File

@@ -8,10 +8,10 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
import java.util.Stack; import java.util.Stack;
import java.util.ArrayList;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -11,10 +11,10 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Stack; import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;


@@ -357,7 +357,7 @@ public class PatternSet extends DataType
} }


final String[] result = new String[ tmpNames.size() ]; final String[] result = new String[ tmpNames.size() ];
return (String[]) tmpNames.toArray( result );
return (String[])tmpNames.toArray( result );
} }


/** /**


+ 7
- 7
proposal/myrmidon/src/main/org/apache/tools/ant/util/SourceFileScanner.java View File

@@ -9,11 +9,11 @@ package org.apache.tools.ant.util;


import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os; import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.avalon.excalibur.io.FileUtil;


/** /**
* Utility class that collects the functionality of the various scanDir methods * Utility class that collects the functionality of the various scanDir methods
@@ -78,7 +78,7 @@ public class SourceFileScanner
if( targets == null || targets.length == 0 ) if( targets == null || targets.length == 0 )
{ {
m_task.log( files[ i ] + " skipped - don\'t know how to handle it", m_task.log( files[ i ] + " skipped - don\'t know how to handle it",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
continue; continue;
} }


@@ -87,7 +87,7 @@ public class SourceFileScanner
if( src.lastModified() > now ) if( src.lastModified() > now )
{ {
m_task.log( "Warning: " + files[ i ] + " modified in the future.", m_task.log( "Warning: " + files[ i ] + " modified in the future.",
Project.MSG_WARN );
Project.MSG_WARN );
} }


boolean added = false; boolean added = false;
@@ -99,14 +99,14 @@ public class SourceFileScanner
if( !dest.exists() ) if( !dest.exists() )
{ {
m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
v.add( files[ i ] ); v.add( files[ i ] );
added = true; added = true;
} }
else if( src.lastModified() > dest.lastModified() ) else if( src.lastModified() > dest.lastModified() )
{ {
m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
v.add( files[ i ] ); v.add( files[ i ] );
added = true; added = true;
} }
@@ -123,8 +123,8 @@ public class SourceFileScanner
if( !added ) if( !added )
{ {
m_task.log( files[ i ] + " omitted as " + targetList.toString() m_task.log( files[ i ] + " omitted as " + targetList.toString()
+ ( targets.length == 1 ? " is" : " are " )
+ " up to date.", Project.MSG_VERBOSE );
+ ( targets.length == 1 ? " is" : " are " )
+ " up to date.", Project.MSG_VERBOSE );
} }


} }


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/bzip2/BZip2Constants.java View File

@@ -80,5 +80,5 @@ public interface BZip2Constants
920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638 936, 638
};
};
} }

+ 131
- 129
proposal/myrmidon/src/main/org/apache/tools/bzip2/CBZip2InputStream.java View File

@@ -6,7 +6,9 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.bzip2; package org.apache.tools.bzip2;
import java.io.*;

import java.io.IOException;
import java.io.InputStream;


/** /**
* An input stream that decompresses from the BZip2 format (without the file * An input stream that decompresses from the BZip2 format (without the file
@@ -26,24 +28,24 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
private final static int NO_RAND_PART_C_STATE = 7; private final static int NO_RAND_PART_C_STATE = 7;
private CRC mCrc = new CRC(); private CRC mCrc = new CRC();


private boolean inUse[] = new boolean[256];
private boolean inUse[] = new boolean[ 256 ];


private char seqToUnseq[] = new char[256];
private char unseqToSeq[] = new char[256];
private char seqToUnseq[] = new char[ 256 ];
private char unseqToSeq[] = new char[ 256 ];


private char selector[] = new char[MAX_SELECTORS];
private char selectorMtf[] = new char[MAX_SELECTORS];
private char selector[] = new char[ MAX_SELECTORS ];
private char selectorMtf[] = new char[ MAX_SELECTORS ];


/* /*
* freq table collected to save a pass over the data * freq table collected to save a pass over the data
* during decompression. * during decompression.
*/ */
private int unzftab[] = new int[256];
private int unzftab[] = new int[ 256 ];


private int limit[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int base[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int perm[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int minLens[] = new int[N_GROUPS];
private int limit[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int base[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int perm[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int minLens[] = new int[ N_GROUPS ];


private boolean streamEnd = false; private boolean streamEnd = false;


@@ -146,28 +148,28 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
else else
{ {
int retChar = currentChar; int retChar = currentChar;
switch ( currentState )
switch( currentState )
{ {
case START_BLOCK_STATE:
break;
case RAND_PART_A_STATE:
break;
case RAND_PART_B_STATE:
setupRandPartB();
break;
case RAND_PART_C_STATE:
setupRandPartC();
break;
case NO_RAND_PART_A_STATE:
break;
case NO_RAND_PART_B_STATE:
setupNoRandPartB();
break;
case NO_RAND_PART_C_STATE:
setupNoRandPartC();
break;
default:
break;
case START_BLOCK_STATE:
break;
case RAND_PART_A_STATE:
break;
case RAND_PART_B_STATE:
setupRandPartB();
break;
case RAND_PART_C_STATE:
setupRandPartC();
break;
case NO_RAND_PART_A_STATE:
break;
case NO_RAND_PART_B_STATE:
setupNoRandPartB();
break;
case NO_RAND_PART_C_STATE:
setupNoRandPartC();
break;
default:
break;
} }
return retChar; return retChar;
} }
@@ -176,7 +178,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
private void setDecompressStructureSizes( int newSize100k ) private void setDecompressStructureSizes( int newSize100k )
{ {
if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k
&& blockSize100k <= 9 ) )
&& blockSize100k <= 9 ) )
{ {
// throw new IOException("Invalid block size"); // throw new IOException("Invalid block size");
} }
@@ -187,30 +189,30 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
return; return;


int n = baseBlockSize * newSize100k; int n = baseBlockSize * newSize100k;
ll8 = new char[n];
tt = new int[n];
ll8 = new char[ n ];
tt = new int[ n ];
} }


private void setupBlock() private void setupBlock()
{ {
int cftab[] = new int[257];
int cftab[] = new int[ 257 ];
char ch; char ch;


cftab[0] = 0;
cftab[ 0 ] = 0;
for( i = 1; i <= 256; i++ ) for( i = 1; i <= 256; i++ )
cftab[i] = unzftab[i - 1];
cftab[ i ] = unzftab[ i - 1 ];
for( i = 1; i <= 256; i++ ) for( i = 1; i <= 256; i++ )
cftab[i] += cftab[i - 1];
cftab[ i ] += cftab[ i - 1 ];


for( i = 0; i <= last; i++ ) for( i = 0; i <= last; i++ )
{ {
ch = ( char )ll8[i];
tt[cftab[ch]] = i;
cftab[ch]++;
ch = (char)ll8[ i ];
tt[ cftab[ ch ] ] = i;
cftab[ ch ]++;
} }
cftab = null; cftab = null;


tPos = tt[origPtr];
tPos = tt[ origPtr ];


count = 0; count = 0;
i2 = 0; i2 = 0;
@@ -235,8 +237,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( i2 <= last ) if( i2 <= last )
{ {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos];
tPos = tt[tPos];
ch2 = ll8[ tPos ];
tPos = tt[ tPos ];
i2++; i2++;


currentChar = ch2; currentChar = ch2;
@@ -264,8 +266,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
count++; count++;
if( count >= 4 ) if( count >= 4 )
{ {
z = ll8[tPos];
tPos = tt[tPos];
z = ll8[ tPos ];
tPos = tt[ tPos ];
currentState = NO_RAND_PART_C_STATE; currentState = NO_RAND_PART_C_STATE;
j2 = 0; j2 = 0;
setupNoRandPartC(); setupNoRandPartC();
@@ -280,7 +282,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void setupNoRandPartC() private void setupNoRandPartC()
{ {
if( j2 < ( int )z )
if( j2 < (int)z )
{ {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC( ch2 ); mCrc.updateCRC( ch2 );
@@ -300,17 +302,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( i2 <= last ) if( i2 <= last )
{ {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos];
tPos = tt[tPos];
ch2 = ll8[ tPos ];
tPos = tt[ tPos ];
if( rNToGo == 0 ) if( rNToGo == 0 )
{ {
rNToGo = rNums[rTPos];
rNToGo = rNums[ rTPos ];
rTPos++; rTPos++;
if( rTPos == 512 ) if( rTPos == 512 )
rTPos = 0; rTPos = 0;
} }
rNToGo--; rNToGo--;
ch2 ^= ( int )( ( rNToGo == 1 ) ? 1 : 0 );
ch2 ^= (int)( ( rNToGo == 1 ) ? 1 : 0 );
i2++; i2++;


currentChar = ch2; currentChar = ch2;
@@ -338,11 +340,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
count++; count++;
if( count >= 4 ) if( count >= 4 )
{ {
z = ll8[tPos];
tPos = tt[tPos];
z = ll8[ tPos ];
tPos = tt[ tPos ];
if( rNToGo == 0 ) if( rNToGo == 0 )
{ {
rNToGo = rNums[rTPos];
rNToGo = rNums[ rTPos ];
rTPos++; rTPos++;
if( rTPos == 512 ) if( rTPos == 512 )
rTPos = 0; rTPos = 0;
@@ -363,7 +365,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void setupRandPartC() private void setupRandPartC()
{ {
if( j2 < ( int )z )
if( j2 < (int)z )
{ {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC( ch2 ); mCrc.updateCRC( ch2 );
@@ -380,7 +382,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void getAndMoveToFrontDecode() private void getAndMoveToFrontDecode()
{ {
char yy[] = new char[256];
char yy[] = new char[ 256 ];
int i; int i;
int j; int j;
int nextSym; int nextSym;
@@ -404,10 +406,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
* cache misses. * cache misses.
*/ */
for( i = 0; i <= 255; i++ ) for( i = 0; i <= 255; i++ )
unzftab[i] = 0;
unzftab[ i ] = 0;


for( i = 0; i <= 255; i++ ) for( i = 0; i <= 255; i++ )
yy[i] = ( char )i;
yy[ i ] = (char)i;


last = -1; last = -1;
{ {
@@ -421,10 +423,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -435,7 +437,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -455,7 +457,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
} }
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }


while( true ) while( true )
@@ -487,10 +489,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -501,7 +503,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -522,18 +524,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
; ;
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }
}while ( nextSym == RUNA || nextSym == RUNB );
} while( nextSym == RUNA || nextSym == RUNB );


s++; s++;
ch = seqToUnseq[yy[0]];
unzftab[ch] += s;
ch = seqToUnseq[ yy[ 0 ] ];
unzftab[ ch ] += s;


while( s > 0 ) while( s > 0 )
{ {
last++; last++;
ll8[last] = ch;
ll8[ last ] = ch;
s--; s--;
} }
; ;
@@ -549,9 +551,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( last >= limitLast ) if( last >= limitLast )
blockOverrun(); blockOverrun();


tmp = yy[nextSym - 1];
unzftab[seqToUnseq[tmp]]++;
ll8[last] = seqToUnseq[tmp];
tmp = yy[ nextSym - 1 ];
unzftab[ seqToUnseq[ tmp ] ]++;
ll8[ last ] = seqToUnseq[ tmp ];


/* /*
* This loop is hammered during decompression, * This loop is hammered during decompression,
@@ -561,15 +563,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
j = nextSym - 1; j = nextSym - 1;
for( ; j > 3; j -= 4 ) for( ; j > 3; j -= 4 )
{ {
yy[j] = yy[j - 1];
yy[j - 1] = yy[j - 2];
yy[j - 2] = yy[j - 3];
yy[j - 3] = yy[j - 4];
yy[ j ] = yy[ j - 1 ];
yy[ j - 1 ] = yy[ j - 2 ];
yy[ j - 2 ] = yy[ j - 3 ];
yy[ j - 3 ] = yy[ j - 4 ];
} }
for( ; j > 0; j-- ) for( ; j > 0; j-- )
yy[j] = yy[j - 1];
yy[ j ] = yy[ j - 1 ];


yy[0] = tmp;
yy[ 0 ] = tmp;
{ {
int zt; int zt;
int zn; int zn;
@@ -581,10 +583,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -595,7 +597,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -612,7 +614,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
; ;
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }
continue; continue;
} }
@@ -626,17 +628,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private int bsGetInt32() private int bsGetInt32()
{ {
return ( int )bsGetint();
return (int)bsGetint();
} }


private int bsGetIntVS( int numBits ) private int bsGetIntVS( int numBits )
{ {
return ( int )bsR( numBits );
return (int)bsR( numBits );
} }


private char bsGetUChar() private char bsGetUChar()
{ {
return ( char )bsR( 8 );
return (char)bsR( 8 );
} }


private int bsGetint() private int bsGetint()
@@ -659,7 +661,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -709,7 +711,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
crcError(); crcError();


computedCombinedCRC = ( computedCombinedCRC << 1 ) computedCombinedCRC = ( computedCombinedCRC << 1 )
| ( computedCombinedCRC >>> 31 );
| ( computedCombinedCRC >>> 31 );
computedCombinedCRC ^= computedBlockCRC; computedCombinedCRC ^= computedBlockCRC;
} }


@@ -725,33 +727,33 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
pp = 0; pp = 0;
for( i = minLen; i <= maxLen; i++ ) for( i = minLen; i <= maxLen; i++ )
for( j = 0; j < alphaSize; j++ ) for( j = 0; j < alphaSize; j++ )
if( length[j] == i )
if( length[ j ] == i )
{ {
perm[pp] = j;
perm[ pp ] = j;
pp++; pp++;
} }
; ;


for( i = 0; i < MAX_CODE_LEN; i++ ) for( i = 0; i < MAX_CODE_LEN; i++ )
base[i] = 0;
base[ i ] = 0;
for( i = 0; i < alphaSize; i++ ) for( i = 0; i < alphaSize; i++ )
base[length[i] + 1]++;
base[ length[ i ] + 1 ]++;


for( i = 1; i < MAX_CODE_LEN; i++ ) for( i = 1; i < MAX_CODE_LEN; i++ )
base[i] += base[i - 1];
base[ i ] += base[ i - 1 ];


for( i = 0; i < MAX_CODE_LEN; i++ ) for( i = 0; i < MAX_CODE_LEN; i++ )
limit[i] = 0;
limit[ i ] = 0;
vec = 0; vec = 0;


for( i = minLen; i <= maxLen; i++ ) for( i = minLen; i <= maxLen; i++ )
{ {
vec += ( base[i + 1] - base[i] );
limit[i] = vec - 1;
vec += ( base[ i + 1 ] - base[ i ] );
limit[ i ] = vec - 1;
vec <<= 1; vec <<= 1;
} }
for( i = minLen + 1; i <= maxLen; i++ ) for( i = minLen + 1; i <= maxLen; i++ )
base[i] = ( ( limit[i - 1] + 1 ) << 1 ) - base[i];
base[ i ] = ( ( limit[ i - 1 ] + 1 ) << 1 ) - base[ i ];
} }


private void initBlock() private void initBlock()
@@ -769,14 +771,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
magic5 = bsGetUChar(); magic5 = bsGetUChar();
magic6 = bsGetUChar(); magic6 = bsGetUChar();
if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45
&& magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 )
&& magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 )
{ {
complete(); complete();
return; return;
} }


if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59
|| magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 )
|| magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 )
{ {
badBlockHeader(); badBlockHeader();
streamEnd = true; streamEnd = true;
@@ -819,17 +821,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
int i; int i;
nInUse = 0; nInUse = 0;
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
if( inUse[i] )
if( inUse[ i ] )
{ {
seqToUnseq[nInUse] = ( char )i;
unseqToSeq[i] = ( char )nInUse;
seqToUnseq[ nInUse ] = (char)i;
unseqToSeq[ i ] = (char)nInUse;
nInUse++; nInUse++;
} }
} }


private void recvDecodingTables() private void recvDecodingTables()
{ {
char len[][] = new char[N_GROUPS][MAX_ALPHA_SIZE];
char len[][] = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ];
int i; int i;
int j; int j;
int t; int t;
@@ -838,25 +840,25 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
int alphaSize; int alphaSize;
int minLen; int minLen;
int maxLen; int maxLen;
boolean inUse16[] = new boolean[16];
boolean inUse16[] = new boolean[ 16 ];


/* /*
* Receive the mapping table * Receive the mapping table
*/ */
for( i = 0; i < 16; i++ ) for( i = 0; i < 16; i++ )
if( bsR( 1 ) == 1 ) if( bsR( 1 ) == 1 )
inUse16[i] = true;
inUse16[ i ] = true;
else else
inUse16[i] = false;
inUse16[ i ] = false;


for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
inUse[i] = false;
inUse[ i ] = false;


for( i = 0; i < 16; i++ ) for( i = 0; i < 16; i++ )
if( inUse16[i] )
if( inUse16[ i ] )
for( j = 0; j < 16; j++ ) for( j = 0; j < 16; j++ )
if( bsR( 1 ) == 1 ) if( bsR( 1 ) == 1 )
inUse[i * 16 + j] = true;
inUse[ i * 16 + j ] = true;


makeMaps(); makeMaps();
alphaSize = nInUse + 2; alphaSize = nInUse + 2;
@@ -871,29 +873,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
j = 0; j = 0;
while( bsR( 1 ) == 1 ) while( bsR( 1 ) == 1 )
j++; j++;
selectorMtf[i] = ( char )j;
selectorMtf[ i ] = (char)j;
} }
{ {
/* /*
* Undo the MTF values for the selectors. * Undo the MTF values for the selectors.
*/ */
char pos[] = new char[N_GROUPS];
char pos[] = new char[ N_GROUPS ];
char tmp; char tmp;
char v; char v;
for( v = 0; v < nGroups; v++ ) for( v = 0; v < nGroups; v++ )
pos[v] = v;
pos[ v ] = v;


for( i = 0; i < nSelectors; i++ ) for( i = 0; i < nSelectors; i++ )
{ {
v = selectorMtf[i];
tmp = pos[v];
v = selectorMtf[ i ];
tmp = pos[ v ];
while( v > 0 ) while( v > 0 )
{ {
pos[v] = pos[v - 1];
pos[ v ] = pos[ v - 1 ];
v--; v--;
} }
pos[0] = tmp;
selector[i] = tmp;
pos[ 0 ] = tmp;
selector[ i ] = tmp;
} }
} }


@@ -912,7 +914,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
else else
curr--; curr--;
} }
len[t][i] = ( char )curr;
len[ t ][ i ] = (char)curr;
} }
} }


@@ -925,14 +927,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
maxLen = 0; maxLen = 0;
for( i = 0; i < alphaSize; i++ ) for( i = 0; i < alphaSize; i++ )
{ {
if( len[t][i] > maxLen )
maxLen = len[t][i];
if( len[t][i] < minLen )
minLen = len[t][i];
if( len[ t ][ i ] > maxLen )
maxLen = len[ t ][ i ];
if( len[ t ][ i ] < minLen )
minLen = len[ t ][ i ];
} }
hbCreateDecodeTables( limit[t], base[t], perm[t], len[t], minLen,
maxLen, alphaSize );
minLens[t] = minLen;
hbCreateDecodeTables( limit[ t ], base[ t ], perm[ t ], len[ t ], minLen,
maxLen, alphaSize );
minLens[ t ] = minLen;
} }
} }
} }


+ 331
- 329
proposal/myrmidon/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java
File diff suppressed because it is too large
View File


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/bzip2/CRC.java View File

@@ -80,7 +80,7 @@ class CRC
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
};


int globalCrc; int globalCrc;


@@ -114,7 +114,7 @@ class CRC
int temp = ( globalCrc >> 24 ) ^ inCh; int temp = ( globalCrc >> 24 ) ^ inCh;
if( temp < 0 ) if( temp < 0 )
temp = 256 + temp; temp = 256 + temp;
globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[temp];
globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[ temp ];
} }
} }



+ 9
- 7
proposal/myrmidon/src/main/org/apache/tools/mail/MailMessage.java View File

@@ -6,16 +6,17 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.mail; package org.apache.tools.mail;

import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;


/** /**
* A class to help send SMTP email. This class is an improvement on the * A class to help send SMTP email. This class is an improvement on the
@@ -348,7 +349,7 @@ public class MailMessage
// Check that the response is one of the valid codes // Check that the response is one of the valid codes
for( int i = 0; i < ok.length; i++ ) for( int i = 0; i < ok.length; i++ )
{ {
if( response.startsWith( "" + ok[i] ) )
if( response.startsWith( "" + ok[ i ] ) )
{ {
return true; return true;
} }
@@ -364,7 +365,7 @@ public class MailMessage
socket = new Socket( host, port ); socket = new Socket( host, port );
out = new MailPrintStream( out = new MailPrintStream(
new BufferedOutputStream( new BufferedOutputStream(
socket.getOutputStream() ) );
socket.getOutputStream() ) );
in = new SmtpResponseReader( socket.getInputStream() ); in = new SmtpResponseReader( socket.getInputStream() );
getReady(); getReady();
} }
@@ -387,8 +388,8 @@ public class MailMessage
Enumeration e = headers.keys(); Enumeration e = headers.keys();
while( e.hasMoreElements() ) while( e.hasMoreElements() )
{ {
String name = ( String )e.nextElement();
String value = ( String )headers.get( name );
String name = (String)e.nextElement();
String value = (String)headers.get( name );
out.println( name + ": " + value ); out.println( name + ": " + value );
} }
out.println(); out.println();
@@ -471,6 +472,7 @@ public class MailMessage
// This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>.. // This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>..
// per RFC 821. It also ensures that new lines are always \r\n. // per RFC 821. It also ensures that new lines are always \r\n.
// //

class MailPrintStream extends PrintStream class MailPrintStream extends PrintStream
{ {


@@ -506,7 +508,7 @@ class MailPrintStream extends PrintStream
{ {
for( int i = 0; i < len; i++ ) for( int i = 0; i < len; i++ )
{ {
write( buf[off + i] );
write( buf[ off + i ] );
} }
} }




+ 1
- 0
proposal/myrmidon/src/main/org/apache/tools/mail/SmtpResponseReader.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.mail; package org.apache.tools.mail;

import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


+ 24
- 23
proposal/myrmidon/src/main/org/apache/tools/tar/TarBuffer.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@@ -137,7 +138,7 @@ public class TarBuffer
{ {
for( int i = 0, sz = this.getRecordSize(); i < sz; ++i ) for( int i = 0, sz = this.getRecordSize(); i < sz; ++i )
{ {
if( record[i] != 0 )
if( record[ i ] != 0 )
{ {
return false; return false;
} }
@@ -165,7 +166,7 @@ public class TarBuffer
this.flushBlock(); this.flushBlock();


if( this.outStream != System.out if( this.outStream != System.out
&& this.outStream != System.err )
&& this.outStream != System.err )
{ {
this.outStream.close(); this.outStream.close();


@@ -195,7 +196,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "ReadRecord: recIdx = " + this.currRecIdx System.err.println( "ReadRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.inStream == null ) if( this.inStream == null )
@@ -211,11 +212,11 @@ public class TarBuffer
} }
} }


byte[] result = new byte[this.recordSize];
byte[] result = new byte[ this.recordSize ];


System.arraycopy( this.blockBuffer, System.arraycopy( this.blockBuffer,
( this.currRecIdx * this.recordSize ), result, 0,
this.recordSize );
( this.currRecIdx * this.recordSize ), result, 0,
this.recordSize );


this.currRecIdx++; this.currRecIdx++;


@@ -233,7 +234,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "SkipRecord: recIdx = " + this.currRecIdx System.err.println( "SkipRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.inStream == null ) if( this.inStream == null )
@@ -264,7 +265,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "WriteRecord: recIdx = " + this.currRecIdx System.err.println( "WriteRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.outStream == null ) if( this.outStream == null )
@@ -275,9 +276,9 @@ public class TarBuffer
if( record.length != this.recordSize ) if( record.length != this.recordSize )
{ {
throw new IOException( "record to write has length '" throw new IOException( "record to write has length '"
+ record.length
+ "' which is not the record size of '"
+ this.recordSize + "'" );
+ record.length
+ "' which is not the record size of '"
+ this.recordSize + "'" );
} }


if( this.currRecIdx >= this.recsPerBlock ) if( this.currRecIdx >= this.recsPerBlock )
@@ -286,8 +287,8 @@ public class TarBuffer
} }


System.arraycopy( record, 0, this.blockBuffer, System.arraycopy( record, 0, this.blockBuffer,
( this.currRecIdx * this.recordSize ),
this.recordSize );
( this.currRecIdx * this.recordSize ),
this.recordSize );


this.currRecIdx++; this.currRecIdx++;
} }
@@ -306,7 +307,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "WriteRecord: recIdx = " + this.currRecIdx System.err.println( "WriteRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.outStream == null ) if( this.outStream == null )
@@ -317,9 +318,9 @@ public class TarBuffer
if( ( offset + this.recordSize ) > buf.length ) if( ( offset + this.recordSize ) > buf.length )
{ {
throw new IOException( "record has length '" + buf.length throw new IOException( "record has length '" + buf.length
+ "' with offset '" + offset
+ "' which is less than the record size of '"
+ this.recordSize + "'" );
+ "' with offset '" + offset
+ "' which is less than the record size of '"
+ this.recordSize + "'" );
} }


if( this.currRecIdx >= this.recsPerBlock ) if( this.currRecIdx >= this.recsPerBlock )
@@ -328,8 +329,8 @@ public class TarBuffer
} }


System.arraycopy( buf, offset, this.blockBuffer, System.arraycopy( buf, offset, this.blockBuffer,
( this.currRecIdx * this.recordSize ),
this.recordSize );
( this.currRecIdx * this.recordSize ),
this.recordSize );


this.currRecIdx++; this.currRecIdx++;
} }
@@ -370,7 +371,7 @@ public class TarBuffer
this.blockSize = blockSize; this.blockSize = blockSize;
this.recordSize = recordSize; this.recordSize = recordSize;
this.recsPerBlock = ( this.blockSize / this.recordSize ); this.recsPerBlock = ( this.blockSize / this.recordSize );
this.blockBuffer = new byte[this.blockSize];
this.blockBuffer = new byte[ this.blockSize ];


if( this.inStream != null ) if( this.inStream != null )
{ {
@@ -409,7 +410,7 @@ public class TarBuffer
while( bytesNeeded > 0 ) while( bytesNeeded > 0 )
{ {
long numBytes = this.inStream.read( this.blockBuffer, offset, long numBytes = this.inStream.read( this.blockBuffer, offset,
bytesNeeded );
bytesNeeded );


// //
// NOTE // NOTE
@@ -437,8 +438,8 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "ReadBlock: INCOMPLETE READ " System.err.println( "ReadBlock: INCOMPLETE READ "
+ numBytes + " of " + this.blockSize
+ " bytes read." );
+ numBytes + " of " + this.blockSize
+ " bytes read." );
} }
} }
} }


+ 9
- 9
proposal/myrmidon/src/main/org/apache/tools/tar/TarConstants.java View File

@@ -82,42 +82,42 @@ public interface TarConstants
/** /**
* Normal file type. * Normal file type.
*/ */
byte LF_NORMAL = ( byte )'0';
byte LF_NORMAL = (byte)'0';


/** /**
* Link file type. * Link file type.
*/ */
byte LF_LINK = ( byte )'1';
byte LF_LINK = (byte)'1';


/** /**
* Symbolic link file type. * Symbolic link file type.
*/ */
byte LF_SYMLINK = ( byte )'2';
byte LF_SYMLINK = (byte)'2';


/** /**
* Character device file type. * Character device file type.
*/ */
byte LF_CHR = ( byte )'3';
byte LF_CHR = (byte)'3';


/** /**
* Block device file type. * Block device file type.
*/ */
byte LF_BLK = ( byte )'4';
byte LF_BLK = (byte)'4';


/** /**
* Directory file type. * Directory file type.
*/ */
byte LF_DIR = ( byte )'5';
byte LF_DIR = (byte)'5';


/** /**
* FIFO (pipe) file type. * FIFO (pipe) file type.
*/ */
byte LF_FIFO = ( byte )'6';
byte LF_FIFO = (byte)'6';


/** /**
* Contiguous file type. * Contiguous file type.
*/ */
byte LF_CONTIG = ( byte )'7';
byte LF_CONTIG = (byte)'7';


/** /**
* The magic tag representing a POSIX tar archive. * The magic tag representing a POSIX tar archive.
@@ -137,5 +137,5 @@ public interface TarConstants
/** /**
* Identifies the *next* file on the tape as having a long name. * Identifies the *next* file on the tape as having a long name.
*/ */
byte LF_GNUTYPE_LONGNAME = ( byte )'L';
byte LF_GNUTYPE_LONGNAME = (byte)'L';
} }

+ 16
- 17
proposal/myrmidon/src/main/org/apache/tools/tar/TarEntry.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;


@@ -190,8 +191,8 @@ public class TarEntry implements TarConstants
char ch2 = name.charAt( 1 ); char ch2 = name.charAt( 1 );


if( ch2 == ':' if( ch2 == ':'
&& ( ( ch1 >= 'a' && ch1 <= 'z' )
|| ( ch1 >= 'A' && ch1 <= 'Z' ) ) )
&& ( ( ch1 >= 'a' && ch1 <= 'z' )
|| ( ch1 >= 'A' && ch1 <= 'Z' ) ) )
{ {
name = name.substring( 2 ); name = name.substring( 2 );
} }
@@ -406,15 +407,15 @@ public class TarEntry implements TarConstants
{ {
if( this.file == null || !this.file.isDirectory() ) if( this.file == null || !this.file.isDirectory() )
{ {
return new TarEntry[0];
return new TarEntry[ 0 ];
} }


String[] list = this.file.list(); String[] list = this.file.list();
TarEntry[] result = new TarEntry[list.length];
TarEntry[] result = new TarEntry[ list.length ];


for( int i = 0; i < list.length; ++i ) for( int i = 0; i < list.length; ++i )
{ {
result[i] = new TarEntry( new File( this.file, list[i] ) );
result[ i ] = new TarEntry( new File( this.file, list[ i ] ) );
} }


return result; return result;
@@ -490,7 +491,6 @@ public class TarEntry implements TarConstants
return this.size; return this.size;
} }



/** /**
* Get this entry's user id. * Get this entry's user id.
* *
@@ -549,7 +549,6 @@ public class TarEntry implements TarConstants
return false; return false;
} }



/** /**
* Indicate if this entry is a GNU long name block * Indicate if this entry is a GNU long name block
* *
@@ -585,19 +584,19 @@ public class TarEntry implements TarConstants


this.name = TarUtils.parseName( header, offset, NAMELEN ); this.name = TarUtils.parseName( header, offset, NAMELEN );
offset += NAMELEN; offset += NAMELEN;
this.mode = ( int )TarUtils.parseOctal( header, offset, MODELEN );
this.mode = (int)TarUtils.parseOctal( header, offset, MODELEN );
offset += MODELEN; offset += MODELEN;
this.userId = ( int )TarUtils.parseOctal( header, offset, UIDLEN );
this.userId = (int)TarUtils.parseOctal( header, offset, UIDLEN );
offset += UIDLEN; offset += UIDLEN;
this.groupId = ( int )TarUtils.parseOctal( header, offset, GIDLEN );
this.groupId = (int)TarUtils.parseOctal( header, offset, GIDLEN );
offset += GIDLEN; offset += GIDLEN;
this.size = TarUtils.parseOctal( header, offset, SIZELEN ); this.size = TarUtils.parseOctal( header, offset, SIZELEN );
offset += SIZELEN; offset += SIZELEN;
this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN ); this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN );
offset += MODTIMELEN; offset += MODTIMELEN;
this.checkSum = ( int )TarUtils.parseOctal( header, offset, CHKSUMLEN );
this.checkSum = (int)TarUtils.parseOctal( header, offset, CHKSUMLEN );
offset += CHKSUMLEN; offset += CHKSUMLEN;
this.linkFlag = header[offset++];
this.linkFlag = header[ offset++ ];
this.linkName = TarUtils.parseName( header, offset, NAMELEN ); this.linkName = TarUtils.parseName( header, offset, NAMELEN );
offset += NAMELEN; offset += NAMELEN;
this.magic = TarUtils.parseName( header, offset, MAGICLEN ); this.magic = TarUtils.parseName( header, offset, MAGICLEN );
@@ -606,9 +605,9 @@ public class TarEntry implements TarConstants
offset += UNAMELEN; offset += UNAMELEN;
this.groupName = TarUtils.parseName( header, offset, GNAMELEN ); this.groupName = TarUtils.parseName( header, offset, GNAMELEN );
offset += GNAMELEN; offset += GNAMELEN;
this.devMajor = ( int )TarUtils.parseOctal( header, offset, DEVLEN );
this.devMajor = (int)TarUtils.parseOctal( header, offset, DEVLEN );
offset += DEVLEN; offset += DEVLEN;
this.devMinor = ( int )TarUtils.parseOctal( header, offset, DEVLEN );
this.devMinor = (int)TarUtils.parseOctal( header, offset, DEVLEN );
} }


/** /**
@@ -631,10 +630,10 @@ public class TarEntry implements TarConstants


for( int c = 0; c < CHKSUMLEN; ++c ) for( int c = 0; c < CHKSUMLEN; ++c )
{ {
outbuf[offset++] = ( byte )' ';
outbuf[ offset++ ] = (byte)' ';
} }


outbuf[offset++] = this.linkFlag;
outbuf[ offset++ ] = this.linkFlag;
offset = TarUtils.getNameBytes( this.linkName, outbuf, offset, NAMELEN ); offset = TarUtils.getNameBytes( this.linkName, outbuf, offset, NAMELEN );
offset = TarUtils.getNameBytes( this.magic, outbuf, offset, MAGICLEN ); offset = TarUtils.getNameBytes( this.magic, outbuf, offset, MAGICLEN );
offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN ); offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN );
@@ -644,7 +643,7 @@ public class TarEntry implements TarConstants


while( offset < outbuf.length ) while( offset < outbuf.length )
{ {
outbuf[offset++] = 0;
outbuf[ offset++ ] = 0;
} }


long checkSum = TarUtils.computeCheckSum( outbuf ); long checkSum = TarUtils.computeCheckSum( outbuf );


+ 50
- 45
proposal/myrmidon/src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -48,7 +49,7 @@ public class TarInputStream extends FilterInputStream


this.buffer = new TarBuffer( is, blockSize, recordSize ); this.buffer = new TarBuffer( is, blockSize, recordSize );
this.readBuf = null; this.readBuf = null;
this.oneBuf = new byte[1];
this.oneBuf = new byte[ 1 ];
this.debug = false; this.debug = false;
this.hasHitEOF = false; this.hasHitEOF = false;
} }
@@ -90,10 +91,10 @@ public class TarInputStream extends FilterInputStream
if( this.debug ) if( this.debug )
{ {
System.err.println( "TarInputStream: SKIP currENTRY '" System.err.println( "TarInputStream: SKIP currENTRY '"
+ this.currEntry.getName() + "' SZ "
+ this.entrySize + " OFF "
+ this.entryOffset + " skipping "
+ numToSkip + " bytes" );
+ this.currEntry.getName() + "' SZ "
+ this.entrySize + " OFF "
+ this.entryOffset + " skipping "
+ numToSkip + " bytes" );
} }


if( numToSkip > 0 ) if( numToSkip > 0 )
@@ -131,56 +132,56 @@ public class TarInputStream extends FilterInputStream
{ {
this.currEntry = new TarEntry( headerBuf ); this.currEntry = new TarEntry( headerBuf );


if( !( headerBuf[257] == 'u' && headerBuf[258] == 's'
&& headerBuf[259] == 't' && headerBuf[260] == 'a'
&& headerBuf[261] == 'r' ) )
if( !( headerBuf[ 257 ] == 'u' && headerBuf[ 258 ] == 's'
&& headerBuf[ 259 ] == 't' && headerBuf[ 260 ] == 'a'
&& headerBuf[ 261 ] == 'r' ) )
{ {
this.entrySize = 0; this.entrySize = 0;
this.entryOffset = 0; this.entryOffset = 0;
this.currEntry = null; this.currEntry = null;


throw new IOException( "bad header in block " throw new IOException( "bad header in block "
+ this.buffer.getCurrentBlockNum()
+ " record "
+ this.buffer.getCurrentRecordNum()
+ ", " +
"header magic is not 'ustar', but '"
+ headerBuf[257]
+ headerBuf[258]
+ headerBuf[259]
+ headerBuf[260]
+ headerBuf[261]
+ "', or (dec) "
+ ( ( int )headerBuf[257] )
+ ", "
+ ( ( int )headerBuf[258] )
+ ", "
+ ( ( int )headerBuf[259] )
+ ", "
+ ( ( int )headerBuf[260] )
+ ", "
+ ( ( int )headerBuf[261] ) );
+ this.buffer.getCurrentBlockNum()
+ " record "
+ this.buffer.getCurrentRecordNum()
+ ", " +
"header magic is not 'ustar', but '"
+ headerBuf[ 257 ]
+ headerBuf[ 258 ]
+ headerBuf[ 259 ]
+ headerBuf[ 260 ]
+ headerBuf[ 261 ]
+ "', or (dec) "
+ ( (int)headerBuf[ 257 ] )
+ ", "
+ ( (int)headerBuf[ 258 ] )
+ ", "
+ ( (int)headerBuf[ 259 ] )
+ ", "
+ ( (int)headerBuf[ 260 ] )
+ ", "
+ ( (int)headerBuf[ 261 ] ) );
} }


if( this.debug ) if( this.debug )
{ {
System.err.println( "TarInputStream: SET CURRENTRY '" System.err.println( "TarInputStream: SET CURRENTRY '"
+ this.currEntry.getName()
+ "' size = "
+ this.currEntry.getSize() );
+ this.currEntry.getName()
+ "' size = "
+ this.currEntry.getSize() );
} }


this.entryOffset = 0; this.entryOffset = 0;


// REVIEW How do we resolve this discrepancy?! // REVIEW How do we resolve this discrepancy?!
this.entrySize = ( int )this.currEntry.getSize();
this.entrySize = (int)this.currEntry.getSize();
} }


if( this.currEntry != null && this.currEntry.isGNULongNameEntry() ) if( this.currEntry != null && this.currEntry.isGNULongNameEntry() )
{ {
// read in the name // read in the name
StringBuffer longName = new StringBuffer(); StringBuffer longName = new StringBuffer();
byte[] buffer = new byte[256];
byte[] buffer = new byte[ 256 ];
int length = 0; int length = 0;
while( ( length = read( buffer ) ) >= 0 ) while( ( length = read( buffer ) ) >= 0 )
{ {
@@ -240,7 +241,7 @@ public class TarInputStream extends FilterInputStream
public void copyEntryContents( OutputStream out ) public void copyEntryContents( OutputStream out )
throws IOException throws IOException
{ {
byte[] buf = new byte[32 * 1024];
byte[] buf = new byte[ 32 * 1024 ];


while( true ) while( true )
{ {
@@ -260,7 +261,9 @@ public class TarInputStream extends FilterInputStream
* *
* @param markLimit The limit to mark. * @param markLimit The limit to mark.
*/ */
public void mark( int markLimit ) { }
public void mark( int markLimit )
{
}


/** /**
* Since we do not support marking just yet, we return false. * Since we do not support marking just yet, we return false.
@@ -290,7 +293,7 @@ public class TarInputStream extends FilterInputStream
} }
else else
{ {
return ( int )this.oneBuf[0];
return (int)this.oneBuf[ 0 ];
} }
} }


@@ -337,7 +340,7 @@ public class TarInputStream extends FilterInputStream
if( this.readBuf != null ) if( this.readBuf != null )
{ {
int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length
: numToRead;
: numToRead;


System.arraycopy( this.readBuf, 0, buf, offset, sz ); System.arraycopy( this.readBuf, 0, buf, offset, sz );


@@ -348,7 +351,7 @@ public class TarInputStream extends FilterInputStream
else else
{ {
int newLen = this.readBuf.length - sz; int newLen = this.readBuf.length - sz;
byte[] newBuf = new byte[newLen];
byte[] newBuf = new byte[ newLen ];


System.arraycopy( this.readBuf, sz, newBuf, 0, newLen ); System.arraycopy( this.readBuf, sz, newBuf, 0, newLen );


@@ -368,7 +371,7 @@ public class TarInputStream extends FilterInputStream
{ {
// Unexpected EOF! // Unexpected EOF!
throw new IOException( "unexpected EOF with " + numToRead throw new IOException( "unexpected EOF with " + numToRead
+ " bytes unread" );
+ " bytes unread" );
} }


int sz = numToRead; int sz = numToRead;
@@ -378,7 +381,7 @@ public class TarInputStream extends FilterInputStream
{ {
System.arraycopy( rec, 0, buf, offset, sz ); System.arraycopy( rec, 0, buf, offset, sz );


this.readBuf = new byte[recLen - sz];
this.readBuf = new byte[ recLen - sz ];


System.arraycopy( rec, sz, this.readBuf, 0, recLen - sz ); System.arraycopy( rec, sz, this.readBuf, 0, recLen - sz );
} }
@@ -402,7 +405,9 @@ public class TarInputStream extends FilterInputStream
/** /**
* Since we do not support marking just yet, we do nothing. * Since we do not support marking just yet, we do nothing.
*/ */
public void reset() { }
public void reset()
{
}


/** /**
* Skip bytes in the input buffer. This skips bytes in the current entry's * Skip bytes in the input buffer. This skips bytes in the current entry's
@@ -420,13 +425,13 @@ public class TarInputStream extends FilterInputStream
// This is horribly inefficient, but it ensures that we // This is horribly inefficient, but it ensures that we
// properly skip over bytes via the TarBuffer... // properly skip over bytes via the TarBuffer...
// //
byte[] skipBuf = new byte[8 * 1024];
byte[] skipBuf = new byte[ 8 * 1024 ];


for( int num = numToSkip; num > 0; )
for( int num = numToSkip; num > 0; )
{ {
int numRead = this.read( skipBuf, 0, int numRead = this.read( skipBuf, 0,
( num > skipBuf.length ? skipBuf.length
: num ) );
( num > skipBuf.length ? skipBuf.length
: num ) );


if( numRead == -1 ) if( numRead == -1 )
{ {


+ 19
- 19
proposal/myrmidon/src/main/org/apache/tools/tar/TarOutputStream.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.FilterOutputStream; import java.io.FilterOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@@ -50,9 +51,9 @@ public class TarOutputStream extends FilterOutputStream
this.buffer = new TarBuffer( os, blockSize, recordSize ); this.buffer = new TarBuffer( os, blockSize, recordSize );
this.debug = false; this.debug = false;
this.assemLen = 0; this.assemLen = 0;
this.assemBuf = new byte[recordSize];
this.recordBuf = new byte[recordSize];
this.oneBuf = new byte[1];
this.assemBuf = new byte[ recordSize ];
this.recordBuf = new byte[ recordSize ];
this.oneBuf = new byte[ 1 ];
} }


/** /**
@@ -65,7 +66,6 @@ public class TarOutputStream extends FilterOutputStream
this.buffer.setDebug( debug ); this.buffer.setDebug( debug );
} }



/** /**
* Sets the debugging flag. * Sets the debugging flag.
* *
@@ -120,7 +120,7 @@ public class TarOutputStream extends FilterOutputStream
{ {
for( int i = this.assemLen; i < this.assemBuf.length; ++i ) for( int i = this.assemLen; i < this.assemBuf.length; ++i )
{ {
this.assemBuf[i] = 0;
this.assemBuf[ i ] = 0;
} }


this.buffer.writeRecord( this.assemBuf ); this.buffer.writeRecord( this.assemBuf );
@@ -132,8 +132,8 @@ public class TarOutputStream extends FilterOutputStream
if( this.currBytes < this.currSize ) if( this.currBytes < this.currSize )
{ {
throw new IOException( "entry closed at '" + this.currBytes throw new IOException( "entry closed at '" + this.currBytes
+ "' before the '" + this.currSize
+ "' bytes specified in the header were written" );
+ "' before the '" + this.currSize
+ "' bytes specified in the header were written" );
} }
} }


@@ -171,7 +171,7 @@ public class TarOutputStream extends FilterOutputStream
// create a TarEntry for the LongLink, the contents // create a TarEntry for the LongLink, the contents
// of which are the entry's name // of which are the entry's name
TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK, TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK,
TarConstants.LF_GNUTYPE_LONGNAME );
TarConstants.LF_GNUTYPE_LONGNAME );


longLinkEntry.setSize( entry.getName().length() + 1 ); longLinkEntry.setSize( entry.getName().length() + 1 );
putNextEntry( longLinkEntry ); putNextEntry( longLinkEntry );
@@ -182,8 +182,8 @@ public class TarOutputStream extends FilterOutputStream
else if( longFileMode != LONGFILE_TRUNCATE ) else if( longFileMode != LONGFILE_TRUNCATE )
{ {
throw new RuntimeException( "file name '" + entry.getName() throw new RuntimeException( "file name '" + entry.getName()
+ "' is too long ( > "
+ TarConstants.NAMELEN + " bytes)" );
+ "' is too long ( > "
+ TarConstants.NAMELEN + " bytes)" );
} }
} }


@@ -198,7 +198,7 @@ public class TarOutputStream extends FilterOutputStream
} }
else else
{ {
this.currSize = ( int )entry.getSize();
this.currSize = (int)entry.getSize();
} }
} }


@@ -212,7 +212,7 @@ public class TarOutputStream extends FilterOutputStream
public void write( int b ) public void write( int b )
throws IOException throws IOException
{ {
this.oneBuf[0] = ( byte )b;
this.oneBuf[ 0 ] = (byte)b;


this.write( this.oneBuf, 0, 1 ); this.write( this.oneBuf, 0, 1 );
} }
@@ -249,8 +249,8 @@ public class TarOutputStream extends FilterOutputStream
if( ( this.currBytes + numToWrite ) > this.currSize ) if( ( this.currBytes + numToWrite ) > this.currSize )
{ {
throw new IOException( "request to write '" + numToWrite throw new IOException( "request to write '" + numToWrite
+ "' bytes exceeds size in header of '"
+ this.currSize + "' bytes" );
+ "' bytes exceeds size in header of '"
+ this.currSize + "' bytes" );
// //
// We have to deal with assembly!!! // We have to deal with assembly!!!
// The programmer can be writing little 32 byte chunks for all // The programmer can be writing little 32 byte chunks for all
@@ -267,9 +267,9 @@ public class TarOutputStream extends FilterOutputStream
int aLen = this.recordBuf.length - this.assemLen; int aLen = this.recordBuf.length - this.assemLen;


System.arraycopy( this.assemBuf, 0, this.recordBuf, 0, System.arraycopy( this.assemBuf, 0, this.recordBuf, 0,
this.assemLen );
this.assemLen );
System.arraycopy( wBuf, wOffset, this.recordBuf, System.arraycopy( wBuf, wOffset, this.recordBuf,
this.assemLen, aLen );
this.assemLen, aLen );
this.buffer.writeRecord( this.recordBuf ); this.buffer.writeRecord( this.recordBuf );


this.currBytes += this.recordBuf.length; this.currBytes += this.recordBuf.length;
@@ -280,7 +280,7 @@ public class TarOutputStream extends FilterOutputStream
else else
{ {
System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen,
numToWrite );
numToWrite );


wOffset += numToWrite; wOffset += numToWrite;
this.assemLen += numToWrite; this.assemLen += numToWrite;
@@ -298,7 +298,7 @@ public class TarOutputStream extends FilterOutputStream
if( numToWrite < this.recordBuf.length ) if( numToWrite < this.recordBuf.length )
{ {
System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen,
numToWrite );
numToWrite );


this.assemLen += numToWrite; this.assemLen += numToWrite;


@@ -326,7 +326,7 @@ public class TarOutputStream extends FilterOutputStream
{ {
for( int i = 0; i < this.recordBuf.length; ++i ) for( int i = 0; i < this.recordBuf.length; ++i )
{ {
this.recordBuf[i] = 0;
this.recordBuf[ i ] = 0;
} }


this.buffer.writeRecord( this.recordBuf ); this.buffer.writeRecord( this.recordBuf );


+ 18
- 18
proposal/myrmidon/src/main/org/apache/tools/tar/TarUtils.java View File

@@ -30,8 +30,8 @@ public class TarUtils
{ {
getOctalBytes( value, buf, offset, length ); getOctalBytes( value, buf, offset, length );


buf[offset + length - 1] = ( byte )' ';
buf[offset + length - 2] = 0;
buf[ offset + length - 1 ] = (byte)' ';
buf[ offset + length - 2 ] = 0;


return offset + length; return offset + length;
} }
@@ -47,7 +47,7 @@ public class TarUtils
*/ */
public static int getLongOctalBytes( long value, byte[] buf, int offset, int length ) public static int getLongOctalBytes( long value, byte[] buf, int offset, int length )
{ {
byte[] temp = new byte[length + 1];
byte[] temp = new byte[ length + 1 ];


getOctalBytes( value, temp, 0, length + 1 ); getOctalBytes( value, temp, 0, length + 1 );
System.arraycopy( temp, 0, buf, offset, length ); System.arraycopy( temp, 0, buf, offset, length );
@@ -70,12 +70,12 @@ public class TarUtils


for( i = 0; i < length && i < name.length(); ++i ) for( i = 0; i < length && i < name.length(); ++i )
{ {
buf[offset + i] = ( byte )name.charAt( i );
buf[ offset + i ] = (byte)name.charAt( i );
} }


for( ; i < length; ++i ) for( ; i < length; ++i )
{ {
buf[offset + i] = 0;
buf[ offset + i ] = 0;
} }


return offset + length; return offset + length;
@@ -92,31 +92,31 @@ public class TarUtils
*/ */
public static int getOctalBytes( long value, byte[] buf, int offset, int length ) public static int getOctalBytes( long value, byte[] buf, int offset, int length )
{ {
byte[] result = new byte[length];
byte[] result = new byte[ length ];
int idx = length - 1; int idx = length - 1;


buf[offset + idx] = 0;
buf[ offset + idx ] = 0;
--idx; --idx;
buf[offset + idx] = ( byte )' ';
buf[ offset + idx ] = (byte)' ';
--idx; --idx;


if( value == 0 ) if( value == 0 )
{ {
buf[offset + idx] = ( byte )'0';
buf[ offset + idx ] = (byte)'0';
--idx; --idx;
} }
else else
{ {
for( long val = value; idx >= 0 && val > 0; --idx ) for( long val = value; idx >= 0 && val > 0; --idx )
{ {
buf[offset + idx] = ( byte )( ( byte )'0' + ( byte )( val & 7 ) );
buf[ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
val = val >> 3; val = val >> 3;
} }
} }


for( ; idx >= 0; --idx ) for( ; idx >= 0; --idx )
{ {
buf[offset + idx] = ( byte )' ';
buf[ offset + idx ] = (byte)' ';
} }


return offset + length; return offset + length;
@@ -134,7 +134,7 @@ public class TarUtils


for( int i = 0; i < buf.length; ++i ) for( int i = 0; i < buf.length; ++i )
{ {
sum += 255 & buf[i];
sum += 255 & buf[ i ];
} }


return sum; return sum;
@@ -155,12 +155,12 @@ public class TarUtils


for( int i = offset; i < end; ++i ) for( int i = offset; i < end; ++i )
{ {
if( header[i] == 0 )
if( header[ i ] == 0 )
{ {
break; break;
} }


result.append( ( char )header[i] );
result.append( (char)header[ i ] );
} }


return result; return result;
@@ -183,26 +183,26 @@ public class TarUtils


for( int i = offset; i < end; ++i ) for( int i = offset; i < end; ++i )
{ {
if( header[i] == 0 )
if( header[ i ] == 0 )
{ {
break; break;
} }


if( header[i] == ( byte )' ' || header[i] == '0' )
if( header[ i ] == (byte)' ' || header[ i ] == '0' )
{ {
if( stillPadding ) if( stillPadding )
{ {
continue; continue;
} }


if( header[i] == ( byte )' ' )
if( header[ i ] == (byte)' ' )
{ {
break; break;
} }
} }


stillPadding = false; stillPadding = false;
result = ( result << 3 ) + ( header[i] - '0' );
result = ( result << 3 ) + ( header[ i ] - '0' );
} }


return result; return result;


+ 19
- 16
proposal/myrmidon/src/main/org/apache/tools/zip/AsiExtraField.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.util.zip.CRC32; import java.util.zip.CRC32;
import java.util.zip.ZipException; import java.util.zip.ZipException;


@@ -79,7 +80,9 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
*/ */
private CRC32 crc = new CRC32(); private CRC32 crc = new CRC32();


public AsiExtraField() { }
public AsiExtraField()
{
}


/** /**
* Indicate whether this entry is a directory. * Indicate whether this entry is a directory.
@@ -205,17 +208,17 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
public byte[] getLocalFileDataData() public byte[] getLocalFileDataData()
{ {
// CRC will be added later // CRC will be added later
byte[] data = new byte[getLocalFileDataLength().getValue() - 4];
byte[] data = new byte[ getLocalFileDataLength().getValue() - 4 ];
System.arraycopy( ( new ZipShort( getMode() ) ).getBytes(), 0, data, 0, 2 ); System.arraycopy( ( new ZipShort( getMode() ) ).getBytes(), 0, data, 0, 2 );


byte[] linkArray = getLinkedFile().getBytes(); byte[] linkArray = getLinkedFile().getBytes();
System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(), System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(),
0, data, 2, 4 );
0, data, 2, 4 );


System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(), System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(),
0, data, 6, 2 );
0, data, 6, 2 );
System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(), System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(),
0, data, 8, 2 );
0, data, 8, 2 );


System.arraycopy( linkArray, 0, data, 10, linkArray.length ); System.arraycopy( linkArray, 0, data, 10, linkArray.length );


@@ -223,7 +226,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
crc.update( data ); crc.update( data );
long checksum = crc.getValue(); long checksum = crc.getValue();


byte[] result = new byte[data.length + 4];
byte[] result = new byte[ data.length + 4 ];
System.arraycopy( ( new ZipLong( checksum ) ).getBytes(), 0, result, 0, 4 ); System.arraycopy( ( new ZipLong( checksum ) ).getBytes(), 0, result, 0, 4 );
System.arraycopy( data, 0, result, 4, data.length ); System.arraycopy( data, 0, result, 4, data.length );
return result; return result;
@@ -239,11 +242,11 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
public ZipShort getLocalFileDataLength() public ZipShort getLocalFileDataLength()
{ {
return new ZipShort( 4// CRC return new ZipShort( 4// CRC
+ 2// Mode
+ 4// SizDev
+ 2// UID
+ 2// GID
+ getLinkedFile().getBytes().length );
+ 2// Mode
+ 4// SizDev
+ 2// UID
+ 2// GID
+ getLinkedFile().getBytes().length );
} }


/** /**
@@ -304,7 +307,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
{ {


long givenChecksum = ( new ZipLong( data, offset ) ).getValue(); long givenChecksum = ( new ZipLong( data, offset ) ).getValue();
byte[] tmp = new byte[length - 4];
byte[] tmp = new byte[ length - 4 ];
System.arraycopy( data, offset + 4, tmp, 0, length - 4 ); System.arraycopy( data, offset + 4, tmp, 0, length - 4 );
crc.reset(); crc.reset();
crc.update( tmp ); crc.update( tmp );
@@ -312,13 +315,13 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
if( givenChecksum != realChecksum ) if( givenChecksum != realChecksum )
{ {
throw new ZipException( "bad CRC checksum " throw new ZipException( "bad CRC checksum "
+ Long.toHexString( givenChecksum )
+ " instead of "
+ Long.toHexString( realChecksum ) );
+ Long.toHexString( givenChecksum )
+ " instead of "
+ Long.toHexString( realChecksum ) );
} }


int newMode = ( new ZipShort( tmp, 0 ) ).getValue(); int newMode = ( new ZipShort( tmp, 0 ) ).getValue();
byte[] linkArray = new byte[( int )( new ZipLong( tmp, 2 ) ).getValue()];
byte[] linkArray = new byte[ (int)( new ZipLong( tmp, 2 ) ).getValue() ];
uid = ( new ZipShort( tmp, 6 ) ).getValue(); uid = ( new ZipShort( tmp, 6 ) ).getValue();
gid = ( new ZipShort( tmp, 8 ) ).getValue(); gid = ( new ZipShort( tmp, 8 ) ).getValue();




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/zip/UnrecognizedExtraField.java View File

@@ -92,7 +92,7 @@ public class UnrecognizedExtraField implements ZipExtraField


public void parseFromLocalFileData( byte[] data, int offset, int length ) public void parseFromLocalFileData( byte[] data, int offset, int length )
{ {
byte[] tmp = new byte[length];
byte[] tmp = new byte[ length ];
System.arraycopy( data, offset, tmp, 0, length ); System.arraycopy( data, offset, tmp, 0, length );
setLocalFileDataData( tmp ); setLocalFileDataData( tmp );
} }


+ 12
- 11
proposal/myrmidon/src/main/org/apache/tools/zip/ZipEntry.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@@ -120,7 +121,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
public ZipEntry( ZipEntry entry ) public ZipEntry( ZipEntry entry )
throws ZipException throws ZipException
{ {
this( ( java.util.zip.ZipEntry )entry );
this( (java.util.zip.ZipEntry)entry );
setInternalAttributes( entry.getInternalAttributes() ); setInternalAttributes( entry.getInternalAttributes() );
setExternalAttributes( entry.getExternalAttributes() ); setExternalAttributes( entry.getExternalAttributes() );
setExtraFields( entry.getExtraFields() ); setExtraFields( entry.getExtraFields() );
@@ -142,7 +143,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
{ {
setCompressedSizeMethod = setCompressedSizeMethod =
java.util.zip.ZipEntry.class.getMethod( "setCompressedSize", java.util.zip.ZipEntry.class.getMethod( "setCompressedSize",
new Class[]{Long.TYPE} );
new Class[]{Long.TYPE} );
} }
catch( NoSuchMethodException nse ) catch( NoSuchMethodException nse )
{ {
@@ -181,14 +182,14 @@ public class ZipEntry extends java.util.zip.ZipEntry
{ {
Throwable nested = ite.getTargetException(); Throwable nested = ite.getTargetException();
throw new RuntimeException( "Exception setting the compressed size " throw new RuntimeException( "Exception setting the compressed size "
+ "of " + ze + ": "
+ nested.getMessage() );
+ "of " + ze + ": "
+ nested.getMessage() );
} }
catch( Throwable other ) catch( Throwable other )
{ {
throw new RuntimeException( "Exception setting the compressed size " throw new RuntimeException( "Exception setting the compressed size "
+ "of " + ze + ": "
+ other.getMessage() );
+ "of " + ze + ": "
+ other.getMessage() );
} }
} }


@@ -255,7 +256,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
extraFields.clear(); extraFields.clear();
for( int i = 0; i < fields.length; i++ ) for( int i = 0; i < fields.length; i++ )
{ {
extraFields.add( fields[i] );
extraFields.add( fields[ i ] );
} }
setExtra(); setExtra();
} }
@@ -341,7 +342,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
public byte[] getLocalFileDataExtra() public byte[] getLocalFileDataExtra()
{ {
byte[] extra = getExtra(); byte[] extra = getExtra();
return extra != null ? extra : new byte[0];
return extra != null ? extra : new byte[ 0 ];
} }


/** /**
@@ -357,7 +358,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
boolean done = false; boolean done = false;
for( int i = 0; !done && i < extraFields.size(); i++ ) for( int i = 0; !done && i < extraFields.size(); i++ )
{ {
if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
{ {
extraFields.set( i, ze ); extraFields.set( i, ze );
done = true; done = true;
@@ -381,7 +382,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
ZipEntry e = null; ZipEntry e = null;
try try
{ {
e = new ZipEntry( ( java.util.zip.ZipEntry )super.clone() );
e = new ZipEntry( (java.util.zip.ZipEntry)super.clone() );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@@ -405,7 +406,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
boolean done = false; boolean done = false;
for( int i = 0; !done && i < extraFields.size(); i++ ) for( int i = 0; !done && i < extraFields.size(); i++ )
{ {
if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
{ {
extraFields.remove( i ); extraFields.remove( i );
done = true; done = true;


+ 1
- 0
proposal/myrmidon/src/main/org/apache/tools/zip/ZipExtraField.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.util.zip.ZipException; import java.util.zip.ZipException;


/** /**


+ 11
- 11
proposal/myrmidon/src/main/org/apache/tools/zip/ZipLong.java View File

@@ -50,10 +50,10 @@ public class ZipLong implements Cloneable
*/ */
public ZipLong( byte[] bytes, int offset ) public ZipLong( byte[] bytes, int offset )
{ {
value = ( bytes[offset + 3] << 24 ) & 0xFF000000l;
value += ( bytes[offset + 2] << 16 ) & 0xFF0000;
value += ( bytes[offset + 1] << 8 ) & 0xFF00;
value += ( bytes[offset] & 0xFF );
value = ( bytes[ offset + 3 ] << 24 ) & 0xFF000000l;
value += ( bytes[ offset + 2 ] << 16 ) & 0xFF0000;
value += ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
value += ( bytes[ offset ] & 0xFF );
} }


/** /**
@@ -64,11 +64,11 @@ public class ZipLong implements Cloneable
*/ */
public byte[] getBytes() public byte[] getBytes()
{ {
byte[] result = new byte[4];
result[0] = ( byte )( ( value & 0xFF ) );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
byte[] result = new byte[ 4 ];
result[ 0 ] = (byte)( ( value & 0xFF ) );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
return result; return result;
} }


@@ -96,7 +96,7 @@ public class ZipLong implements Cloneable
{ {
return false; return false;
} }
return value == ( ( ZipLong )o ).getValue();
return value == ( (ZipLong)o ).getValue();
} }


/** /**
@@ -107,7 +107,7 @@ public class ZipLong implements Cloneable
*/ */
public int hashCode() public int hashCode()
{ {
return ( int )value;
return (int)value;
} }


}// ZipLong }// ZipLong

+ 23
- 22
proposal/myrmidon/src/main/org/apache/tools/zip/ZipOutputStream.java View File

@@ -6,12 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.ArrayList;
import java.util.zip.CRC32; import java.util.zip.CRC32;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
@@ -216,17 +217,17 @@ public class ZipOutputStream extends DeflaterOutputStream
return DOS_TIME_MIN; return DOS_TIME_MIN;
} }
long value = ( ( year - 1980 ) << 25 ) long value = ( ( year - 1980 ) << 25 )
| ( month << 21 )
| ( time.getDate() << 16 )
| ( time.getHours() << 11 )
| ( time.getMinutes() << 5 )
| ( time.getSeconds() >> 1 );
byte[] result = new byte[4];
result[0] = ( byte )( ( value & 0xFF ) );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
| ( month << 21 )
| ( time.getDate() << 16 )
| ( time.getHours() << 11 )
| ( time.getMinutes() << 5 )
| ( time.getSeconds() >> 1 );
byte[] result = new byte[ 4 ];
result[ 0 ] = (byte)( ( value & 0xFF ) );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
return new ZipLong( result ); return new ZipLong( result );
} }


@@ -332,19 +333,19 @@ public class ZipOutputStream extends DeflaterOutputStream
if( entry.getCrc() != realCrc ) if( entry.getCrc() != realCrc )
{ {
throw new ZipException( "bad CRC checksum for entry " throw new ZipException( "bad CRC checksum for entry "
+ entry.getName() + ": "
+ Long.toHexString( entry.getCrc() )
+ " instead of "
+ Long.toHexString( realCrc ) );
+ entry.getName() + ": "
+ Long.toHexString( entry.getCrc() )
+ " instead of "
+ Long.toHexString( realCrc ) );
} }


if( entry.getSize() != written - dataStart ) if( entry.getSize() != written - dataStart )
{ {
throw new ZipException( "bad size for entry " throw new ZipException( "bad size for entry "
+ entry.getName() + ": "
+ entry.getSize()
+ " instead of "
+ ( written - dataStart ) );
+ entry.getName() + ": "
+ entry.getSize()
+ " instead of "
+ ( written - dataStart ) );
} }


} }
@@ -372,7 +373,7 @@ public class ZipOutputStream extends DeflaterOutputStream
cdOffset = new ZipLong( written ); cdOffset = new ZipLong( written );
for( int i = 0; i < entries.size(); i++ ) for( int i = 0; i < entries.size(); i++ )
{ {
writeCentralFileHeader( ( ZipEntry )entries.get( i ) );
writeCentralFileHeader( (ZipEntry)entries.get( i ) );
} }
cdLength = new ZipLong( written - cdOffset.getValue() ); cdLength = new ZipLong( written - cdOffset.getValue() );
writeCentralDirectoryEnd(); writeCentralDirectoryEnd();
@@ -593,7 +594,7 @@ public class ZipOutputStream extends DeflaterOutputStream
written += 4; written += 4;


// relative offset of LFH // relative offset of LFH
out.write( ( ( ZipLong )offsets.get( ze ) ).getBytes() );
out.write( ( (ZipLong)offsets.get( ze ) ).getBytes() );
written += 4; written += 4;


// file name // file name


+ 6
- 6
proposal/myrmidon/src/main/org/apache/tools/zip/ZipShort.java View File

@@ -50,8 +50,8 @@ public class ZipShort implements Cloneable
*/ */
public ZipShort( byte[] bytes, int offset ) public ZipShort( byte[] bytes, int offset )
{ {
value = ( bytes[offset + 1] << 8 ) & 0xFF00;
value += ( bytes[offset] & 0xFF );
value = ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
value += ( bytes[ offset ] & 0xFF );
} }


/** /**
@@ -62,9 +62,9 @@ public class ZipShort implements Cloneable
*/ */
public byte[] getBytes() public byte[] getBytes()
{ {
byte[] result = new byte[2];
result[0] = ( byte )( value & 0xFF );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
byte[] result = new byte[ 2 ];
result[ 0 ] = (byte)( value & 0xFF );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
return result; return result;
} }


@@ -92,7 +92,7 @@ public class ZipShort implements Cloneable
{ {
return false; return false;
} }
return value == ( ( ZipShort )o ).getValue();
return value == ( (ZipShort)o ).getValue();
} }


/** /**


+ 0
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -437,7 +437,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
Execute exe = new Execute( new LogStreamHandler( attributes, Execute exe = new Execute( new LogStreamHandler( attributes,
Project.MSG_INFO, Project.MSG_INFO,
Project.MSG_WARN ) ); Project.MSG_WARN ) );
exe.setAntRun( project );
exe.setWorkingDirectory( project.getBaseDir() ); exe.setWorkingDirectory( project.getBaseDir() );
exe.setCommandline( commandArray ); exe.setCommandline( commandArray );
exe.execute(); exe.execute();


+ 0
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/condition/And.java View File

@@ -7,7 +7,6 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import java.util.Iterator;
import java.util.Enumeration; import java.util.Enumeration;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;




+ 1
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/condition/ConditionBase.java View File

@@ -7,10 +7,9 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.apache.myrmidon.framework.Os; import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.taskdefs.Available; import org.apache.tools.ant.taskdefs.Available;


+ 2
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java View File

@@ -10,10 +10,9 @@ package org.apache.tools.ant.taskdefs.file;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java View File

@@ -457,8 +457,8 @@ public class Delete
if( dirCount > 0 ) if( dirCount > 0 )
{ {
getLogger().info( "Deleted " + dirCount + " director" + getLogger().info( "Deleted " + dirCount + " director" +
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
} }
} }
} }


+ 2
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java View File

@@ -9,16 +9,15 @@ package org.apache.tools.ant.taskdefs.file;


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.Iterator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.FilterSet; import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection; import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Moves a file or directory to a new file or directory. By default, the * Moves a file or directory to a new file or directory. By default, the


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.taskdefs.rmic; package org.apache.tools.ant.taskdefs.rmic;


import java.io.File; import java.io.File;
import java.util.Random;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Rmic; import org.apache.tools.ant.taskdefs.Rmic;


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/Commandline.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.StringTokenizer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;


/** /**


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileList.java View File

@@ -8,9 +8,9 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Stack; import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java View File

@@ -8,8 +8,8 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.Stack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Stack;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner; import org.apache.tools.ant.FileScanner;


+ 3
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java View File

@@ -10,11 +10,11 @@ package org.apache.tools.ant.types;// java io classes
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.Properties;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java View File

@@ -9,8 +9,8 @@ package org.apache.tools.ant.types;// java io classes


// java util classes // java util classes


import java.util.Iterator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;


// ant classes // ant classes


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java View File

@@ -8,10 +8,10 @@
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
import java.util.Stack; import java.util.Stack;
import java.util.ArrayList;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java View File

@@ -11,10 +11,10 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Stack; import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;


@@ -357,7 +357,7 @@ public class PatternSet extends DataType
} }


final String[] result = new String[ tmpNames.size() ]; final String[] result = new String[ tmpNames.size() ];
return (String[]) tmpNames.toArray( result );
return (String[])tmpNames.toArray( result );
} }


/** /**


+ 7
- 7
proposal/myrmidon/src/todo/org/apache/tools/ant/util/SourceFileScanner.java View File

@@ -9,11 +9,11 @@ package org.apache.tools.ant.util;


import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os; import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.avalon.excalibur.io.FileUtil;


/** /**
* Utility class that collects the functionality of the various scanDir methods * Utility class that collects the functionality of the various scanDir methods
@@ -78,7 +78,7 @@ public class SourceFileScanner
if( targets == null || targets.length == 0 ) if( targets == null || targets.length == 0 )
{ {
m_task.log( files[ i ] + " skipped - don\'t know how to handle it", m_task.log( files[ i ] + " skipped - don\'t know how to handle it",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
continue; continue;
} }


@@ -87,7 +87,7 @@ public class SourceFileScanner
if( src.lastModified() > now ) if( src.lastModified() > now )
{ {
m_task.log( "Warning: " + files[ i ] + " modified in the future.", m_task.log( "Warning: " + files[ i ] + " modified in the future.",
Project.MSG_WARN );
Project.MSG_WARN );
} }


boolean added = false; boolean added = false;
@@ -99,14 +99,14 @@ public class SourceFileScanner
if( !dest.exists() ) if( !dest.exists() )
{ {
m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
v.add( files[ i ] ); v.add( files[ i ] );
added = true; added = true;
} }
else if( src.lastModified() > dest.lastModified() ) else if( src.lastModified() > dest.lastModified() )
{ {
m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
v.add( files[ i ] ); v.add( files[ i ] );
added = true; added = true;
} }
@@ -123,8 +123,8 @@ public class SourceFileScanner
if( !added ) if( !added )
{ {
m_task.log( files[ i ] + " omitted as " + targetList.toString() m_task.log( files[ i ] + " omitted as " + targetList.toString()
+ ( targets.length == 1 ? " is" : " are " )
+ " up to date.", Project.MSG_VERBOSE );
+ ( targets.length == 1 ? " is" : " are " )
+ " up to date.", Project.MSG_VERBOSE );
} }


} }


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/bzip2/BZip2Constants.java View File

@@ -80,5 +80,5 @@ public interface BZip2Constants
920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638 936, 638
};
};
} }

+ 131
- 129
proposal/myrmidon/src/todo/org/apache/tools/bzip2/CBZip2InputStream.java View File

@@ -6,7 +6,9 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.bzip2; package org.apache.tools.bzip2;
import java.io.*;

import java.io.IOException;
import java.io.InputStream;


/** /**
* An input stream that decompresses from the BZip2 format (without the file * An input stream that decompresses from the BZip2 format (without the file
@@ -26,24 +28,24 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
private final static int NO_RAND_PART_C_STATE = 7; private final static int NO_RAND_PART_C_STATE = 7;
private CRC mCrc = new CRC(); private CRC mCrc = new CRC();


private boolean inUse[] = new boolean[256];
private boolean inUse[] = new boolean[ 256 ];


private char seqToUnseq[] = new char[256];
private char unseqToSeq[] = new char[256];
private char seqToUnseq[] = new char[ 256 ];
private char unseqToSeq[] = new char[ 256 ];


private char selector[] = new char[MAX_SELECTORS];
private char selectorMtf[] = new char[MAX_SELECTORS];
private char selector[] = new char[ MAX_SELECTORS ];
private char selectorMtf[] = new char[ MAX_SELECTORS ];


/* /*
* freq table collected to save a pass over the data * freq table collected to save a pass over the data
* during decompression. * during decompression.
*/ */
private int unzftab[] = new int[256];
private int unzftab[] = new int[ 256 ];


private int limit[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int base[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int perm[][] = new int[N_GROUPS][MAX_ALPHA_SIZE];
private int minLens[] = new int[N_GROUPS];
private int limit[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int base[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int perm[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
private int minLens[] = new int[ N_GROUPS ];


private boolean streamEnd = false; private boolean streamEnd = false;


@@ -146,28 +148,28 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
else else
{ {
int retChar = currentChar; int retChar = currentChar;
switch ( currentState )
switch( currentState )
{ {
case START_BLOCK_STATE:
break;
case RAND_PART_A_STATE:
break;
case RAND_PART_B_STATE:
setupRandPartB();
break;
case RAND_PART_C_STATE:
setupRandPartC();
break;
case NO_RAND_PART_A_STATE:
break;
case NO_RAND_PART_B_STATE:
setupNoRandPartB();
break;
case NO_RAND_PART_C_STATE:
setupNoRandPartC();
break;
default:
break;
case START_BLOCK_STATE:
break;
case RAND_PART_A_STATE:
break;
case RAND_PART_B_STATE:
setupRandPartB();
break;
case RAND_PART_C_STATE:
setupRandPartC();
break;
case NO_RAND_PART_A_STATE:
break;
case NO_RAND_PART_B_STATE:
setupNoRandPartB();
break;
case NO_RAND_PART_C_STATE:
setupNoRandPartC();
break;
default:
break;
} }
return retChar; return retChar;
} }
@@ -176,7 +178,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
private void setDecompressStructureSizes( int newSize100k ) private void setDecompressStructureSizes( int newSize100k )
{ {
if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k
&& blockSize100k <= 9 ) )
&& blockSize100k <= 9 ) )
{ {
// throw new IOException("Invalid block size"); // throw new IOException("Invalid block size");
} }
@@ -187,30 +189,30 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
return; return;


int n = baseBlockSize * newSize100k; int n = baseBlockSize * newSize100k;
ll8 = new char[n];
tt = new int[n];
ll8 = new char[ n ];
tt = new int[ n ];
} }


private void setupBlock() private void setupBlock()
{ {
int cftab[] = new int[257];
int cftab[] = new int[ 257 ];
char ch; char ch;


cftab[0] = 0;
cftab[ 0 ] = 0;
for( i = 1; i <= 256; i++ ) for( i = 1; i <= 256; i++ )
cftab[i] = unzftab[i - 1];
cftab[ i ] = unzftab[ i - 1 ];
for( i = 1; i <= 256; i++ ) for( i = 1; i <= 256; i++ )
cftab[i] += cftab[i - 1];
cftab[ i ] += cftab[ i - 1 ];


for( i = 0; i <= last; i++ ) for( i = 0; i <= last; i++ )
{ {
ch = ( char )ll8[i];
tt[cftab[ch]] = i;
cftab[ch]++;
ch = (char)ll8[ i ];
tt[ cftab[ ch ] ] = i;
cftab[ ch ]++;
} }
cftab = null; cftab = null;


tPos = tt[origPtr];
tPos = tt[ origPtr ];


count = 0; count = 0;
i2 = 0; i2 = 0;
@@ -235,8 +237,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( i2 <= last ) if( i2 <= last )
{ {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos];
tPos = tt[tPos];
ch2 = ll8[ tPos ];
tPos = tt[ tPos ];
i2++; i2++;


currentChar = ch2; currentChar = ch2;
@@ -264,8 +266,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
count++; count++;
if( count >= 4 ) if( count >= 4 )
{ {
z = ll8[tPos];
tPos = tt[tPos];
z = ll8[ tPos ];
tPos = tt[ tPos ];
currentState = NO_RAND_PART_C_STATE; currentState = NO_RAND_PART_C_STATE;
j2 = 0; j2 = 0;
setupNoRandPartC(); setupNoRandPartC();
@@ -280,7 +282,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void setupNoRandPartC() private void setupNoRandPartC()
{ {
if( j2 < ( int )z )
if( j2 < (int)z )
{ {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC( ch2 ); mCrc.updateCRC( ch2 );
@@ -300,17 +302,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( i2 <= last ) if( i2 <= last )
{ {
chPrev = ch2; chPrev = ch2;
ch2 = ll8[tPos];
tPos = tt[tPos];
ch2 = ll8[ tPos ];
tPos = tt[ tPos ];
if( rNToGo == 0 ) if( rNToGo == 0 )
{ {
rNToGo = rNums[rTPos];
rNToGo = rNums[ rTPos ];
rTPos++; rTPos++;
if( rTPos == 512 ) if( rTPos == 512 )
rTPos = 0; rTPos = 0;
} }
rNToGo--; rNToGo--;
ch2 ^= ( int )( ( rNToGo == 1 ) ? 1 : 0 );
ch2 ^= (int)( ( rNToGo == 1 ) ? 1 : 0 );
i2++; i2++;


currentChar = ch2; currentChar = ch2;
@@ -338,11 +340,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
count++; count++;
if( count >= 4 ) if( count >= 4 )
{ {
z = ll8[tPos];
tPos = tt[tPos];
z = ll8[ tPos ];
tPos = tt[ tPos ];
if( rNToGo == 0 ) if( rNToGo == 0 )
{ {
rNToGo = rNums[rTPos];
rNToGo = rNums[ rTPos ];
rTPos++; rTPos++;
if( rTPos == 512 ) if( rTPos == 512 )
rTPos = 0; rTPos = 0;
@@ -363,7 +365,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void setupRandPartC() private void setupRandPartC()
{ {
if( j2 < ( int )z )
if( j2 < (int)z )
{ {
currentChar = ch2; currentChar = ch2;
mCrc.updateCRC( ch2 ); mCrc.updateCRC( ch2 );
@@ -380,7 +382,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private void getAndMoveToFrontDecode() private void getAndMoveToFrontDecode()
{ {
char yy[] = new char[256];
char yy[] = new char[ 256 ];
int i; int i;
int j; int j;
int nextSym; int nextSym;
@@ -404,10 +406,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
* cache misses. * cache misses.
*/ */
for( i = 0; i <= 255; i++ ) for( i = 0; i <= 255; i++ )
unzftab[i] = 0;
unzftab[ i ] = 0;


for( i = 0; i <= 255; i++ ) for( i = 0; i <= 255; i++ )
yy[i] = ( char )i;
yy[ i ] = (char)i;


last = -1; last = -1;
{ {
@@ -421,10 +423,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -435,7 +437,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -455,7 +457,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
} }
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }


while( true ) while( true )
@@ -487,10 +489,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -501,7 +503,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -522,18 +524,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
; ;
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }
}while ( nextSym == RUNA || nextSym == RUNB );
} while( nextSym == RUNA || nextSym == RUNB );


s++; s++;
ch = seqToUnseq[yy[0]];
unzftab[ch] += s;
ch = seqToUnseq[ yy[ 0 ] ];
unzftab[ ch ] += s;


while( s > 0 ) while( s > 0 )
{ {
last++; last++;
ll8[last] = ch;
ll8[ last ] = ch;
s--; s--;
} }
; ;
@@ -549,9 +551,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
if( last >= limitLast ) if( last >= limitLast )
blockOverrun(); blockOverrun();


tmp = yy[nextSym - 1];
unzftab[seqToUnseq[tmp]]++;
ll8[last] = seqToUnseq[tmp];
tmp = yy[ nextSym - 1 ];
unzftab[ seqToUnseq[ tmp ] ]++;
ll8[ last ] = seqToUnseq[ tmp ];


/* /*
* This loop is hammered during decompression, * This loop is hammered during decompression,
@@ -561,15 +563,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
j = nextSym - 1; j = nextSym - 1;
for( ; j > 3; j -= 4 ) for( ; j > 3; j -= 4 )
{ {
yy[j] = yy[j - 1];
yy[j - 1] = yy[j - 2];
yy[j - 2] = yy[j - 3];
yy[j - 3] = yy[j - 4];
yy[ j ] = yy[ j - 1 ];
yy[ j - 1 ] = yy[ j - 2 ];
yy[ j - 2 ] = yy[ j - 3 ];
yy[ j - 3 ] = yy[ j - 4 ];
} }
for( ; j > 0; j-- ) for( ; j > 0; j-- )
yy[j] = yy[j - 1];
yy[ j ] = yy[ j - 1 ];


yy[0] = tmp;
yy[ 0 ] = tmp;
{ {
int zt; int zt;
int zn; int zn;
@@ -581,10 +583,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
groupPos = G_SIZE; groupPos = G_SIZE;
} }
groupPos--; groupPos--;
zt = selector[groupNo];
zn = minLens[zt];
zt = selector[ groupNo ];
zn = minLens[ zt ];
zvec = bsR( zn ); zvec = bsR( zn );
while( zvec > limit[zt][zn] )
while( zvec > limit[ zt ][ zn ] )
{ {
zn++; zn++;
{ {
@@ -595,7 +597,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -612,7 +614,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
zvec = ( zvec << 1 ) | zj; zvec = ( zvec << 1 ) | zj;
} }
; ;
nextSym = perm[zt][zvec - base[zt][zn]];
nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ];
} }
continue; continue;
} }
@@ -626,17 +628,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants


private int bsGetInt32() private int bsGetInt32()
{ {
return ( int )bsGetint();
return (int)bsGetint();
} }


private int bsGetIntVS( int numBits ) private int bsGetIntVS( int numBits )
{ {
return ( int )bsR( numBits );
return (int)bsR( numBits );
} }


private char bsGetUChar() private char bsGetUChar()
{ {
return ( char )bsR( 8 );
return (char)bsR( 8 );
} }


private int bsGetint() private int bsGetint()
@@ -659,7 +661,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
char thech = 0; char thech = 0;
try try
{ {
thech = ( char )bsStream.read();
thech = (char)bsStream.read();
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -709,7 +711,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
crcError(); crcError();


computedCombinedCRC = ( computedCombinedCRC << 1 ) computedCombinedCRC = ( computedCombinedCRC << 1 )
| ( computedCombinedCRC >>> 31 );
| ( computedCombinedCRC >>> 31 );
computedCombinedCRC ^= computedBlockCRC; computedCombinedCRC ^= computedBlockCRC;
} }


@@ -725,33 +727,33 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
pp = 0; pp = 0;
for( i = minLen; i <= maxLen; i++ ) for( i = minLen; i <= maxLen; i++ )
for( j = 0; j < alphaSize; j++ ) for( j = 0; j < alphaSize; j++ )
if( length[j] == i )
if( length[ j ] == i )
{ {
perm[pp] = j;
perm[ pp ] = j;
pp++; pp++;
} }
; ;


for( i = 0; i < MAX_CODE_LEN; i++ ) for( i = 0; i < MAX_CODE_LEN; i++ )
base[i] = 0;
base[ i ] = 0;
for( i = 0; i < alphaSize; i++ ) for( i = 0; i < alphaSize; i++ )
base[length[i] + 1]++;
base[ length[ i ] + 1 ]++;


for( i = 1; i < MAX_CODE_LEN; i++ ) for( i = 1; i < MAX_CODE_LEN; i++ )
base[i] += base[i - 1];
base[ i ] += base[ i - 1 ];


for( i = 0; i < MAX_CODE_LEN; i++ ) for( i = 0; i < MAX_CODE_LEN; i++ )
limit[i] = 0;
limit[ i ] = 0;
vec = 0; vec = 0;


for( i = minLen; i <= maxLen; i++ ) for( i = minLen; i <= maxLen; i++ )
{ {
vec += ( base[i + 1] - base[i] );
limit[i] = vec - 1;
vec += ( base[ i + 1 ] - base[ i ] );
limit[ i ] = vec - 1;
vec <<= 1; vec <<= 1;
} }
for( i = minLen + 1; i <= maxLen; i++ ) for( i = minLen + 1; i <= maxLen; i++ )
base[i] = ( ( limit[i - 1] + 1 ) << 1 ) - base[i];
base[ i ] = ( ( limit[ i - 1 ] + 1 ) << 1 ) - base[ i ];
} }


private void initBlock() private void initBlock()
@@ -769,14 +771,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
magic5 = bsGetUChar(); magic5 = bsGetUChar();
magic6 = bsGetUChar(); magic6 = bsGetUChar();
if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45
&& magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 )
&& magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 )
{ {
complete(); complete();
return; return;
} }


if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59
|| magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 )
|| magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 )
{ {
badBlockHeader(); badBlockHeader();
streamEnd = true; streamEnd = true;
@@ -819,17 +821,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
int i; int i;
nInUse = 0; nInUse = 0;
for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
if( inUse[i] )
if( inUse[ i ] )
{ {
seqToUnseq[nInUse] = ( char )i;
unseqToSeq[i] = ( char )nInUse;
seqToUnseq[ nInUse ] = (char)i;
unseqToSeq[ i ] = (char)nInUse;
nInUse++; nInUse++;
} }
} }


private void recvDecodingTables() private void recvDecodingTables()
{ {
char len[][] = new char[N_GROUPS][MAX_ALPHA_SIZE];
char len[][] = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ];
int i; int i;
int j; int j;
int t; int t;
@@ -838,25 +840,25 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
int alphaSize; int alphaSize;
int minLen; int minLen;
int maxLen; int maxLen;
boolean inUse16[] = new boolean[16];
boolean inUse16[] = new boolean[ 16 ];


/* /*
* Receive the mapping table * Receive the mapping table
*/ */
for( i = 0; i < 16; i++ ) for( i = 0; i < 16; i++ )
if( bsR( 1 ) == 1 ) if( bsR( 1 ) == 1 )
inUse16[i] = true;
inUse16[ i ] = true;
else else
inUse16[i] = false;
inUse16[ i ] = false;


for( i = 0; i < 256; i++ ) for( i = 0; i < 256; i++ )
inUse[i] = false;
inUse[ i ] = false;


for( i = 0; i < 16; i++ ) for( i = 0; i < 16; i++ )
if( inUse16[i] )
if( inUse16[ i ] )
for( j = 0; j < 16; j++ ) for( j = 0; j < 16; j++ )
if( bsR( 1 ) == 1 ) if( bsR( 1 ) == 1 )
inUse[i * 16 + j] = true;
inUse[ i * 16 + j ] = true;


makeMaps(); makeMaps();
alphaSize = nInUse + 2; alphaSize = nInUse + 2;
@@ -871,29 +873,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
j = 0; j = 0;
while( bsR( 1 ) == 1 ) while( bsR( 1 ) == 1 )
j++; j++;
selectorMtf[i] = ( char )j;
selectorMtf[ i ] = (char)j;
} }
{ {
/* /*
* Undo the MTF values for the selectors. * Undo the MTF values for the selectors.
*/ */
char pos[] = new char[N_GROUPS];
char pos[] = new char[ N_GROUPS ];
char tmp; char tmp;
char v; char v;
for( v = 0; v < nGroups; v++ ) for( v = 0; v < nGroups; v++ )
pos[v] = v;
pos[ v ] = v;


for( i = 0; i < nSelectors; i++ ) for( i = 0; i < nSelectors; i++ )
{ {
v = selectorMtf[i];
tmp = pos[v];
v = selectorMtf[ i ];
tmp = pos[ v ];
while( v > 0 ) while( v > 0 )
{ {
pos[v] = pos[v - 1];
pos[ v ] = pos[ v - 1 ];
v--; v--;
} }
pos[0] = tmp;
selector[i] = tmp;
pos[ 0 ] = tmp;
selector[ i ] = tmp;
} }
} }


@@ -912,7 +914,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
else else
curr--; curr--;
} }
len[t][i] = ( char )curr;
len[ t ][ i ] = (char)curr;
} }
} }


@@ -925,14 +927,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants
maxLen = 0; maxLen = 0;
for( i = 0; i < alphaSize; i++ ) for( i = 0; i < alphaSize; i++ )
{ {
if( len[t][i] > maxLen )
maxLen = len[t][i];
if( len[t][i] < minLen )
minLen = len[t][i];
if( len[ t ][ i ] > maxLen )
maxLen = len[ t ][ i ];
if( len[ t ][ i ] < minLen )
minLen = len[ t ][ i ];
} }
hbCreateDecodeTables( limit[t], base[t], perm[t], len[t], minLen,
maxLen, alphaSize );
minLens[t] = minLen;
hbCreateDecodeTables( limit[ t ], base[ t ], perm[ t ], len[ t ], minLen,
maxLen, alphaSize );
minLens[ t ] = minLen;
} }
} }
} }


+ 331
- 329
proposal/myrmidon/src/todo/org/apache/tools/bzip2/CBZip2OutputStream.java
File diff suppressed because it is too large
View File


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/bzip2/CRC.java View File

@@ -80,7 +80,7 @@ class CRC
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
};


int globalCrc; int globalCrc;


@@ -114,7 +114,7 @@ class CRC
int temp = ( globalCrc >> 24 ) ^ inCh; int temp = ( globalCrc >> 24 ) ^ inCh;
if( temp < 0 ) if( temp < 0 )
temp = 256 + temp; temp = 256 + temp;
globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[temp];
globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[ temp ];
} }
} }



+ 9
- 7
proposal/myrmidon/src/todo/org/apache/tools/mail/MailMessage.java View File

@@ -6,16 +6,17 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.mail; package org.apache.tools.mail;

import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;


/** /**
* A class to help send SMTP email. This class is an improvement on the * A class to help send SMTP email. This class is an improvement on the
@@ -348,7 +349,7 @@ public class MailMessage
// Check that the response is one of the valid codes // Check that the response is one of the valid codes
for( int i = 0; i < ok.length; i++ ) for( int i = 0; i < ok.length; i++ )
{ {
if( response.startsWith( "" + ok[i] ) )
if( response.startsWith( "" + ok[ i ] ) )
{ {
return true; return true;
} }
@@ -364,7 +365,7 @@ public class MailMessage
socket = new Socket( host, port ); socket = new Socket( host, port );
out = new MailPrintStream( out = new MailPrintStream(
new BufferedOutputStream( new BufferedOutputStream(
socket.getOutputStream() ) );
socket.getOutputStream() ) );
in = new SmtpResponseReader( socket.getInputStream() ); in = new SmtpResponseReader( socket.getInputStream() );
getReady(); getReady();
} }
@@ -387,8 +388,8 @@ public class MailMessage
Enumeration e = headers.keys(); Enumeration e = headers.keys();
while( e.hasMoreElements() ) while( e.hasMoreElements() )
{ {
String name = ( String )e.nextElement();
String value = ( String )headers.get( name );
String name = (String)e.nextElement();
String value = (String)headers.get( name );
out.println( name + ": " + value ); out.println( name + ": " + value );
} }
out.println(); out.println();
@@ -471,6 +472,7 @@ public class MailMessage
// This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>.. // This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>..
// per RFC 821. It also ensures that new lines are always \r\n. // per RFC 821. It also ensures that new lines are always \r\n.
// //

class MailPrintStream extends PrintStream class MailPrintStream extends PrintStream
{ {


@@ -506,7 +508,7 @@ class MailPrintStream extends PrintStream
{ {
for( int i = 0; i < len; i++ ) for( int i = 0; i < len; i++ )
{ {
write( buf[off + i] );
write( buf[ off + i ] );
} }
} }




+ 1
- 0
proposal/myrmidon/src/todo/org/apache/tools/mail/SmtpResponseReader.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.mail; package org.apache.tools.mail;

import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


+ 24
- 23
proposal/myrmidon/src/todo/org/apache/tools/tar/TarBuffer.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@@ -137,7 +138,7 @@ public class TarBuffer
{ {
for( int i = 0, sz = this.getRecordSize(); i < sz; ++i ) for( int i = 0, sz = this.getRecordSize(); i < sz; ++i )
{ {
if( record[i] != 0 )
if( record[ i ] != 0 )
{ {
return false; return false;
} }
@@ -165,7 +166,7 @@ public class TarBuffer
this.flushBlock(); this.flushBlock();


if( this.outStream != System.out if( this.outStream != System.out
&& this.outStream != System.err )
&& this.outStream != System.err )
{ {
this.outStream.close(); this.outStream.close();


@@ -195,7 +196,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "ReadRecord: recIdx = " + this.currRecIdx System.err.println( "ReadRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.inStream == null ) if( this.inStream == null )
@@ -211,11 +212,11 @@ public class TarBuffer
} }
} }


byte[] result = new byte[this.recordSize];
byte[] result = new byte[ this.recordSize ];


System.arraycopy( this.blockBuffer, System.arraycopy( this.blockBuffer,
( this.currRecIdx * this.recordSize ), result, 0,
this.recordSize );
( this.currRecIdx * this.recordSize ), result, 0,
this.recordSize );


this.currRecIdx++; this.currRecIdx++;


@@ -233,7 +234,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "SkipRecord: recIdx = " + this.currRecIdx System.err.println( "SkipRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.inStream == null ) if( this.inStream == null )
@@ -264,7 +265,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "WriteRecord: recIdx = " + this.currRecIdx System.err.println( "WriteRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.outStream == null ) if( this.outStream == null )
@@ -275,9 +276,9 @@ public class TarBuffer
if( record.length != this.recordSize ) if( record.length != this.recordSize )
{ {
throw new IOException( "record to write has length '" throw new IOException( "record to write has length '"
+ record.length
+ "' which is not the record size of '"
+ this.recordSize + "'" );
+ record.length
+ "' which is not the record size of '"
+ this.recordSize + "'" );
} }


if( this.currRecIdx >= this.recsPerBlock ) if( this.currRecIdx >= this.recsPerBlock )
@@ -286,8 +287,8 @@ public class TarBuffer
} }


System.arraycopy( record, 0, this.blockBuffer, System.arraycopy( record, 0, this.blockBuffer,
( this.currRecIdx * this.recordSize ),
this.recordSize );
( this.currRecIdx * this.recordSize ),
this.recordSize );


this.currRecIdx++; this.currRecIdx++;
} }
@@ -306,7 +307,7 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "WriteRecord: recIdx = " + this.currRecIdx System.err.println( "WriteRecord: recIdx = " + this.currRecIdx
+ " blkIdx = " + this.currBlkIdx );
+ " blkIdx = " + this.currBlkIdx );
} }


if( this.outStream == null ) if( this.outStream == null )
@@ -317,9 +318,9 @@ public class TarBuffer
if( ( offset + this.recordSize ) > buf.length ) if( ( offset + this.recordSize ) > buf.length )
{ {
throw new IOException( "record has length '" + buf.length throw new IOException( "record has length '" + buf.length
+ "' with offset '" + offset
+ "' which is less than the record size of '"
+ this.recordSize + "'" );
+ "' with offset '" + offset
+ "' which is less than the record size of '"
+ this.recordSize + "'" );
} }


if( this.currRecIdx >= this.recsPerBlock ) if( this.currRecIdx >= this.recsPerBlock )
@@ -328,8 +329,8 @@ public class TarBuffer
} }


System.arraycopy( buf, offset, this.blockBuffer, System.arraycopy( buf, offset, this.blockBuffer,
( this.currRecIdx * this.recordSize ),
this.recordSize );
( this.currRecIdx * this.recordSize ),
this.recordSize );


this.currRecIdx++; this.currRecIdx++;
} }
@@ -370,7 +371,7 @@ public class TarBuffer
this.blockSize = blockSize; this.blockSize = blockSize;
this.recordSize = recordSize; this.recordSize = recordSize;
this.recsPerBlock = ( this.blockSize / this.recordSize ); this.recsPerBlock = ( this.blockSize / this.recordSize );
this.blockBuffer = new byte[this.blockSize];
this.blockBuffer = new byte[ this.blockSize ];


if( this.inStream != null ) if( this.inStream != null )
{ {
@@ -409,7 +410,7 @@ public class TarBuffer
while( bytesNeeded > 0 ) while( bytesNeeded > 0 )
{ {
long numBytes = this.inStream.read( this.blockBuffer, offset, long numBytes = this.inStream.read( this.blockBuffer, offset,
bytesNeeded );
bytesNeeded );


// //
// NOTE // NOTE
@@ -437,8 +438,8 @@ public class TarBuffer
if( this.debug ) if( this.debug )
{ {
System.err.println( "ReadBlock: INCOMPLETE READ " System.err.println( "ReadBlock: INCOMPLETE READ "
+ numBytes + " of " + this.blockSize
+ " bytes read." );
+ numBytes + " of " + this.blockSize
+ " bytes read." );
} }
} }
} }


+ 9
- 9
proposal/myrmidon/src/todo/org/apache/tools/tar/TarConstants.java View File

@@ -82,42 +82,42 @@ public interface TarConstants
/** /**
* Normal file type. * Normal file type.
*/ */
byte LF_NORMAL = ( byte )'0';
byte LF_NORMAL = (byte)'0';


/** /**
* Link file type. * Link file type.
*/ */
byte LF_LINK = ( byte )'1';
byte LF_LINK = (byte)'1';


/** /**
* Symbolic link file type. * Symbolic link file type.
*/ */
byte LF_SYMLINK = ( byte )'2';
byte LF_SYMLINK = (byte)'2';


/** /**
* Character device file type. * Character device file type.
*/ */
byte LF_CHR = ( byte )'3';
byte LF_CHR = (byte)'3';


/** /**
* Block device file type. * Block device file type.
*/ */
byte LF_BLK = ( byte )'4';
byte LF_BLK = (byte)'4';


/** /**
* Directory file type. * Directory file type.
*/ */
byte LF_DIR = ( byte )'5';
byte LF_DIR = (byte)'5';


/** /**
* FIFO (pipe) file type. * FIFO (pipe) file type.
*/ */
byte LF_FIFO = ( byte )'6';
byte LF_FIFO = (byte)'6';


/** /**
* Contiguous file type. * Contiguous file type.
*/ */
byte LF_CONTIG = ( byte )'7';
byte LF_CONTIG = (byte)'7';


/** /**
* The magic tag representing a POSIX tar archive. * The magic tag representing a POSIX tar archive.
@@ -137,5 +137,5 @@ public interface TarConstants
/** /**
* Identifies the *next* file on the tape as having a long name. * Identifies the *next* file on the tape as having a long name.
*/ */
byte LF_GNUTYPE_LONGNAME = ( byte )'L';
byte LF_GNUTYPE_LONGNAME = (byte)'L';
} }

+ 16
- 17
proposal/myrmidon/src/todo/org/apache/tools/tar/TarEntry.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;


@@ -190,8 +191,8 @@ public class TarEntry implements TarConstants
char ch2 = name.charAt( 1 ); char ch2 = name.charAt( 1 );


if( ch2 == ':' if( ch2 == ':'
&& ( ( ch1 >= 'a' && ch1 <= 'z' )
|| ( ch1 >= 'A' && ch1 <= 'Z' ) ) )
&& ( ( ch1 >= 'a' && ch1 <= 'z' )
|| ( ch1 >= 'A' && ch1 <= 'Z' ) ) )
{ {
name = name.substring( 2 ); name = name.substring( 2 );
} }
@@ -406,15 +407,15 @@ public class TarEntry implements TarConstants
{ {
if( this.file == null || !this.file.isDirectory() ) if( this.file == null || !this.file.isDirectory() )
{ {
return new TarEntry[0];
return new TarEntry[ 0 ];
} }


String[] list = this.file.list(); String[] list = this.file.list();
TarEntry[] result = new TarEntry[list.length];
TarEntry[] result = new TarEntry[ list.length ];


for( int i = 0; i < list.length; ++i ) for( int i = 0; i < list.length; ++i )
{ {
result[i] = new TarEntry( new File( this.file, list[i] ) );
result[ i ] = new TarEntry( new File( this.file, list[ i ] ) );
} }


return result; return result;
@@ -490,7 +491,6 @@ public class TarEntry implements TarConstants
return this.size; return this.size;
} }



/** /**
* Get this entry's user id. * Get this entry's user id.
* *
@@ -549,7 +549,6 @@ public class TarEntry implements TarConstants
return false; return false;
} }



/** /**
* Indicate if this entry is a GNU long name block * Indicate if this entry is a GNU long name block
* *
@@ -585,19 +584,19 @@ public class TarEntry implements TarConstants


this.name = TarUtils.parseName( header, offset, NAMELEN ); this.name = TarUtils.parseName( header, offset, NAMELEN );
offset += NAMELEN; offset += NAMELEN;
this.mode = ( int )TarUtils.parseOctal( header, offset, MODELEN );
this.mode = (int)TarUtils.parseOctal( header, offset, MODELEN );
offset += MODELEN; offset += MODELEN;
this.userId = ( int )TarUtils.parseOctal( header, offset, UIDLEN );
this.userId = (int)TarUtils.parseOctal( header, offset, UIDLEN );
offset += UIDLEN; offset += UIDLEN;
this.groupId = ( int )TarUtils.parseOctal( header, offset, GIDLEN );
this.groupId = (int)TarUtils.parseOctal( header, offset, GIDLEN );
offset += GIDLEN; offset += GIDLEN;
this.size = TarUtils.parseOctal( header, offset, SIZELEN ); this.size = TarUtils.parseOctal( header, offset, SIZELEN );
offset += SIZELEN; offset += SIZELEN;
this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN ); this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN );
offset += MODTIMELEN; offset += MODTIMELEN;
this.checkSum = ( int )TarUtils.parseOctal( header, offset, CHKSUMLEN );
this.checkSum = (int)TarUtils.parseOctal( header, offset, CHKSUMLEN );
offset += CHKSUMLEN; offset += CHKSUMLEN;
this.linkFlag = header[offset++];
this.linkFlag = header[ offset++ ];
this.linkName = TarUtils.parseName( header, offset, NAMELEN ); this.linkName = TarUtils.parseName( header, offset, NAMELEN );
offset += NAMELEN; offset += NAMELEN;
this.magic = TarUtils.parseName( header, offset, MAGICLEN ); this.magic = TarUtils.parseName( header, offset, MAGICLEN );
@@ -606,9 +605,9 @@ public class TarEntry implements TarConstants
offset += UNAMELEN; offset += UNAMELEN;
this.groupName = TarUtils.parseName( header, offset, GNAMELEN ); this.groupName = TarUtils.parseName( header, offset, GNAMELEN );
offset += GNAMELEN; offset += GNAMELEN;
this.devMajor = ( int )TarUtils.parseOctal( header, offset, DEVLEN );
this.devMajor = (int)TarUtils.parseOctal( header, offset, DEVLEN );
offset += DEVLEN; offset += DEVLEN;
this.devMinor = ( int )TarUtils.parseOctal( header, offset, DEVLEN );
this.devMinor = (int)TarUtils.parseOctal( header, offset, DEVLEN );
} }


/** /**
@@ -631,10 +630,10 @@ public class TarEntry implements TarConstants


for( int c = 0; c < CHKSUMLEN; ++c ) for( int c = 0; c < CHKSUMLEN; ++c )
{ {
outbuf[offset++] = ( byte )' ';
outbuf[ offset++ ] = (byte)' ';
} }


outbuf[offset++] = this.linkFlag;
outbuf[ offset++ ] = this.linkFlag;
offset = TarUtils.getNameBytes( this.linkName, outbuf, offset, NAMELEN ); offset = TarUtils.getNameBytes( this.linkName, outbuf, offset, NAMELEN );
offset = TarUtils.getNameBytes( this.magic, outbuf, offset, MAGICLEN ); offset = TarUtils.getNameBytes( this.magic, outbuf, offset, MAGICLEN );
offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN ); offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN );
@@ -644,7 +643,7 @@ public class TarEntry implements TarConstants


while( offset < outbuf.length ) while( offset < outbuf.length )
{ {
outbuf[offset++] = 0;
outbuf[ offset++ ] = 0;
} }


long checkSum = TarUtils.computeCheckSum( outbuf ); long checkSum = TarUtils.computeCheckSum( outbuf );


+ 50
- 45
proposal/myrmidon/src/todo/org/apache/tools/tar/TarInputStream.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -48,7 +49,7 @@ public class TarInputStream extends FilterInputStream


this.buffer = new TarBuffer( is, blockSize, recordSize ); this.buffer = new TarBuffer( is, blockSize, recordSize );
this.readBuf = null; this.readBuf = null;
this.oneBuf = new byte[1];
this.oneBuf = new byte[ 1 ];
this.debug = false; this.debug = false;
this.hasHitEOF = false; this.hasHitEOF = false;
} }
@@ -90,10 +91,10 @@ public class TarInputStream extends FilterInputStream
if( this.debug ) if( this.debug )
{ {
System.err.println( "TarInputStream: SKIP currENTRY '" System.err.println( "TarInputStream: SKIP currENTRY '"
+ this.currEntry.getName() + "' SZ "
+ this.entrySize + " OFF "
+ this.entryOffset + " skipping "
+ numToSkip + " bytes" );
+ this.currEntry.getName() + "' SZ "
+ this.entrySize + " OFF "
+ this.entryOffset + " skipping "
+ numToSkip + " bytes" );
} }


if( numToSkip > 0 ) if( numToSkip > 0 )
@@ -131,56 +132,56 @@ public class TarInputStream extends FilterInputStream
{ {
this.currEntry = new TarEntry( headerBuf ); this.currEntry = new TarEntry( headerBuf );


if( !( headerBuf[257] == 'u' && headerBuf[258] == 's'
&& headerBuf[259] == 't' && headerBuf[260] == 'a'
&& headerBuf[261] == 'r' ) )
if( !( headerBuf[ 257 ] == 'u' && headerBuf[ 258 ] == 's'
&& headerBuf[ 259 ] == 't' && headerBuf[ 260 ] == 'a'
&& headerBuf[ 261 ] == 'r' ) )
{ {
this.entrySize = 0; this.entrySize = 0;
this.entryOffset = 0; this.entryOffset = 0;
this.currEntry = null; this.currEntry = null;


throw new IOException( "bad header in block " throw new IOException( "bad header in block "
+ this.buffer.getCurrentBlockNum()
+ " record "
+ this.buffer.getCurrentRecordNum()
+ ", " +
"header magic is not 'ustar', but '"
+ headerBuf[257]
+ headerBuf[258]
+ headerBuf[259]
+ headerBuf[260]
+ headerBuf[261]
+ "', or (dec) "
+ ( ( int )headerBuf[257] )
+ ", "
+ ( ( int )headerBuf[258] )
+ ", "
+ ( ( int )headerBuf[259] )
+ ", "
+ ( ( int )headerBuf[260] )
+ ", "
+ ( ( int )headerBuf[261] ) );
+ this.buffer.getCurrentBlockNum()
+ " record "
+ this.buffer.getCurrentRecordNum()
+ ", " +
"header magic is not 'ustar', but '"
+ headerBuf[ 257 ]
+ headerBuf[ 258 ]
+ headerBuf[ 259 ]
+ headerBuf[ 260 ]
+ headerBuf[ 261 ]
+ "', or (dec) "
+ ( (int)headerBuf[ 257 ] )
+ ", "
+ ( (int)headerBuf[ 258 ] )
+ ", "
+ ( (int)headerBuf[ 259 ] )
+ ", "
+ ( (int)headerBuf[ 260 ] )
+ ", "
+ ( (int)headerBuf[ 261 ] ) );
} }


if( this.debug ) if( this.debug )
{ {
System.err.println( "TarInputStream: SET CURRENTRY '" System.err.println( "TarInputStream: SET CURRENTRY '"
+ this.currEntry.getName()
+ "' size = "
+ this.currEntry.getSize() );
+ this.currEntry.getName()
+ "' size = "
+ this.currEntry.getSize() );
} }


this.entryOffset = 0; this.entryOffset = 0;


// REVIEW How do we resolve this discrepancy?! // REVIEW How do we resolve this discrepancy?!
this.entrySize = ( int )this.currEntry.getSize();
this.entrySize = (int)this.currEntry.getSize();
} }


if( this.currEntry != null && this.currEntry.isGNULongNameEntry() ) if( this.currEntry != null && this.currEntry.isGNULongNameEntry() )
{ {
// read in the name // read in the name
StringBuffer longName = new StringBuffer(); StringBuffer longName = new StringBuffer();
byte[] buffer = new byte[256];
byte[] buffer = new byte[ 256 ];
int length = 0; int length = 0;
while( ( length = read( buffer ) ) >= 0 ) while( ( length = read( buffer ) ) >= 0 )
{ {
@@ -240,7 +241,7 @@ public class TarInputStream extends FilterInputStream
public void copyEntryContents( OutputStream out ) public void copyEntryContents( OutputStream out )
throws IOException throws IOException
{ {
byte[] buf = new byte[32 * 1024];
byte[] buf = new byte[ 32 * 1024 ];


while( true ) while( true )
{ {
@@ -260,7 +261,9 @@ public class TarInputStream extends FilterInputStream
* *
* @param markLimit The limit to mark. * @param markLimit The limit to mark.
*/ */
public void mark( int markLimit ) { }
public void mark( int markLimit )
{
}


/** /**
* Since we do not support marking just yet, we return false. * Since we do not support marking just yet, we return false.
@@ -290,7 +293,7 @@ public class TarInputStream extends FilterInputStream
} }
else else
{ {
return ( int )this.oneBuf[0];
return (int)this.oneBuf[ 0 ];
} }
} }


@@ -337,7 +340,7 @@ public class TarInputStream extends FilterInputStream
if( this.readBuf != null ) if( this.readBuf != null )
{ {
int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length
: numToRead;
: numToRead;


System.arraycopy( this.readBuf, 0, buf, offset, sz ); System.arraycopy( this.readBuf, 0, buf, offset, sz );


@@ -348,7 +351,7 @@ public class TarInputStream extends FilterInputStream
else else
{ {
int newLen = this.readBuf.length - sz; int newLen = this.readBuf.length - sz;
byte[] newBuf = new byte[newLen];
byte[] newBuf = new byte[ newLen ];


System.arraycopy( this.readBuf, sz, newBuf, 0, newLen ); System.arraycopy( this.readBuf, sz, newBuf, 0, newLen );


@@ -368,7 +371,7 @@ public class TarInputStream extends FilterInputStream
{ {
// Unexpected EOF! // Unexpected EOF!
throw new IOException( "unexpected EOF with " + numToRead throw new IOException( "unexpected EOF with " + numToRead
+ " bytes unread" );
+ " bytes unread" );
} }


int sz = numToRead; int sz = numToRead;
@@ -378,7 +381,7 @@ public class TarInputStream extends FilterInputStream
{ {
System.arraycopy( rec, 0, buf, offset, sz ); System.arraycopy( rec, 0, buf, offset, sz );


this.readBuf = new byte[recLen - sz];
this.readBuf = new byte[ recLen - sz ];


System.arraycopy( rec, sz, this.readBuf, 0, recLen - sz ); System.arraycopy( rec, sz, this.readBuf, 0, recLen - sz );
} }
@@ -402,7 +405,9 @@ public class TarInputStream extends FilterInputStream
/** /**
* Since we do not support marking just yet, we do nothing. * Since we do not support marking just yet, we do nothing.
*/ */
public void reset() { }
public void reset()
{
}


/** /**
* Skip bytes in the input buffer. This skips bytes in the current entry's * Skip bytes in the input buffer. This skips bytes in the current entry's
@@ -420,13 +425,13 @@ public class TarInputStream extends FilterInputStream
// This is horribly inefficient, but it ensures that we // This is horribly inefficient, but it ensures that we
// properly skip over bytes via the TarBuffer... // properly skip over bytes via the TarBuffer...
// //
byte[] skipBuf = new byte[8 * 1024];
byte[] skipBuf = new byte[ 8 * 1024 ];


for( int num = numToSkip; num > 0; )
for( int num = numToSkip; num > 0; )
{ {
int numRead = this.read( skipBuf, 0, int numRead = this.read( skipBuf, 0,
( num > skipBuf.length ? skipBuf.length
: num ) );
( num > skipBuf.length ? skipBuf.length
: num ) );


if( numRead == -1 ) if( numRead == -1 )
{ {


+ 19
- 19
proposal/myrmidon/src/todo/org/apache/tools/tar/TarOutputStream.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.tar; package org.apache.tools.tar;

import java.io.FilterOutputStream; import java.io.FilterOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@@ -50,9 +51,9 @@ public class TarOutputStream extends FilterOutputStream
this.buffer = new TarBuffer( os, blockSize, recordSize ); this.buffer = new TarBuffer( os, blockSize, recordSize );
this.debug = false; this.debug = false;
this.assemLen = 0; this.assemLen = 0;
this.assemBuf = new byte[recordSize];
this.recordBuf = new byte[recordSize];
this.oneBuf = new byte[1];
this.assemBuf = new byte[ recordSize ];
this.recordBuf = new byte[ recordSize ];
this.oneBuf = new byte[ 1 ];
} }


/** /**
@@ -65,7 +66,6 @@ public class TarOutputStream extends FilterOutputStream
this.buffer.setDebug( debug ); this.buffer.setDebug( debug );
} }



/** /**
* Sets the debugging flag. * Sets the debugging flag.
* *
@@ -120,7 +120,7 @@ public class TarOutputStream extends FilterOutputStream
{ {
for( int i = this.assemLen; i < this.assemBuf.length; ++i ) for( int i = this.assemLen; i < this.assemBuf.length; ++i )
{ {
this.assemBuf[i] = 0;
this.assemBuf[ i ] = 0;
} }


this.buffer.writeRecord( this.assemBuf ); this.buffer.writeRecord( this.assemBuf );
@@ -132,8 +132,8 @@ public class TarOutputStream extends FilterOutputStream
if( this.currBytes < this.currSize ) if( this.currBytes < this.currSize )
{ {
throw new IOException( "entry closed at '" + this.currBytes throw new IOException( "entry closed at '" + this.currBytes
+ "' before the '" + this.currSize
+ "' bytes specified in the header were written" );
+ "' before the '" + this.currSize
+ "' bytes specified in the header were written" );
} }
} }


@@ -171,7 +171,7 @@ public class TarOutputStream extends FilterOutputStream
// create a TarEntry for the LongLink, the contents // create a TarEntry for the LongLink, the contents
// of which are the entry's name // of which are the entry's name
TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK, TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK,
TarConstants.LF_GNUTYPE_LONGNAME );
TarConstants.LF_GNUTYPE_LONGNAME );


longLinkEntry.setSize( entry.getName().length() + 1 ); longLinkEntry.setSize( entry.getName().length() + 1 );
putNextEntry( longLinkEntry ); putNextEntry( longLinkEntry );
@@ -182,8 +182,8 @@ public class TarOutputStream extends FilterOutputStream
else if( longFileMode != LONGFILE_TRUNCATE ) else if( longFileMode != LONGFILE_TRUNCATE )
{ {
throw new RuntimeException( "file name '" + entry.getName() throw new RuntimeException( "file name '" + entry.getName()
+ "' is too long ( > "
+ TarConstants.NAMELEN + " bytes)" );
+ "' is too long ( > "
+ TarConstants.NAMELEN + " bytes)" );
} }
} }


@@ -198,7 +198,7 @@ public class TarOutputStream extends FilterOutputStream
} }
else else
{ {
this.currSize = ( int )entry.getSize();
this.currSize = (int)entry.getSize();
} }
} }


@@ -212,7 +212,7 @@ public class TarOutputStream extends FilterOutputStream
public void write( int b ) public void write( int b )
throws IOException throws IOException
{ {
this.oneBuf[0] = ( byte )b;
this.oneBuf[ 0 ] = (byte)b;


this.write( this.oneBuf, 0, 1 ); this.write( this.oneBuf, 0, 1 );
} }
@@ -249,8 +249,8 @@ public class TarOutputStream extends FilterOutputStream
if( ( this.currBytes + numToWrite ) > this.currSize ) if( ( this.currBytes + numToWrite ) > this.currSize )
{ {
throw new IOException( "request to write '" + numToWrite throw new IOException( "request to write '" + numToWrite
+ "' bytes exceeds size in header of '"
+ this.currSize + "' bytes" );
+ "' bytes exceeds size in header of '"
+ this.currSize + "' bytes" );
// //
// We have to deal with assembly!!! // We have to deal with assembly!!!
// The programmer can be writing little 32 byte chunks for all // The programmer can be writing little 32 byte chunks for all
@@ -267,9 +267,9 @@ public class TarOutputStream extends FilterOutputStream
int aLen = this.recordBuf.length - this.assemLen; int aLen = this.recordBuf.length - this.assemLen;


System.arraycopy( this.assemBuf, 0, this.recordBuf, 0, System.arraycopy( this.assemBuf, 0, this.recordBuf, 0,
this.assemLen );
this.assemLen );
System.arraycopy( wBuf, wOffset, this.recordBuf, System.arraycopy( wBuf, wOffset, this.recordBuf,
this.assemLen, aLen );
this.assemLen, aLen );
this.buffer.writeRecord( this.recordBuf ); this.buffer.writeRecord( this.recordBuf );


this.currBytes += this.recordBuf.length; this.currBytes += this.recordBuf.length;
@@ -280,7 +280,7 @@ public class TarOutputStream extends FilterOutputStream
else else
{ {
System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen,
numToWrite );
numToWrite );


wOffset += numToWrite; wOffset += numToWrite;
this.assemLen += numToWrite; this.assemLen += numToWrite;
@@ -298,7 +298,7 @@ public class TarOutputStream extends FilterOutputStream
if( numToWrite < this.recordBuf.length ) if( numToWrite < this.recordBuf.length )
{ {
System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen,
numToWrite );
numToWrite );


this.assemLen += numToWrite; this.assemLen += numToWrite;


@@ -326,7 +326,7 @@ public class TarOutputStream extends FilterOutputStream
{ {
for( int i = 0; i < this.recordBuf.length; ++i ) for( int i = 0; i < this.recordBuf.length; ++i )
{ {
this.recordBuf[i] = 0;
this.recordBuf[ i ] = 0;
} }


this.buffer.writeRecord( this.recordBuf ); this.buffer.writeRecord( this.recordBuf );


+ 18
- 18
proposal/myrmidon/src/todo/org/apache/tools/tar/TarUtils.java View File

@@ -30,8 +30,8 @@ public class TarUtils
{ {
getOctalBytes( value, buf, offset, length ); getOctalBytes( value, buf, offset, length );


buf[offset + length - 1] = ( byte )' ';
buf[offset + length - 2] = 0;
buf[ offset + length - 1 ] = (byte)' ';
buf[ offset + length - 2 ] = 0;


return offset + length; return offset + length;
} }
@@ -47,7 +47,7 @@ public class TarUtils
*/ */
public static int getLongOctalBytes( long value, byte[] buf, int offset, int length ) public static int getLongOctalBytes( long value, byte[] buf, int offset, int length )
{ {
byte[] temp = new byte[length + 1];
byte[] temp = new byte[ length + 1 ];


getOctalBytes( value, temp, 0, length + 1 ); getOctalBytes( value, temp, 0, length + 1 );
System.arraycopy( temp, 0, buf, offset, length ); System.arraycopy( temp, 0, buf, offset, length );
@@ -70,12 +70,12 @@ public class TarUtils


for( i = 0; i < length && i < name.length(); ++i ) for( i = 0; i < length && i < name.length(); ++i )
{ {
buf[offset + i] = ( byte )name.charAt( i );
buf[ offset + i ] = (byte)name.charAt( i );
} }


for( ; i < length; ++i ) for( ; i < length; ++i )
{ {
buf[offset + i] = 0;
buf[ offset + i ] = 0;
} }


return offset + length; return offset + length;
@@ -92,31 +92,31 @@ public class TarUtils
*/ */
public static int getOctalBytes( long value, byte[] buf, int offset, int length ) public static int getOctalBytes( long value, byte[] buf, int offset, int length )
{ {
byte[] result = new byte[length];
byte[] result = new byte[ length ];
int idx = length - 1; int idx = length - 1;


buf[offset + idx] = 0;
buf[ offset + idx ] = 0;
--idx; --idx;
buf[offset + idx] = ( byte )' ';
buf[ offset + idx ] = (byte)' ';
--idx; --idx;


if( value == 0 ) if( value == 0 )
{ {
buf[offset + idx] = ( byte )'0';
buf[ offset + idx ] = (byte)'0';
--idx; --idx;
} }
else else
{ {
for( long val = value; idx >= 0 && val > 0; --idx ) for( long val = value; idx >= 0 && val > 0; --idx )
{ {
buf[offset + idx] = ( byte )( ( byte )'0' + ( byte )( val & 7 ) );
buf[ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
val = val >> 3; val = val >> 3;
} }
} }


for( ; idx >= 0; --idx ) for( ; idx >= 0; --idx )
{ {
buf[offset + idx] = ( byte )' ';
buf[ offset + idx ] = (byte)' ';
} }


return offset + length; return offset + length;
@@ -134,7 +134,7 @@ public class TarUtils


for( int i = 0; i < buf.length; ++i ) for( int i = 0; i < buf.length; ++i )
{ {
sum += 255 & buf[i];
sum += 255 & buf[ i ];
} }


return sum; return sum;
@@ -155,12 +155,12 @@ public class TarUtils


for( int i = offset; i < end; ++i ) for( int i = offset; i < end; ++i )
{ {
if( header[i] == 0 )
if( header[ i ] == 0 )
{ {
break; break;
} }


result.append( ( char )header[i] );
result.append( (char)header[ i ] );
} }


return result; return result;
@@ -183,26 +183,26 @@ public class TarUtils


for( int i = offset; i < end; ++i ) for( int i = offset; i < end; ++i )
{ {
if( header[i] == 0 )
if( header[ i ] == 0 )
{ {
break; break;
} }


if( header[i] == ( byte )' ' || header[i] == '0' )
if( header[ i ] == (byte)' ' || header[ i ] == '0' )
{ {
if( stillPadding ) if( stillPadding )
{ {
continue; continue;
} }


if( header[i] == ( byte )' ' )
if( header[ i ] == (byte)' ' )
{ {
break; break;
} }
} }


stillPadding = false; stillPadding = false;
result = ( result << 3 ) + ( header[i] - '0' );
result = ( result << 3 ) + ( header[ i ] - '0' );
} }


return result; return result;


+ 19
- 16
proposal/myrmidon/src/todo/org/apache/tools/zip/AsiExtraField.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.util.zip.CRC32; import java.util.zip.CRC32;
import java.util.zip.ZipException; import java.util.zip.ZipException;


@@ -79,7 +80,9 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
*/ */
private CRC32 crc = new CRC32(); private CRC32 crc = new CRC32();


public AsiExtraField() { }
public AsiExtraField()
{
}


/** /**
* Indicate whether this entry is a directory. * Indicate whether this entry is a directory.
@@ -205,17 +208,17 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
public byte[] getLocalFileDataData() public byte[] getLocalFileDataData()
{ {
// CRC will be added later // CRC will be added later
byte[] data = new byte[getLocalFileDataLength().getValue() - 4];
byte[] data = new byte[ getLocalFileDataLength().getValue() - 4 ];
System.arraycopy( ( new ZipShort( getMode() ) ).getBytes(), 0, data, 0, 2 ); System.arraycopy( ( new ZipShort( getMode() ) ).getBytes(), 0, data, 0, 2 );


byte[] linkArray = getLinkedFile().getBytes(); byte[] linkArray = getLinkedFile().getBytes();
System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(), System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(),
0, data, 2, 4 );
0, data, 2, 4 );


System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(), System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(),
0, data, 6, 2 );
0, data, 6, 2 );
System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(), System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(),
0, data, 8, 2 );
0, data, 8, 2 );


System.arraycopy( linkArray, 0, data, 10, linkArray.length ); System.arraycopy( linkArray, 0, data, 10, linkArray.length );


@@ -223,7 +226,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
crc.update( data ); crc.update( data );
long checksum = crc.getValue(); long checksum = crc.getValue();


byte[] result = new byte[data.length + 4];
byte[] result = new byte[ data.length + 4 ];
System.arraycopy( ( new ZipLong( checksum ) ).getBytes(), 0, result, 0, 4 ); System.arraycopy( ( new ZipLong( checksum ) ).getBytes(), 0, result, 0, 4 );
System.arraycopy( data, 0, result, 4, data.length ); System.arraycopy( data, 0, result, 4, data.length );
return result; return result;
@@ -239,11 +242,11 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
public ZipShort getLocalFileDataLength() public ZipShort getLocalFileDataLength()
{ {
return new ZipShort( 4// CRC return new ZipShort( 4// CRC
+ 2// Mode
+ 4// SizDev
+ 2// UID
+ 2// GID
+ getLinkedFile().getBytes().length );
+ 2// Mode
+ 4// SizDev
+ 2// UID
+ 2// GID
+ getLinkedFile().getBytes().length );
} }


/** /**
@@ -304,7 +307,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
{ {


long givenChecksum = ( new ZipLong( data, offset ) ).getValue(); long givenChecksum = ( new ZipLong( data, offset ) ).getValue();
byte[] tmp = new byte[length - 4];
byte[] tmp = new byte[ length - 4 ];
System.arraycopy( data, offset + 4, tmp, 0, length - 4 ); System.arraycopy( data, offset + 4, tmp, 0, length - 4 );
crc.reset(); crc.reset();
crc.update( tmp ); crc.update( tmp );
@@ -312,13 +315,13 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
if( givenChecksum != realChecksum ) if( givenChecksum != realChecksum )
{ {
throw new ZipException( "bad CRC checksum " throw new ZipException( "bad CRC checksum "
+ Long.toHexString( givenChecksum )
+ " instead of "
+ Long.toHexString( realChecksum ) );
+ Long.toHexString( givenChecksum )
+ " instead of "
+ Long.toHexString( realChecksum ) );
} }


int newMode = ( new ZipShort( tmp, 0 ) ).getValue(); int newMode = ( new ZipShort( tmp, 0 ) ).getValue();
byte[] linkArray = new byte[( int )( new ZipLong( tmp, 2 ) ).getValue()];
byte[] linkArray = new byte[ (int)( new ZipLong( tmp, 2 ) ).getValue() ];
uid = ( new ZipShort( tmp, 6 ) ).getValue(); uid = ( new ZipShort( tmp, 6 ) ).getValue();
gid = ( new ZipShort( tmp, 8 ) ).getValue(); gid = ( new ZipShort( tmp, 8 ) ).getValue();




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/zip/UnrecognizedExtraField.java View File

@@ -92,7 +92,7 @@ public class UnrecognizedExtraField implements ZipExtraField


public void parseFromLocalFileData( byte[] data, int offset, int length ) public void parseFromLocalFileData( byte[] data, int offset, int length )
{ {
byte[] tmp = new byte[length];
byte[] tmp = new byte[ length ];
System.arraycopy( data, offset, tmp, 0, length ); System.arraycopy( data, offset, tmp, 0, length );
setLocalFileDataData( tmp ); setLocalFileDataData( tmp );
} }


+ 12
- 11
proposal/myrmidon/src/todo/org/apache/tools/zip/ZipEntry.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@@ -120,7 +121,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
public ZipEntry( ZipEntry entry ) public ZipEntry( ZipEntry entry )
throws ZipException throws ZipException
{ {
this( ( java.util.zip.ZipEntry )entry );
this( (java.util.zip.ZipEntry)entry );
setInternalAttributes( entry.getInternalAttributes() ); setInternalAttributes( entry.getInternalAttributes() );
setExternalAttributes( entry.getExternalAttributes() ); setExternalAttributes( entry.getExternalAttributes() );
setExtraFields( entry.getExtraFields() ); setExtraFields( entry.getExtraFields() );
@@ -142,7 +143,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
{ {
setCompressedSizeMethod = setCompressedSizeMethod =
java.util.zip.ZipEntry.class.getMethod( "setCompressedSize", java.util.zip.ZipEntry.class.getMethod( "setCompressedSize",
new Class[]{Long.TYPE} );
new Class[]{Long.TYPE} );
} }
catch( NoSuchMethodException nse ) catch( NoSuchMethodException nse )
{ {
@@ -181,14 +182,14 @@ public class ZipEntry extends java.util.zip.ZipEntry
{ {
Throwable nested = ite.getTargetException(); Throwable nested = ite.getTargetException();
throw new RuntimeException( "Exception setting the compressed size " throw new RuntimeException( "Exception setting the compressed size "
+ "of " + ze + ": "
+ nested.getMessage() );
+ "of " + ze + ": "
+ nested.getMessage() );
} }
catch( Throwable other ) catch( Throwable other )
{ {
throw new RuntimeException( "Exception setting the compressed size " throw new RuntimeException( "Exception setting the compressed size "
+ "of " + ze + ": "
+ other.getMessage() );
+ "of " + ze + ": "
+ other.getMessage() );
} }
} }


@@ -255,7 +256,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
extraFields.clear(); extraFields.clear();
for( int i = 0; i < fields.length; i++ ) for( int i = 0; i < fields.length; i++ )
{ {
extraFields.add( fields[i] );
extraFields.add( fields[ i ] );
} }
setExtra(); setExtra();
} }
@@ -341,7 +342,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
public byte[] getLocalFileDataExtra() public byte[] getLocalFileDataExtra()
{ {
byte[] extra = getExtra(); byte[] extra = getExtra();
return extra != null ? extra : new byte[0];
return extra != null ? extra : new byte[ 0 ];
} }


/** /**
@@ -357,7 +358,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
boolean done = false; boolean done = false;
for( int i = 0; !done && i < extraFields.size(); i++ ) for( int i = 0; !done && i < extraFields.size(); i++ )
{ {
if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
{ {
extraFields.set( i, ze ); extraFields.set( i, ze );
done = true; done = true;
@@ -381,7 +382,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
ZipEntry e = null; ZipEntry e = null;
try try
{ {
e = new ZipEntry( ( java.util.zip.ZipEntry )super.clone() );
e = new ZipEntry( (java.util.zip.ZipEntry)super.clone() );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@@ -405,7 +406,7 @@ public class ZipEntry extends java.util.zip.ZipEntry
boolean done = false; boolean done = false;
for( int i = 0; !done && i < extraFields.size(); i++ ) for( int i = 0; !done && i < extraFields.size(); i++ )
{ {
if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
{ {
extraFields.remove( i ); extraFields.remove( i );
done = true; done = true;


+ 1
- 0
proposal/myrmidon/src/todo/org/apache/tools/zip/ZipExtraField.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.util.zip.ZipException; import java.util.zip.ZipException;


/** /**


+ 11
- 11
proposal/myrmidon/src/todo/org/apache/tools/zip/ZipLong.java View File

@@ -50,10 +50,10 @@ public class ZipLong implements Cloneable
*/ */
public ZipLong( byte[] bytes, int offset ) public ZipLong( byte[] bytes, int offset )
{ {
value = ( bytes[offset + 3] << 24 ) & 0xFF000000l;
value += ( bytes[offset + 2] << 16 ) & 0xFF0000;
value += ( bytes[offset + 1] << 8 ) & 0xFF00;
value += ( bytes[offset] & 0xFF );
value = ( bytes[ offset + 3 ] << 24 ) & 0xFF000000l;
value += ( bytes[ offset + 2 ] << 16 ) & 0xFF0000;
value += ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
value += ( bytes[ offset ] & 0xFF );
} }


/** /**
@@ -64,11 +64,11 @@ public class ZipLong implements Cloneable
*/ */
public byte[] getBytes() public byte[] getBytes()
{ {
byte[] result = new byte[4];
result[0] = ( byte )( ( value & 0xFF ) );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
byte[] result = new byte[ 4 ];
result[ 0 ] = (byte)( ( value & 0xFF ) );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
return result; return result;
} }


@@ -96,7 +96,7 @@ public class ZipLong implements Cloneable
{ {
return false; return false;
} }
return value == ( ( ZipLong )o ).getValue();
return value == ( (ZipLong)o ).getValue();
} }


/** /**
@@ -107,7 +107,7 @@ public class ZipLong implements Cloneable
*/ */
public int hashCode() public int hashCode()
{ {
return ( int )value;
return (int)value;
} }


}// ZipLong }// ZipLong

+ 23
- 22
proposal/myrmidon/src/todo/org/apache/tools/zip/ZipOutputStream.java View File

@@ -6,12 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.zip; package org.apache.tools.zip;

import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.ArrayList;
import java.util.zip.CRC32; import java.util.zip.CRC32;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
@@ -216,17 +217,17 @@ public class ZipOutputStream extends DeflaterOutputStream
return DOS_TIME_MIN; return DOS_TIME_MIN;
} }
long value = ( ( year - 1980 ) << 25 ) long value = ( ( year - 1980 ) << 25 )
| ( month << 21 )
| ( time.getDate() << 16 )
| ( time.getHours() << 11 )
| ( time.getMinutes() << 5 )
| ( time.getSeconds() >> 1 );
byte[] result = new byte[4];
result[0] = ( byte )( ( value & 0xFF ) );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
| ( month << 21 )
| ( time.getDate() << 16 )
| ( time.getHours() << 11 )
| ( time.getMinutes() << 5 )
| ( time.getSeconds() >> 1 );
byte[] result = new byte[ 4 ];
result[ 0 ] = (byte)( ( value & 0xFF ) );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
return new ZipLong( result ); return new ZipLong( result );
} }


@@ -332,19 +333,19 @@ public class ZipOutputStream extends DeflaterOutputStream
if( entry.getCrc() != realCrc ) if( entry.getCrc() != realCrc )
{ {
throw new ZipException( "bad CRC checksum for entry " throw new ZipException( "bad CRC checksum for entry "
+ entry.getName() + ": "
+ Long.toHexString( entry.getCrc() )
+ " instead of "
+ Long.toHexString( realCrc ) );
+ entry.getName() + ": "
+ Long.toHexString( entry.getCrc() )
+ " instead of "
+ Long.toHexString( realCrc ) );
} }


if( entry.getSize() != written - dataStart ) if( entry.getSize() != written - dataStart )
{ {
throw new ZipException( "bad size for entry " throw new ZipException( "bad size for entry "
+ entry.getName() + ": "
+ entry.getSize()
+ " instead of "
+ ( written - dataStart ) );
+ entry.getName() + ": "
+ entry.getSize()
+ " instead of "
+ ( written - dataStart ) );
} }


} }
@@ -372,7 +373,7 @@ public class ZipOutputStream extends DeflaterOutputStream
cdOffset = new ZipLong( written ); cdOffset = new ZipLong( written );
for( int i = 0; i < entries.size(); i++ ) for( int i = 0; i < entries.size(); i++ )
{ {
writeCentralFileHeader( ( ZipEntry )entries.get( i ) );
writeCentralFileHeader( (ZipEntry)entries.get( i ) );
} }
cdLength = new ZipLong( written - cdOffset.getValue() ); cdLength = new ZipLong( written - cdOffset.getValue() );
writeCentralDirectoryEnd(); writeCentralDirectoryEnd();
@@ -593,7 +594,7 @@ public class ZipOutputStream extends DeflaterOutputStream
written += 4; written += 4;


// relative offset of LFH // relative offset of LFH
out.write( ( ( ZipLong )offsets.get( ze ) ).getBytes() );
out.write( ( (ZipLong)offsets.get( ze ) ).getBytes() );
written += 4; written += 4;


// file name // file name


+ 6
- 6
proposal/myrmidon/src/todo/org/apache/tools/zip/ZipShort.java View File

@@ -50,8 +50,8 @@ public class ZipShort implements Cloneable
*/ */
public ZipShort( byte[] bytes, int offset ) public ZipShort( byte[] bytes, int offset )
{ {
value = ( bytes[offset + 1] << 8 ) & 0xFF00;
value += ( bytes[offset] & 0xFF );
value = ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
value += ( bytes[ offset ] & 0xFF );
} }


/** /**
@@ -62,9 +62,9 @@ public class ZipShort implements Cloneable
*/ */
public byte[] getBytes() public byte[] getBytes()
{ {
byte[] result = new byte[2];
result[0] = ( byte )( value & 0xFF );
result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
byte[] result = new byte[ 2 ];
result[ 0 ] = (byte)( value & 0xFF );
result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
return result; return result;
} }


@@ -92,7 +92,7 @@ public class ZipShort implements Cloneable
{ {
return false; return false;
} }
return value == ( ( ZipShort )o ).getValue();
return value == ( (ZipShort)o ).getValue();
} }


/** /**


Loading…
Cancel
Save