git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270312 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -437,7 +437,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| Execute exe = new Execute( new LogStreamHandler( attributes, | |||
| Project.MSG_INFO, | |||
| Project.MSG_WARN ) ); | |||
| exe.setAntRun( project ); | |||
| exe.setWorkingDirectory( project.getBaseDir() ); | |||
| exe.setCommandline( commandArray ); | |||
| exe.execute(); | |||
| @@ -7,7 +7,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Iterator; | |||
| import java.util.Enumeration; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -7,10 +7,9 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Iterator; | |||
| import java.util.NoSuchElementException; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.NoSuchElementException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| import org.apache.tools.ant.taskdefs.Available; | |||
| @@ -10,10 +10,9 @@ package org.apache.tools.ant.taskdefs.file; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Iterator; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -457,8 +457,8 @@ public class Delete | |||
| if( dirCount > 0 ) | |||
| { | |||
| getLogger().info( "Deleted " + dirCount + " director" + | |||
| ( dirCount == 1 ? "y" : "ies" ) + | |||
| " from " + d.getAbsolutePath() ); | |||
| ( dirCount == 1 ? "y" : "ies" ) + | |||
| " from " + d.getAbsolutePath() ); | |||
| } | |||
| } | |||
| } | |||
| @@ -9,16 +9,15 @@ package org.apache.tools.ant.taskdefs.file; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Iterator; | |||
| import java.util.Iterator; | |||
| import java.util.Enumeration; | |||
| import java.util.Iterator; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| 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.FilterSet; | |||
| 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 | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.taskdefs.rmic; | |||
| import java.io.File; | |||
| import java.util.Random; | |||
| import java.util.ArrayList; | |||
| import java.util.Random; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.Rmic; | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| /** | |||
| @@ -8,9 +8,9 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.Stack; | |||
| import java.util.ArrayList; | |||
| import java.util.Stack; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.FileScanner; | |||
| @@ -10,11 +10,11 @@ package org.apache.tools.ant.types;// java io classes | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.Properties; | |||
| import java.util.ArrayList; | |||
| 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.tools.ant.Project; | |||
| @@ -9,8 +9,8 @@ package org.apache.tools.ant.types;// java io classes | |||
| // java util classes | |||
| import java.util.Iterator; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| // ant classes | |||
| @@ -8,10 +8,10 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Locale; | |||
| import java.util.Stack; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -11,10 +11,10 @@ import java.io.BufferedReader; | |||
| import java.io.File; | |||
| import java.io.FileReader; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -357,7 +357,7 @@ public class PatternSet extends DataType | |||
| } | |||
| final String[] result = new String[ tmpNames.size() ]; | |||
| return (String[]) tmpNames.toArray( result ); | |||
| return (String[])tmpNames.toArray( result ); | |||
| } | |||
| /** | |||
| @@ -9,11 +9,11 @@ package org.apache.tools.ant.util; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| /** | |||
| * Utility class that collects the functionality of the various scanDir methods | |||
| @@ -78,7 +78,7 @@ public class SourceFileScanner | |||
| if( targets == null || targets.length == 0 ) | |||
| { | |||
| m_task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| continue; | |||
| } | |||
| @@ -87,7 +87,7 @@ public class SourceFileScanner | |||
| if( src.lastModified() > now ) | |||
| { | |||
| m_task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| Project.MSG_WARN ); | |||
| Project.MSG_WARN ); | |||
| } | |||
| boolean added = false; | |||
| @@ -99,14 +99,14 @@ public class SourceFileScanner | |||
| if( !dest.exists() ) | |||
| { | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| v.add( files[ i ] ); | |||
| added = true; | |||
| } | |||
| else if( src.lastModified() > dest.lastModified() ) | |||
| { | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| v.add( files[ i ] ); | |||
| added = true; | |||
| } | |||
| @@ -123,8 +123,8 @@ public class SourceFileScanner | |||
| if( !added ) | |||
| { | |||
| 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 ); | |||
| } | |||
| } | |||
| @@ -80,5 +80,5 @@ public interface BZip2Constants | |||
| 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, | |||
| 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, | |||
| 936, 638 | |||
| }; | |||
| }; | |||
| } | |||
| @@ -6,7 +6,9 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| 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 | |||
| @@ -26,24 +28,24 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private final static int NO_RAND_PART_C_STATE = 7; | |||
| 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 | |||
| * 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; | |||
| @@ -146,28 +148,28 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| else | |||
| { | |||
| 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; | |||
| } | |||
| @@ -176,7 +178,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setDecompressStructureSizes( int newSize100k ) | |||
| { | |||
| if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k | |||
| && blockSize100k <= 9 ) ) | |||
| && blockSize100k <= 9 ) ) | |||
| { | |||
| // throw new IOException("Invalid block size"); | |||
| } | |||
| @@ -187,30 +189,30 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| return; | |||
| int n = baseBlockSize * newSize100k; | |||
| ll8 = new char[n]; | |||
| tt = new int[n]; | |||
| ll8 = new char[ n ]; | |||
| tt = new int[ n ]; | |||
| } | |||
| private void setupBlock() | |||
| { | |||
| int cftab[] = new int[257]; | |||
| int cftab[] = new int[ 257 ]; | |||
| char ch; | |||
| cftab[0] = 0; | |||
| cftab[ 0 ] = 0; | |||
| for( i = 1; i <= 256; i++ ) | |||
| cftab[i] = unzftab[i - 1]; | |||
| cftab[ i ] = unzftab[ i - 1 ]; | |||
| for( i = 1; i <= 256; i++ ) | |||
| cftab[i] += cftab[i - 1]; | |||
| cftab[ i ] += cftab[ i - 1 ]; | |||
| 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; | |||
| tPos = tt[origPtr]; | |||
| tPos = tt[ origPtr ]; | |||
| count = 0; | |||
| i2 = 0; | |||
| @@ -235,8 +237,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( i2 <= last ) | |||
| { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| ch2 = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| i2++; | |||
| currentChar = ch2; | |||
| @@ -264,8 +266,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| count++; | |||
| if( count >= 4 ) | |||
| { | |||
| z = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| z = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| currentState = NO_RAND_PART_C_STATE; | |||
| j2 = 0; | |||
| setupNoRandPartC(); | |||
| @@ -280,7 +282,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setupNoRandPartC() | |||
| { | |||
| if( j2 < ( int )z ) | |||
| if( j2 < (int)z ) | |||
| { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC( ch2 ); | |||
| @@ -300,17 +302,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( i2 <= last ) | |||
| { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| ch2 = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| if( rNToGo == 0 ) | |||
| { | |||
| rNToGo = rNums[rTPos]; | |||
| rNToGo = rNums[ rTPos ]; | |||
| rTPos++; | |||
| if( rTPos == 512 ) | |||
| rTPos = 0; | |||
| } | |||
| rNToGo--; | |||
| ch2 ^= ( int )( ( rNToGo == 1 ) ? 1 : 0 ); | |||
| ch2 ^= (int)( ( rNToGo == 1 ) ? 1 : 0 ); | |||
| i2++; | |||
| currentChar = ch2; | |||
| @@ -338,11 +340,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| count++; | |||
| if( count >= 4 ) | |||
| { | |||
| z = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| z = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| if( rNToGo == 0 ) | |||
| { | |||
| rNToGo = rNums[rTPos]; | |||
| rNToGo = rNums[ rTPos ]; | |||
| rTPos++; | |||
| if( rTPos == 512 ) | |||
| rTPos = 0; | |||
| @@ -363,7 +365,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setupRandPartC() | |||
| { | |||
| if( j2 < ( int )z ) | |||
| if( j2 < (int)z ) | |||
| { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC( ch2 ); | |||
| @@ -380,7 +382,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void getAndMoveToFrontDecode() | |||
| { | |||
| char yy[] = new char[256]; | |||
| char yy[] = new char[ 256 ]; | |||
| int i; | |||
| int j; | |||
| int nextSym; | |||
| @@ -404,10 +406,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| * cache misses. | |||
| */ | |||
| for( i = 0; i <= 255; i++ ) | |||
| unzftab[i] = 0; | |||
| unzftab[ i ] = 0; | |||
| for( i = 0; i <= 255; i++ ) | |||
| yy[i] = ( char )i; | |||
| yy[ i ] = (char)i; | |||
| last = -1; | |||
| { | |||
| @@ -421,10 +423,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -435,7 +437,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -455,7 +457,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| } | |||
| zvec = ( zvec << 1 ) | zj; | |||
| } | |||
| nextSym = perm[zt][zvec - base[zt][zn]]; | |||
| nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ]; | |||
| } | |||
| while( true ) | |||
| @@ -487,10 +489,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -501,7 +503,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -522,18 +524,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| 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++; | |||
| ch = seqToUnseq[yy[0]]; | |||
| unzftab[ch] += s; | |||
| ch = seqToUnseq[ yy[ 0 ] ]; | |||
| unzftab[ ch ] += s; | |||
| while( s > 0 ) | |||
| { | |||
| last++; | |||
| ll8[last] = ch; | |||
| ll8[ last ] = ch; | |||
| s--; | |||
| } | |||
| ; | |||
| @@ -549,9 +551,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( last >= limitLast ) | |||
| 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, | |||
| @@ -561,15 +563,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| j = nextSym - 1; | |||
| 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-- ) | |||
| yy[j] = yy[j - 1]; | |||
| yy[ j ] = yy[ j - 1 ]; | |||
| yy[0] = tmp; | |||
| yy[ 0 ] = tmp; | |||
| { | |||
| int zt; | |||
| int zn; | |||
| @@ -581,10 +583,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -595,7 +597,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -612,7 +614,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| zvec = ( zvec << 1 ) | zj; | |||
| } | |||
| ; | |||
| nextSym = perm[zt][zvec - base[zt][zn]]; | |||
| nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ]; | |||
| } | |||
| continue; | |||
| } | |||
| @@ -626,17 +628,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private int bsGetInt32() | |||
| { | |||
| return ( int )bsGetint(); | |||
| return (int)bsGetint(); | |||
| } | |||
| private int bsGetIntVS( int numBits ) | |||
| { | |||
| return ( int )bsR( numBits ); | |||
| return (int)bsR( numBits ); | |||
| } | |||
| private char bsGetUChar() | |||
| { | |||
| return ( char )bsR( 8 ); | |||
| return (char)bsR( 8 ); | |||
| } | |||
| private int bsGetint() | |||
| @@ -659,7 +661,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -709,7 +711,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| crcError(); | |||
| computedCombinedCRC = ( computedCombinedCRC << 1 ) | |||
| | ( computedCombinedCRC >>> 31 ); | |||
| | ( computedCombinedCRC >>> 31 ); | |||
| computedCombinedCRC ^= computedBlockCRC; | |||
| } | |||
| @@ -725,33 +727,33 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| pp = 0; | |||
| for( i = minLen; i <= maxLen; i++ ) | |||
| for( j = 0; j < alphaSize; j++ ) | |||
| if( length[j] == i ) | |||
| if( length[ j ] == i ) | |||
| { | |||
| perm[pp] = j; | |||
| perm[ pp ] = j; | |||
| pp++; | |||
| } | |||
| ; | |||
| for( i = 0; i < MAX_CODE_LEN; i++ ) | |||
| base[i] = 0; | |||
| base[ i ] = 0; | |||
| for( i = 0; i < alphaSize; i++ ) | |||
| base[length[i] + 1]++; | |||
| base[ length[ i ] + 1 ]++; | |||
| 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++ ) | |||
| limit[i] = 0; | |||
| limit[ i ] = 0; | |||
| vec = 0; | |||
| 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; | |||
| } | |||
| 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() | |||
| @@ -769,14 +771,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| magic5 = bsGetUChar(); | |||
| magic6 = bsGetUChar(); | |||
| if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 | |||
| && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 ) | |||
| && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 ) | |||
| { | |||
| complete(); | |||
| return; | |||
| } | |||
| if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 | |||
| || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 ) | |||
| || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 ) | |||
| { | |||
| badBlockHeader(); | |||
| streamEnd = true; | |||
| @@ -819,17 +821,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| int i; | |||
| nInUse = 0; | |||
| 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++; | |||
| } | |||
| } | |||
| private void recvDecodingTables() | |||
| { | |||
| char len[][] = new char[N_GROUPS][MAX_ALPHA_SIZE]; | |||
| char len[][] = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ]; | |||
| int i; | |||
| int j; | |||
| int t; | |||
| @@ -838,25 +840,25 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| int alphaSize; | |||
| int minLen; | |||
| int maxLen; | |||
| boolean inUse16[] = new boolean[16]; | |||
| boolean inUse16[] = new boolean[ 16 ]; | |||
| /* | |||
| * Receive the mapping table | |||
| */ | |||
| for( i = 0; i < 16; i++ ) | |||
| if( bsR( 1 ) == 1 ) | |||
| inUse16[i] = true; | |||
| inUse16[ i ] = true; | |||
| else | |||
| inUse16[i] = false; | |||
| inUse16[ i ] = false; | |||
| for( i = 0; i < 256; i++ ) | |||
| inUse[i] = false; | |||
| inUse[ i ] = false; | |||
| for( i = 0; i < 16; i++ ) | |||
| if( inUse16[i] ) | |||
| if( inUse16[ i ] ) | |||
| for( j = 0; j < 16; j++ ) | |||
| if( bsR( 1 ) == 1 ) | |||
| inUse[i * 16 + j] = true; | |||
| inUse[ i * 16 + j ] = true; | |||
| makeMaps(); | |||
| alphaSize = nInUse + 2; | |||
| @@ -871,29 +873,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| j = 0; | |||
| while( bsR( 1 ) == 1 ) | |||
| j++; | |||
| selectorMtf[i] = ( char )j; | |||
| selectorMtf[ i ] = (char)j; | |||
| } | |||
| { | |||
| /* | |||
| * Undo the MTF values for the selectors. | |||
| */ | |||
| char pos[] = new char[N_GROUPS]; | |||
| char pos[] = new char[ N_GROUPS ]; | |||
| char tmp; | |||
| char v; | |||
| for( v = 0; v < nGroups; v++ ) | |||
| pos[v] = v; | |||
| pos[ v ] = v; | |||
| for( i = 0; i < nSelectors; i++ ) | |||
| { | |||
| v = selectorMtf[i]; | |||
| tmp = pos[v]; | |||
| v = selectorMtf[ i ]; | |||
| tmp = pos[ v ]; | |||
| while( v > 0 ) | |||
| { | |||
| pos[v] = pos[v - 1]; | |||
| pos[ v ] = pos[ v - 1 ]; | |||
| 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 | |||
| curr--; | |||
| } | |||
| len[t][i] = ( char )curr; | |||
| len[ t ][ i ] = (char)curr; | |||
| } | |||
| } | |||
| @@ -925,14 +927,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| maxLen = 0; | |||
| 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; | |||
| } | |||
| } | |||
| } | |||
| @@ -80,7 +80,7 @@ class CRC | |||
| 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, | |||
| 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, | |||
| 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 | |||
| }; | |||
| }; | |||
| int globalCrc; | |||
| @@ -114,7 +114,7 @@ class CRC | |||
| int temp = ( globalCrc >> 24 ) ^ inCh; | |||
| if( temp < 0 ) | |||
| temp = 256 + temp; | |||
| globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[temp]; | |||
| globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[ temp ]; | |||
| } | |||
| } | |||
| @@ -6,16 +6,17 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.mail; | |||
| import java.io.BufferedOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.io.PrintStream; | |||
| import java.net.InetAddress; | |||
| import java.net.Socket; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| 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 | |||
| @@ -348,7 +349,7 @@ public class MailMessage | |||
| // Check that the response is one of the valid codes | |||
| for( int i = 0; i < ok.length; i++ ) | |||
| { | |||
| if( response.startsWith( "" + ok[i] ) ) | |||
| if( response.startsWith( "" + ok[ i ] ) ) | |||
| { | |||
| return true; | |||
| } | |||
| @@ -364,7 +365,7 @@ public class MailMessage | |||
| socket = new Socket( host, port ); | |||
| out = new MailPrintStream( | |||
| new BufferedOutputStream( | |||
| socket.getOutputStream() ) ); | |||
| socket.getOutputStream() ) ); | |||
| in = new SmtpResponseReader( socket.getInputStream() ); | |||
| getReady(); | |||
| } | |||
| @@ -387,8 +388,8 @@ public class MailMessage | |||
| Enumeration e = headers.keys(); | |||
| 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(); | |||
| @@ -471,6 +472,7 @@ public class MailMessage | |||
| // This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>.. | |||
| // per RFC 821. It also ensures that new lines are always \r\n. | |||
| // | |||
| class MailPrintStream extends PrintStream | |||
| { | |||
| @@ -506,7 +508,7 @@ class MailPrintStream extends PrintStream | |||
| { | |||
| for( int i = 0; i < len; i++ ) | |||
| { | |||
| write( buf[off + i] ); | |||
| write( buf[ off + i ] ); | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.mail; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| @@ -137,7 +138,7 @@ public class TarBuffer | |||
| { | |||
| for( int i = 0, sz = this.getRecordSize(); i < sz; ++i ) | |||
| { | |||
| if( record[i] != 0 ) | |||
| if( record[ i ] != 0 ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -165,7 +166,7 @@ public class TarBuffer | |||
| this.flushBlock(); | |||
| if( this.outStream != System.out | |||
| && this.outStream != System.err ) | |||
| && this.outStream != System.err ) | |||
| { | |||
| this.outStream.close(); | |||
| @@ -195,7 +196,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "ReadRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| 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, | |||
| ( this.currRecIdx * this.recordSize ), result, 0, | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), result, 0, | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| @@ -233,7 +234,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "SkipRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.inStream == null ) | |||
| @@ -264,7 +265,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.outStream == null ) | |||
| @@ -275,9 +276,9 @@ public class TarBuffer | |||
| if( record.length != this.recordSize ) | |||
| { | |||
| 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 ) | |||
| @@ -286,8 +287,8 @@ public class TarBuffer | |||
| } | |||
| System.arraycopy( record, 0, this.blockBuffer, | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| } | |||
| @@ -306,7 +307,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.outStream == null ) | |||
| @@ -317,9 +318,9 @@ public class TarBuffer | |||
| if( ( offset + this.recordSize ) > 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 ) | |||
| @@ -328,8 +329,8 @@ public class TarBuffer | |||
| } | |||
| System.arraycopy( buf, offset, this.blockBuffer, | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| } | |||
| @@ -370,7 +371,7 @@ public class TarBuffer | |||
| this.blockSize = blockSize; | |||
| this.recordSize = recordSize; | |||
| this.recsPerBlock = ( this.blockSize / this.recordSize ); | |||
| this.blockBuffer = new byte[this.blockSize]; | |||
| this.blockBuffer = new byte[ this.blockSize ]; | |||
| if( this.inStream != null ) | |||
| { | |||
| @@ -409,7 +410,7 @@ public class TarBuffer | |||
| while( bytesNeeded > 0 ) | |||
| { | |||
| long numBytes = this.inStream.read( this.blockBuffer, offset, | |||
| bytesNeeded ); | |||
| bytesNeeded ); | |||
| // | |||
| // NOTE | |||
| @@ -437,8 +438,8 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "ReadBlock: INCOMPLETE READ " | |||
| + numBytes + " of " + this.blockSize | |||
| + " bytes read." ); | |||
| + numBytes + " of " + this.blockSize | |||
| + " bytes read." ); | |||
| } | |||
| } | |||
| } | |||
| @@ -82,42 +82,42 @@ public interface TarConstants | |||
| /** | |||
| * Normal file type. | |||
| */ | |||
| byte LF_NORMAL = ( byte )'0'; | |||
| byte LF_NORMAL = (byte)'0'; | |||
| /** | |||
| * Link file type. | |||
| */ | |||
| byte LF_LINK = ( byte )'1'; | |||
| byte LF_LINK = (byte)'1'; | |||
| /** | |||
| * Symbolic link file type. | |||
| */ | |||
| byte LF_SYMLINK = ( byte )'2'; | |||
| byte LF_SYMLINK = (byte)'2'; | |||
| /** | |||
| * Character device file type. | |||
| */ | |||
| byte LF_CHR = ( byte )'3'; | |||
| byte LF_CHR = (byte)'3'; | |||
| /** | |||
| * Block device file type. | |||
| */ | |||
| byte LF_BLK = ( byte )'4'; | |||
| byte LF_BLK = (byte)'4'; | |||
| /** | |||
| * Directory file type. | |||
| */ | |||
| byte LF_DIR = ( byte )'5'; | |||
| byte LF_DIR = (byte)'5'; | |||
| /** | |||
| * FIFO (pipe) file type. | |||
| */ | |||
| byte LF_FIFO = ( byte )'6'; | |||
| byte LF_FIFO = (byte)'6'; | |||
| /** | |||
| * Contiguous file type. | |||
| */ | |||
| byte LF_CONTIG = ( byte )'7'; | |||
| byte LF_CONTIG = (byte)'7'; | |||
| /** | |||
| * 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. | |||
| */ | |||
| byte LF_GNUTYPE_LONGNAME = ( byte )'L'; | |||
| byte LF_GNUTYPE_LONGNAME = (byte)'L'; | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.File; | |||
| import java.util.Date; | |||
| @@ -190,8 +191,8 @@ public class TarEntry implements TarConstants | |||
| char ch2 = name.charAt( 1 ); | |||
| if( ch2 == ':' | |||
| && ( ( ch1 >= 'a' && ch1 <= 'z' ) | |||
| || ( ch1 >= 'A' && ch1 <= 'Z' ) ) ) | |||
| && ( ( ch1 >= 'a' && ch1 <= 'z' ) | |||
| || ( ch1 >= 'A' && ch1 <= 'Z' ) ) ) | |||
| { | |||
| name = name.substring( 2 ); | |||
| } | |||
| @@ -406,15 +407,15 @@ public class TarEntry implements TarConstants | |||
| { | |||
| if( this.file == null || !this.file.isDirectory() ) | |||
| { | |||
| return new TarEntry[0]; | |||
| return new TarEntry[ 0 ]; | |||
| } | |||
| 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 ) | |||
| { | |||
| result[i] = new TarEntry( new File( this.file, list[i] ) ); | |||
| result[ i ] = new TarEntry( new File( this.file, list[ i ] ) ); | |||
| } | |||
| return result; | |||
| @@ -490,7 +491,6 @@ public class TarEntry implements TarConstants | |||
| return this.size; | |||
| } | |||
| /** | |||
| * Get this entry's user id. | |||
| * | |||
| @@ -549,7 +549,6 @@ public class TarEntry implements TarConstants | |||
| return false; | |||
| } | |||
| /** | |||
| * 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 ); | |||
| offset += NAMELEN; | |||
| this.mode = ( int )TarUtils.parseOctal( header, offset, MODELEN ); | |||
| this.mode = (int)TarUtils.parseOctal( header, offset, MODELEN ); | |||
| offset += MODELEN; | |||
| this.userId = ( int )TarUtils.parseOctal( header, offset, UIDLEN ); | |||
| this.userId = (int)TarUtils.parseOctal( header, offset, UIDLEN ); | |||
| offset += UIDLEN; | |||
| this.groupId = ( int )TarUtils.parseOctal( header, offset, GIDLEN ); | |||
| this.groupId = (int)TarUtils.parseOctal( header, offset, GIDLEN ); | |||
| offset += GIDLEN; | |||
| this.size = TarUtils.parseOctal( header, offset, SIZELEN ); | |||
| offset += SIZELEN; | |||
| this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN ); | |||
| offset += MODTIMELEN; | |||
| this.checkSum = ( int )TarUtils.parseOctal( header, offset, CHKSUMLEN ); | |||
| this.checkSum = (int)TarUtils.parseOctal( header, offset, CHKSUMLEN ); | |||
| offset += CHKSUMLEN; | |||
| this.linkFlag = header[offset++]; | |||
| this.linkFlag = header[ offset++ ]; | |||
| this.linkName = TarUtils.parseName( header, offset, NAMELEN ); | |||
| offset += NAMELEN; | |||
| this.magic = TarUtils.parseName( header, offset, MAGICLEN ); | |||
| @@ -606,9 +605,9 @@ public class TarEntry implements TarConstants | |||
| offset += UNAMELEN; | |||
| this.groupName = TarUtils.parseName( header, offset, GNAMELEN ); | |||
| offset += GNAMELEN; | |||
| this.devMajor = ( int )TarUtils.parseOctal( header, offset, DEVLEN ); | |||
| this.devMajor = (int)TarUtils.parseOctal( header, 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 ) | |||
| { | |||
| 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.magic, outbuf, offset, MAGICLEN ); | |||
| offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN ); | |||
| @@ -644,7 +643,7 @@ public class TarEntry implements TarConstants | |||
| while( offset < outbuf.length ) | |||
| { | |||
| outbuf[offset++] = 0; | |||
| outbuf[ offset++ ] = 0; | |||
| } | |||
| long checkSum = TarUtils.computeCheckSum( outbuf ); | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.FilterInputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| @@ -48,7 +49,7 @@ public class TarInputStream extends FilterInputStream | |||
| this.buffer = new TarBuffer( is, blockSize, recordSize ); | |||
| this.readBuf = null; | |||
| this.oneBuf = new byte[1]; | |||
| this.oneBuf = new byte[ 1 ]; | |||
| this.debug = false; | |||
| this.hasHitEOF = false; | |||
| } | |||
| @@ -90,10 +91,10 @@ public class TarInputStream extends FilterInputStream | |||
| if( this.debug ) | |||
| { | |||
| 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 ) | |||
| @@ -131,56 +132,56 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| 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.entryOffset = 0; | |||
| this.currEntry = null; | |||
| 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 ) | |||
| { | |||
| System.err.println( "TarInputStream: SET CURRENTRY '" | |||
| + this.currEntry.getName() | |||
| + "' size = " | |||
| + this.currEntry.getSize() ); | |||
| + this.currEntry.getName() | |||
| + "' size = " | |||
| + this.currEntry.getSize() ); | |||
| } | |||
| this.entryOffset = 0; | |||
| // 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() ) | |||
| { | |||
| // read in the name | |||
| StringBuffer longName = new StringBuffer(); | |||
| byte[] buffer = new byte[256]; | |||
| byte[] buffer = new byte[ 256 ]; | |||
| int length = 0; | |||
| while( ( length = read( buffer ) ) >= 0 ) | |||
| { | |||
| @@ -240,7 +241,7 @@ public class TarInputStream extends FilterInputStream | |||
| public void copyEntryContents( OutputStream out ) | |||
| throws IOException | |||
| { | |||
| byte[] buf = new byte[32 * 1024]; | |||
| byte[] buf = new byte[ 32 * 1024 ]; | |||
| while( true ) | |||
| { | |||
| @@ -260,7 +261,9 @@ public class TarInputStream extends FilterInputStream | |||
| * | |||
| * @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. | |||
| @@ -290,7 +293,7 @@ public class TarInputStream extends FilterInputStream | |||
| } | |||
| else | |||
| { | |||
| return ( int )this.oneBuf[0]; | |||
| return (int)this.oneBuf[ 0 ]; | |||
| } | |||
| } | |||
| @@ -337,7 +340,7 @@ public class TarInputStream extends FilterInputStream | |||
| if( this.readBuf != null ) | |||
| { | |||
| int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length | |||
| : numToRead; | |||
| : numToRead; | |||
| System.arraycopy( this.readBuf, 0, buf, offset, sz ); | |||
| @@ -348,7 +351,7 @@ public class TarInputStream extends FilterInputStream | |||
| else | |||
| { | |||
| int newLen = this.readBuf.length - sz; | |||
| byte[] newBuf = new byte[newLen]; | |||
| byte[] newBuf = new byte[ newLen ]; | |||
| System.arraycopy( this.readBuf, sz, newBuf, 0, newLen ); | |||
| @@ -368,7 +371,7 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| // Unexpected EOF! | |||
| throw new IOException( "unexpected EOF with " + numToRead | |||
| + " bytes unread" ); | |||
| + " bytes unread" ); | |||
| } | |||
| int sz = numToRead; | |||
| @@ -378,7 +381,7 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| 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 ); | |||
| } | |||
| @@ -402,7 +405,9 @@ public class TarInputStream extends FilterInputStream | |||
| /** | |||
| * 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 | |||
| @@ -420,13 +425,13 @@ public class TarInputStream extends FilterInputStream | |||
| // This is horribly inefficient, but it ensures that we | |||
| // 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, | |||
| ( num > skipBuf.length ? skipBuf.length | |||
| : num ) ); | |||
| ( num > skipBuf.length ? skipBuf.length | |||
| : num ) ); | |||
| if( numRead == -1 ) | |||
| { | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.FilterOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| @@ -50,9 +51,9 @@ public class TarOutputStream extends FilterOutputStream | |||
| this.buffer = new TarBuffer( os, blockSize, recordSize ); | |||
| this.debug = false; | |||
| 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 ); | |||
| } | |||
| /** | |||
| * Sets the debugging flag. | |||
| * | |||
| @@ -120,7 +120,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| { | |||
| for( int i = this.assemLen; i < this.assemBuf.length; ++i ) | |||
| { | |||
| this.assemBuf[i] = 0; | |||
| this.assemBuf[ i ] = 0; | |||
| } | |||
| this.buffer.writeRecord( this.assemBuf ); | |||
| @@ -132,8 +132,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( this.currBytes < this.currSize ) | |||
| { | |||
| 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 | |||
| // of which are the entry's name | |||
| TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK, | |||
| TarConstants.LF_GNUTYPE_LONGNAME ); | |||
| TarConstants.LF_GNUTYPE_LONGNAME ); | |||
| longLinkEntry.setSize( entry.getName().length() + 1 ); | |||
| putNextEntry( longLinkEntry ); | |||
| @@ -182,8 +182,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| else if( longFileMode != LONGFILE_TRUNCATE ) | |||
| { | |||
| 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 | |||
| { | |||
| this.currSize = ( int )entry.getSize(); | |||
| this.currSize = (int)entry.getSize(); | |||
| } | |||
| } | |||
| @@ -212,7 +212,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| public void write( int b ) | |||
| throws IOException | |||
| { | |||
| this.oneBuf[0] = ( byte )b; | |||
| this.oneBuf[ 0 ] = (byte)b; | |||
| this.write( this.oneBuf, 0, 1 ); | |||
| } | |||
| @@ -249,8 +249,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( ( this.currBytes + numToWrite ) > this.currSize ) | |||
| { | |||
| 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!!! | |||
| // 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; | |||
| System.arraycopy( this.assemBuf, 0, this.recordBuf, 0, | |||
| this.assemLen ); | |||
| this.assemLen ); | |||
| System.arraycopy( wBuf, wOffset, this.recordBuf, | |||
| this.assemLen, aLen ); | |||
| this.assemLen, aLen ); | |||
| this.buffer.writeRecord( this.recordBuf ); | |||
| this.currBytes += this.recordBuf.length; | |||
| @@ -280,7 +280,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| else | |||
| { | |||
| System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| numToWrite ); | |||
| numToWrite ); | |||
| wOffset += numToWrite; | |||
| this.assemLen += numToWrite; | |||
| @@ -298,7 +298,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( numToWrite < this.recordBuf.length ) | |||
| { | |||
| System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| numToWrite ); | |||
| numToWrite ); | |||
| this.assemLen += numToWrite; | |||
| @@ -326,7 +326,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| { | |||
| for( int i = 0; i < this.recordBuf.length; ++i ) | |||
| { | |||
| this.recordBuf[i] = 0; | |||
| this.recordBuf[ i ] = 0; | |||
| } | |||
| this.buffer.writeRecord( this.recordBuf ); | |||
| @@ -30,8 +30,8 @@ public class TarUtils | |||
| { | |||
| 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; | |||
| } | |||
| @@ -47,7 +47,7 @@ public class TarUtils | |||
| */ | |||
| 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 ); | |||
| System.arraycopy( temp, 0, buf, offset, length ); | |||
| @@ -70,12 +70,12 @@ public class TarUtils | |||
| 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 ) | |||
| { | |||
| buf[offset + i] = 0; | |||
| buf[ offset + i ] = 0; | |||
| } | |||
| return offset + length; | |||
| @@ -92,31 +92,31 @@ public class TarUtils | |||
| */ | |||
| 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; | |||
| buf[offset + idx] = 0; | |||
| buf[ offset + idx ] = 0; | |||
| --idx; | |||
| buf[offset + idx] = ( byte )' '; | |||
| buf[ offset + idx ] = (byte)' '; | |||
| --idx; | |||
| if( value == 0 ) | |||
| { | |||
| buf[offset + idx] = ( byte )'0'; | |||
| buf[ offset + idx ] = (byte)'0'; | |||
| --idx; | |||
| } | |||
| else | |||
| { | |||
| 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; | |||
| } | |||
| } | |||
| for( ; idx >= 0; --idx ) | |||
| { | |||
| buf[offset + idx] = ( byte )' '; | |||
| buf[ offset + idx ] = (byte)' '; | |||
| } | |||
| return offset + length; | |||
| @@ -134,7 +134,7 @@ public class TarUtils | |||
| for( int i = 0; i < buf.length; ++i ) | |||
| { | |||
| sum += 255 & buf[i]; | |||
| sum += 255 & buf[ i ]; | |||
| } | |||
| return sum; | |||
| @@ -155,12 +155,12 @@ public class TarUtils | |||
| for( int i = offset; i < end; ++i ) | |||
| { | |||
| if( header[i] == 0 ) | |||
| if( header[ i ] == 0 ) | |||
| { | |||
| break; | |||
| } | |||
| result.append( ( char )header[i] ); | |||
| result.append( (char)header[ i ] ); | |||
| } | |||
| return result; | |||
| @@ -183,26 +183,26 @@ public class TarUtils | |||
| for( int i = offset; i < end; ++i ) | |||
| { | |||
| if( header[i] == 0 ) | |||
| if( header[ i ] == 0 ) | |||
| { | |||
| break; | |||
| } | |||
| if( header[i] == ( byte )' ' || header[i] == '0' ) | |||
| if( header[ i ] == (byte)' ' || header[ i ] == '0' ) | |||
| { | |||
| if( stillPadding ) | |||
| { | |||
| continue; | |||
| } | |||
| if( header[i] == ( byte )' ' ) | |||
| if( header[ i ] == (byte)' ' ) | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| stillPadding = false; | |||
| result = ( result << 3 ) + ( header[i] - '0' ); | |||
| result = ( result << 3 ) + ( header[ i ] - '0' ); | |||
| } | |||
| return result; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.ZipException; | |||
| @@ -79,7 +80,9 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| */ | |||
| private CRC32 crc = new CRC32(); | |||
| public AsiExtraField() { } | |||
| public AsiExtraField() | |||
| { | |||
| } | |||
| /** | |||
| * Indicate whether this entry is a directory. | |||
| @@ -205,17 +208,17 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| public byte[] getLocalFileDataData() | |||
| { | |||
| // 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 ); | |||
| byte[] linkArray = getLinkedFile().getBytes(); | |||
| System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(), | |||
| 0, data, 2, 4 ); | |||
| 0, data, 2, 4 ); | |||
| System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(), | |||
| 0, data, 6, 2 ); | |||
| 0, data, 6, 2 ); | |||
| System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(), | |||
| 0, data, 8, 2 ); | |||
| 0, data, 8, 2 ); | |||
| System.arraycopy( linkArray, 0, data, 10, linkArray.length ); | |||
| @@ -223,7 +226,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| crc.update( data ); | |||
| 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( data, 0, result, 4, data.length ); | |||
| return result; | |||
| @@ -239,11 +242,11 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| public ZipShort getLocalFileDataLength() | |||
| { | |||
| 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(); | |||
| byte[] tmp = new byte[length - 4]; | |||
| byte[] tmp = new byte[ length - 4 ]; | |||
| System.arraycopy( data, offset + 4, tmp, 0, length - 4 ); | |||
| crc.reset(); | |||
| crc.update( tmp ); | |||
| @@ -312,13 +315,13 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| if( givenChecksum != realChecksum ) | |||
| { | |||
| 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(); | |||
| 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(); | |||
| gid = ( new ZipShort( tmp, 8 ) ).getValue(); | |||
| @@ -92,7 +92,7 @@ public class UnrecognizedExtraField implements ZipExtraField | |||
| 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 ); | |||
| setLocalFileDataData( tmp ); | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.util.ArrayList; | |||
| @@ -120,7 +121,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| public ZipEntry( ZipEntry entry ) | |||
| throws ZipException | |||
| { | |||
| this( ( java.util.zip.ZipEntry )entry ); | |||
| this( (java.util.zip.ZipEntry)entry ); | |||
| setInternalAttributes( entry.getInternalAttributes() ); | |||
| setExternalAttributes( entry.getExternalAttributes() ); | |||
| setExtraFields( entry.getExtraFields() ); | |||
| @@ -142,7 +143,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| { | |||
| setCompressedSizeMethod = | |||
| java.util.zip.ZipEntry.class.getMethod( "setCompressedSize", | |||
| new Class[]{Long.TYPE} ); | |||
| new Class[]{Long.TYPE} ); | |||
| } | |||
| catch( NoSuchMethodException nse ) | |||
| { | |||
| @@ -181,14 +182,14 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| { | |||
| Throwable nested = ite.getTargetException(); | |||
| throw new RuntimeException( "Exception setting the compressed size " | |||
| + "of " + ze + ": " | |||
| + nested.getMessage() ); | |||
| + "of " + ze + ": " | |||
| + nested.getMessage() ); | |||
| } | |||
| catch( Throwable other ) | |||
| { | |||
| 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(); | |||
| for( int i = 0; i < fields.length; i++ ) | |||
| { | |||
| extraFields.add( fields[i] ); | |||
| extraFields.add( fields[ i ] ); | |||
| } | |||
| setExtra(); | |||
| } | |||
| @@ -341,7 +342,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| public byte[] getLocalFileDataExtra() | |||
| { | |||
| 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; | |||
| 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 ); | |||
| done = true; | |||
| @@ -381,7 +382,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| ZipEntry e = null; | |||
| try | |||
| { | |||
| e = new ZipEntry( ( java.util.zip.ZipEntry )super.clone() ); | |||
| e = new ZipEntry( (java.util.zip.ZipEntry)super.clone() ); | |||
| } | |||
| catch( Exception ex ) | |||
| { | |||
| @@ -405,7 +406,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| boolean done = false; | |||
| 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 ); | |||
| done = true; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.util.zip.ZipException; | |||
| /** | |||
| @@ -50,10 +50,10 @@ public class ZipLong implements Cloneable | |||
| */ | |||
| 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() | |||
| { | |||
| 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; | |||
| } | |||
| @@ -96,7 +96,7 @@ public class ZipLong implements Cloneable | |||
| { | |||
| return false; | |||
| } | |||
| return value == ( ( ZipLong )o ).getValue(); | |||
| return value == ( (ZipLong)o ).getValue(); | |||
| } | |||
| /** | |||
| @@ -107,7 +107,7 @@ public class ZipLong implements Cloneable | |||
| */ | |||
| public int hashCode() | |||
| { | |||
| return ( int )value; | |||
| return (int)value; | |||
| } | |||
| }// ZipLong | |||
| @@ -6,12 +6,13 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.Deflater; | |||
| import java.util.zip.DeflaterOutputStream; | |||
| @@ -216,17 +217,17 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| return DOS_TIME_MIN; | |||
| } | |||
| 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 ); | |||
| } | |||
| @@ -332,19 +333,19 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| if( entry.getCrc() != realCrc ) | |||
| { | |||
| 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 ) | |||
| { | |||
| 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 ); | |||
| for( int i = 0; i < entries.size(); i++ ) | |||
| { | |||
| writeCentralFileHeader( ( ZipEntry )entries.get( i ) ); | |||
| writeCentralFileHeader( (ZipEntry)entries.get( i ) ); | |||
| } | |||
| cdLength = new ZipLong( written - cdOffset.getValue() ); | |||
| writeCentralDirectoryEnd(); | |||
| @@ -593,7 +594,7 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| written += 4; | |||
| // relative offset of LFH | |||
| out.write( ( ( ZipLong )offsets.get( ze ) ).getBytes() ); | |||
| out.write( ( (ZipLong)offsets.get( ze ) ).getBytes() ); | |||
| written += 4; | |||
| // file name | |||
| @@ -50,8 +50,8 @@ public class ZipShort implements Cloneable | |||
| */ | |||
| 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() | |||
| { | |||
| 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; | |||
| } | |||
| @@ -92,7 +92,7 @@ public class ZipShort implements Cloneable | |||
| { | |||
| return false; | |||
| } | |||
| return value == ( ( ZipShort )o ).getValue(); | |||
| return value == ( (ZipShort)o ).getValue(); | |||
| } | |||
| /** | |||
| @@ -437,7 +437,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| Execute exe = new Execute( new LogStreamHandler( attributes, | |||
| Project.MSG_INFO, | |||
| Project.MSG_WARN ) ); | |||
| exe.setAntRun( project ); | |||
| exe.setWorkingDirectory( project.getBaseDir() ); | |||
| exe.setCommandline( commandArray ); | |||
| exe.execute(); | |||
| @@ -7,7 +7,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Iterator; | |||
| import java.util.Enumeration; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -7,10 +7,9 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.condition; | |||
| import java.util.Iterator; | |||
| import java.util.NoSuchElementException; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.NoSuchElementException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.ProjectComponent; | |||
| import org.apache.tools.ant.taskdefs.Available; | |||
| @@ -10,10 +10,9 @@ package org.apache.tools.ant.taskdefs.file; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Iterator; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -457,8 +457,8 @@ public class Delete | |||
| if( dirCount > 0 ) | |||
| { | |||
| getLogger().info( "Deleted " + dirCount + " director" + | |||
| ( dirCount == 1 ? "y" : "ies" ) + | |||
| " from " + d.getAbsolutePath() ); | |||
| ( dirCount == 1 ? "y" : "ies" ) + | |||
| " from " + d.getAbsolutePath() ); | |||
| } | |||
| } | |||
| } | |||
| @@ -9,16 +9,15 @@ package org.apache.tools.ant.taskdefs.file; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Iterator; | |||
| import java.util.Iterator; | |||
| import java.util.Enumeration; | |||
| import java.util.Iterator; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| 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.FilterSet; | |||
| 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 | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.taskdefs.rmic; | |||
| import java.io.File; | |||
| import java.util.Random; | |||
| import java.util.ArrayList; | |||
| import java.util.Random; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.Rmic; | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| /** | |||
| @@ -8,9 +8,9 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -8,8 +8,8 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.Stack; | |||
| import java.util.ArrayList; | |||
| import java.util.Stack; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.FileScanner; | |||
| @@ -10,11 +10,11 @@ package org.apache.tools.ant.types;// java io classes | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.Properties; | |||
| import java.util.ArrayList; | |||
| 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.tools.ant.Project; | |||
| @@ -9,8 +9,8 @@ package org.apache.tools.ant.types;// java io classes | |||
| // java util classes | |||
| import java.util.Iterator; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| // ant classes | |||
| @@ -8,10 +8,10 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Locale; | |||
| import java.util.Stack; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -11,10 +11,10 @@ import java.io.BufferedReader; | |||
| import java.io.File; | |||
| import java.io.FileReader; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -357,7 +357,7 @@ public class PatternSet extends DataType | |||
| } | |||
| final String[] result = new String[ tmpNames.size() ]; | |||
| return (String[]) tmpNames.toArray( result ); | |||
| return (String[])tmpNames.toArray( result ); | |||
| } | |||
| /** | |||
| @@ -9,11 +9,11 @@ package org.apache.tools.ant.util; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| /** | |||
| * Utility class that collects the functionality of the various scanDir methods | |||
| @@ -78,7 +78,7 @@ public class SourceFileScanner | |||
| if( targets == null || targets.length == 0 ) | |||
| { | |||
| m_task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| continue; | |||
| } | |||
| @@ -87,7 +87,7 @@ public class SourceFileScanner | |||
| if( src.lastModified() > now ) | |||
| { | |||
| m_task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| Project.MSG_WARN ); | |||
| Project.MSG_WARN ); | |||
| } | |||
| boolean added = false; | |||
| @@ -99,14 +99,14 @@ public class SourceFileScanner | |||
| if( !dest.exists() ) | |||
| { | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| v.add( files[ i ] ); | |||
| added = true; | |||
| } | |||
| else if( src.lastModified() > dest.lastModified() ) | |||
| { | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| Project.MSG_VERBOSE ); | |||
| Project.MSG_VERBOSE ); | |||
| v.add( files[ i ] ); | |||
| added = true; | |||
| } | |||
| @@ -123,8 +123,8 @@ public class SourceFileScanner | |||
| if( !added ) | |||
| { | |||
| 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 ); | |||
| } | |||
| } | |||
| @@ -80,5 +80,5 @@ public interface BZip2Constants | |||
| 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, | |||
| 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, | |||
| 936, 638 | |||
| }; | |||
| }; | |||
| } | |||
| @@ -6,7 +6,9 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| 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 | |||
| @@ -26,24 +28,24 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private final static int NO_RAND_PART_C_STATE = 7; | |||
| 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 | |||
| * 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; | |||
| @@ -146,28 +148,28 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| else | |||
| { | |||
| 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; | |||
| } | |||
| @@ -176,7 +178,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setDecompressStructureSizes( int newSize100k ) | |||
| { | |||
| if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k | |||
| && blockSize100k <= 9 ) ) | |||
| && blockSize100k <= 9 ) ) | |||
| { | |||
| // throw new IOException("Invalid block size"); | |||
| } | |||
| @@ -187,30 +189,30 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| return; | |||
| int n = baseBlockSize * newSize100k; | |||
| ll8 = new char[n]; | |||
| tt = new int[n]; | |||
| ll8 = new char[ n ]; | |||
| tt = new int[ n ]; | |||
| } | |||
| private void setupBlock() | |||
| { | |||
| int cftab[] = new int[257]; | |||
| int cftab[] = new int[ 257 ]; | |||
| char ch; | |||
| cftab[0] = 0; | |||
| cftab[ 0 ] = 0; | |||
| for( i = 1; i <= 256; i++ ) | |||
| cftab[i] = unzftab[i - 1]; | |||
| cftab[ i ] = unzftab[ i - 1 ]; | |||
| for( i = 1; i <= 256; i++ ) | |||
| cftab[i] += cftab[i - 1]; | |||
| cftab[ i ] += cftab[ i - 1 ]; | |||
| 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; | |||
| tPos = tt[origPtr]; | |||
| tPos = tt[ origPtr ]; | |||
| count = 0; | |||
| i2 = 0; | |||
| @@ -235,8 +237,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( i2 <= last ) | |||
| { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| ch2 = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| i2++; | |||
| currentChar = ch2; | |||
| @@ -264,8 +266,8 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| count++; | |||
| if( count >= 4 ) | |||
| { | |||
| z = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| z = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| currentState = NO_RAND_PART_C_STATE; | |||
| j2 = 0; | |||
| setupNoRandPartC(); | |||
| @@ -280,7 +282,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setupNoRandPartC() | |||
| { | |||
| if( j2 < ( int )z ) | |||
| if( j2 < (int)z ) | |||
| { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC( ch2 ); | |||
| @@ -300,17 +302,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( i2 <= last ) | |||
| { | |||
| chPrev = ch2; | |||
| ch2 = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| ch2 = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| if( rNToGo == 0 ) | |||
| { | |||
| rNToGo = rNums[rTPos]; | |||
| rNToGo = rNums[ rTPos ]; | |||
| rTPos++; | |||
| if( rTPos == 512 ) | |||
| rTPos = 0; | |||
| } | |||
| rNToGo--; | |||
| ch2 ^= ( int )( ( rNToGo == 1 ) ? 1 : 0 ); | |||
| ch2 ^= (int)( ( rNToGo == 1 ) ? 1 : 0 ); | |||
| i2++; | |||
| currentChar = ch2; | |||
| @@ -338,11 +340,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| count++; | |||
| if( count >= 4 ) | |||
| { | |||
| z = ll8[tPos]; | |||
| tPos = tt[tPos]; | |||
| z = ll8[ tPos ]; | |||
| tPos = tt[ tPos ]; | |||
| if( rNToGo == 0 ) | |||
| { | |||
| rNToGo = rNums[rTPos]; | |||
| rNToGo = rNums[ rTPos ]; | |||
| rTPos++; | |||
| if( rTPos == 512 ) | |||
| rTPos = 0; | |||
| @@ -363,7 +365,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void setupRandPartC() | |||
| { | |||
| if( j2 < ( int )z ) | |||
| if( j2 < (int)z ) | |||
| { | |||
| currentChar = ch2; | |||
| mCrc.updateCRC( ch2 ); | |||
| @@ -380,7 +382,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private void getAndMoveToFrontDecode() | |||
| { | |||
| char yy[] = new char[256]; | |||
| char yy[] = new char[ 256 ]; | |||
| int i; | |||
| int j; | |||
| int nextSym; | |||
| @@ -404,10 +406,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| * cache misses. | |||
| */ | |||
| for( i = 0; i <= 255; i++ ) | |||
| unzftab[i] = 0; | |||
| unzftab[ i ] = 0; | |||
| for( i = 0; i <= 255; i++ ) | |||
| yy[i] = ( char )i; | |||
| yy[ i ] = (char)i; | |||
| last = -1; | |||
| { | |||
| @@ -421,10 +423,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -435,7 +437,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -455,7 +457,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| } | |||
| zvec = ( zvec << 1 ) | zj; | |||
| } | |||
| nextSym = perm[zt][zvec - base[zt][zn]]; | |||
| nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ]; | |||
| } | |||
| while( true ) | |||
| @@ -487,10 +489,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -501,7 +503,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -522,18 +524,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| 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++; | |||
| ch = seqToUnseq[yy[0]]; | |||
| unzftab[ch] += s; | |||
| ch = seqToUnseq[ yy[ 0 ] ]; | |||
| unzftab[ ch ] += s; | |||
| while( s > 0 ) | |||
| { | |||
| last++; | |||
| ll8[last] = ch; | |||
| ll8[ last ] = ch; | |||
| s--; | |||
| } | |||
| ; | |||
| @@ -549,9 +551,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| if( last >= limitLast ) | |||
| 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, | |||
| @@ -561,15 +563,15 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| j = nextSym - 1; | |||
| 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-- ) | |||
| yy[j] = yy[j - 1]; | |||
| yy[ j ] = yy[ j - 1 ]; | |||
| yy[0] = tmp; | |||
| yy[ 0 ] = tmp; | |||
| { | |||
| int zt; | |||
| int zn; | |||
| @@ -581,10 +583,10 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| groupPos = G_SIZE; | |||
| } | |||
| groupPos--; | |||
| zt = selector[groupNo]; | |||
| zn = minLens[zt]; | |||
| zt = selector[ groupNo ]; | |||
| zn = minLens[ zt ]; | |||
| zvec = bsR( zn ); | |||
| while( zvec > limit[zt][zn] ) | |||
| while( zvec > limit[ zt ][ zn ] ) | |||
| { | |||
| zn++; | |||
| { | |||
| @@ -595,7 +597,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -612,7 +614,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| zvec = ( zvec << 1 ) | zj; | |||
| } | |||
| ; | |||
| nextSym = perm[zt][zvec - base[zt][zn]]; | |||
| nextSym = perm[ zt ][ zvec - base[ zt ][ zn ] ]; | |||
| } | |||
| continue; | |||
| } | |||
| @@ -626,17 +628,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| private int bsGetInt32() | |||
| { | |||
| return ( int )bsGetint(); | |||
| return (int)bsGetint(); | |||
| } | |||
| private int bsGetIntVS( int numBits ) | |||
| { | |||
| return ( int )bsR( numBits ); | |||
| return (int)bsR( numBits ); | |||
| } | |||
| private char bsGetUChar() | |||
| { | |||
| return ( char )bsR( 8 ); | |||
| return (char)bsR( 8 ); | |||
| } | |||
| private int bsGetint() | |||
| @@ -659,7 +661,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| char thech = 0; | |||
| try | |||
| { | |||
| thech = ( char )bsStream.read(); | |||
| thech = (char)bsStream.read(); | |||
| } | |||
| catch( IOException e ) | |||
| { | |||
| @@ -709,7 +711,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| crcError(); | |||
| computedCombinedCRC = ( computedCombinedCRC << 1 ) | |||
| | ( computedCombinedCRC >>> 31 ); | |||
| | ( computedCombinedCRC >>> 31 ); | |||
| computedCombinedCRC ^= computedBlockCRC; | |||
| } | |||
| @@ -725,33 +727,33 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| pp = 0; | |||
| for( i = minLen; i <= maxLen; i++ ) | |||
| for( j = 0; j < alphaSize; j++ ) | |||
| if( length[j] == i ) | |||
| if( length[ j ] == i ) | |||
| { | |||
| perm[pp] = j; | |||
| perm[ pp ] = j; | |||
| pp++; | |||
| } | |||
| ; | |||
| for( i = 0; i < MAX_CODE_LEN; i++ ) | |||
| base[i] = 0; | |||
| base[ i ] = 0; | |||
| for( i = 0; i < alphaSize; i++ ) | |||
| base[length[i] + 1]++; | |||
| base[ length[ i ] + 1 ]++; | |||
| 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++ ) | |||
| limit[i] = 0; | |||
| limit[ i ] = 0; | |||
| vec = 0; | |||
| 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; | |||
| } | |||
| 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() | |||
| @@ -769,14 +771,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| magic5 = bsGetUChar(); | |||
| magic6 = bsGetUChar(); | |||
| if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 | |||
| && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 ) | |||
| && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 ) | |||
| { | |||
| complete(); | |||
| return; | |||
| } | |||
| if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 | |||
| || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 ) | |||
| || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 ) | |||
| { | |||
| badBlockHeader(); | |||
| streamEnd = true; | |||
| @@ -819,17 +821,17 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| int i; | |||
| nInUse = 0; | |||
| 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++; | |||
| } | |||
| } | |||
| private void recvDecodingTables() | |||
| { | |||
| char len[][] = new char[N_GROUPS][MAX_ALPHA_SIZE]; | |||
| char len[][] = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ]; | |||
| int i; | |||
| int j; | |||
| int t; | |||
| @@ -838,25 +840,25 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| int alphaSize; | |||
| int minLen; | |||
| int maxLen; | |||
| boolean inUse16[] = new boolean[16]; | |||
| boolean inUse16[] = new boolean[ 16 ]; | |||
| /* | |||
| * Receive the mapping table | |||
| */ | |||
| for( i = 0; i < 16; i++ ) | |||
| if( bsR( 1 ) == 1 ) | |||
| inUse16[i] = true; | |||
| inUse16[ i ] = true; | |||
| else | |||
| inUse16[i] = false; | |||
| inUse16[ i ] = false; | |||
| for( i = 0; i < 256; i++ ) | |||
| inUse[i] = false; | |||
| inUse[ i ] = false; | |||
| for( i = 0; i < 16; i++ ) | |||
| if( inUse16[i] ) | |||
| if( inUse16[ i ] ) | |||
| for( j = 0; j < 16; j++ ) | |||
| if( bsR( 1 ) == 1 ) | |||
| inUse[i * 16 + j] = true; | |||
| inUse[ i * 16 + j ] = true; | |||
| makeMaps(); | |||
| alphaSize = nInUse + 2; | |||
| @@ -871,29 +873,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| j = 0; | |||
| while( bsR( 1 ) == 1 ) | |||
| j++; | |||
| selectorMtf[i] = ( char )j; | |||
| selectorMtf[ i ] = (char)j; | |||
| } | |||
| { | |||
| /* | |||
| * Undo the MTF values for the selectors. | |||
| */ | |||
| char pos[] = new char[N_GROUPS]; | |||
| char pos[] = new char[ N_GROUPS ]; | |||
| char tmp; | |||
| char v; | |||
| for( v = 0; v < nGroups; v++ ) | |||
| pos[v] = v; | |||
| pos[ v ] = v; | |||
| for( i = 0; i < nSelectors; i++ ) | |||
| { | |||
| v = selectorMtf[i]; | |||
| tmp = pos[v]; | |||
| v = selectorMtf[ i ]; | |||
| tmp = pos[ v ]; | |||
| while( v > 0 ) | |||
| { | |||
| pos[v] = pos[v - 1]; | |||
| pos[ v ] = pos[ v - 1 ]; | |||
| 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 | |||
| curr--; | |||
| } | |||
| len[t][i] = ( char )curr; | |||
| len[ t ][ i ] = (char)curr; | |||
| } | |||
| } | |||
| @@ -925,14 +927,14 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants | |||
| maxLen = 0; | |||
| 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; | |||
| } | |||
| } | |||
| } | |||
| @@ -80,7 +80,7 @@ class CRC | |||
| 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, | |||
| 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, | |||
| 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 | |||
| }; | |||
| }; | |||
| int globalCrc; | |||
| @@ -114,7 +114,7 @@ class CRC | |||
| int temp = ( globalCrc >> 24 ) ^ inCh; | |||
| if( temp < 0 ) | |||
| temp = 256 + temp; | |||
| globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[temp]; | |||
| globalCrc = ( globalCrc << 8 ) ^ CRC.crc32Table[ temp ]; | |||
| } | |||
| } | |||
| @@ -6,16 +6,17 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.mail; | |||
| import java.io.BufferedOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.io.PrintStream; | |||
| import java.net.InetAddress; | |||
| import java.net.Socket; | |||
| import java.util.Iterator; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| 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 | |||
| @@ -348,7 +349,7 @@ public class MailMessage | |||
| // Check that the response is one of the valid codes | |||
| for( int i = 0; i < ok.length; i++ ) | |||
| { | |||
| if( response.startsWith( "" + ok[i] ) ) | |||
| if( response.startsWith( "" + ok[ i ] ) ) | |||
| { | |||
| return true; | |||
| } | |||
| @@ -364,7 +365,7 @@ public class MailMessage | |||
| socket = new Socket( host, port ); | |||
| out = new MailPrintStream( | |||
| new BufferedOutputStream( | |||
| socket.getOutputStream() ) ); | |||
| socket.getOutputStream() ) ); | |||
| in = new SmtpResponseReader( socket.getInputStream() ); | |||
| getReady(); | |||
| } | |||
| @@ -387,8 +388,8 @@ public class MailMessage | |||
| Enumeration e = headers.keys(); | |||
| 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(); | |||
| @@ -471,6 +472,7 @@ public class MailMessage | |||
| // This PrintStream subclass makes sure that <CRLF>. becomes <CRLF>.. | |||
| // per RFC 821. It also ensures that new lines are always \r\n. | |||
| // | |||
| class MailPrintStream extends PrintStream | |||
| { | |||
| @@ -506,7 +508,7 @@ class MailPrintStream extends PrintStream | |||
| { | |||
| for( int i = 0; i < len; i++ ) | |||
| { | |||
| write( buf[off + i] ); | |||
| write( buf[ off + i ] ); | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.mail; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| @@ -137,7 +138,7 @@ public class TarBuffer | |||
| { | |||
| for( int i = 0, sz = this.getRecordSize(); i < sz; ++i ) | |||
| { | |||
| if( record[i] != 0 ) | |||
| if( record[ i ] != 0 ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -165,7 +166,7 @@ public class TarBuffer | |||
| this.flushBlock(); | |||
| if( this.outStream != System.out | |||
| && this.outStream != System.err ) | |||
| && this.outStream != System.err ) | |||
| { | |||
| this.outStream.close(); | |||
| @@ -195,7 +196,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "ReadRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| 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, | |||
| ( this.currRecIdx * this.recordSize ), result, 0, | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), result, 0, | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| @@ -233,7 +234,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "SkipRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.inStream == null ) | |||
| @@ -264,7 +265,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.outStream == null ) | |||
| @@ -275,9 +276,9 @@ public class TarBuffer | |||
| if( record.length != this.recordSize ) | |||
| { | |||
| 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 ) | |||
| @@ -286,8 +287,8 @@ public class TarBuffer | |||
| } | |||
| System.arraycopy( record, 0, this.blockBuffer, | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| } | |||
| @@ -306,7 +307,7 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "WriteRecord: recIdx = " + this.currRecIdx | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| + " blkIdx = " + this.currBlkIdx ); | |||
| } | |||
| if( this.outStream == null ) | |||
| @@ -317,9 +318,9 @@ public class TarBuffer | |||
| if( ( offset + this.recordSize ) > 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 ) | |||
| @@ -328,8 +329,8 @@ public class TarBuffer | |||
| } | |||
| System.arraycopy( buf, offset, this.blockBuffer, | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| ( this.currRecIdx * this.recordSize ), | |||
| this.recordSize ); | |||
| this.currRecIdx++; | |||
| } | |||
| @@ -370,7 +371,7 @@ public class TarBuffer | |||
| this.blockSize = blockSize; | |||
| this.recordSize = recordSize; | |||
| this.recsPerBlock = ( this.blockSize / this.recordSize ); | |||
| this.blockBuffer = new byte[this.blockSize]; | |||
| this.blockBuffer = new byte[ this.blockSize ]; | |||
| if( this.inStream != null ) | |||
| { | |||
| @@ -409,7 +410,7 @@ public class TarBuffer | |||
| while( bytesNeeded > 0 ) | |||
| { | |||
| long numBytes = this.inStream.read( this.blockBuffer, offset, | |||
| bytesNeeded ); | |||
| bytesNeeded ); | |||
| // | |||
| // NOTE | |||
| @@ -437,8 +438,8 @@ public class TarBuffer | |||
| if( this.debug ) | |||
| { | |||
| System.err.println( "ReadBlock: INCOMPLETE READ " | |||
| + numBytes + " of " + this.blockSize | |||
| + " bytes read." ); | |||
| + numBytes + " of " + this.blockSize | |||
| + " bytes read." ); | |||
| } | |||
| } | |||
| } | |||
| @@ -82,42 +82,42 @@ public interface TarConstants | |||
| /** | |||
| * Normal file type. | |||
| */ | |||
| byte LF_NORMAL = ( byte )'0'; | |||
| byte LF_NORMAL = (byte)'0'; | |||
| /** | |||
| * Link file type. | |||
| */ | |||
| byte LF_LINK = ( byte )'1'; | |||
| byte LF_LINK = (byte)'1'; | |||
| /** | |||
| * Symbolic link file type. | |||
| */ | |||
| byte LF_SYMLINK = ( byte )'2'; | |||
| byte LF_SYMLINK = (byte)'2'; | |||
| /** | |||
| * Character device file type. | |||
| */ | |||
| byte LF_CHR = ( byte )'3'; | |||
| byte LF_CHR = (byte)'3'; | |||
| /** | |||
| * Block device file type. | |||
| */ | |||
| byte LF_BLK = ( byte )'4'; | |||
| byte LF_BLK = (byte)'4'; | |||
| /** | |||
| * Directory file type. | |||
| */ | |||
| byte LF_DIR = ( byte )'5'; | |||
| byte LF_DIR = (byte)'5'; | |||
| /** | |||
| * FIFO (pipe) file type. | |||
| */ | |||
| byte LF_FIFO = ( byte )'6'; | |||
| byte LF_FIFO = (byte)'6'; | |||
| /** | |||
| * Contiguous file type. | |||
| */ | |||
| byte LF_CONTIG = ( byte )'7'; | |||
| byte LF_CONTIG = (byte)'7'; | |||
| /** | |||
| * 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. | |||
| */ | |||
| byte LF_GNUTYPE_LONGNAME = ( byte )'L'; | |||
| byte LF_GNUTYPE_LONGNAME = (byte)'L'; | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.File; | |||
| import java.util.Date; | |||
| @@ -190,8 +191,8 @@ public class TarEntry implements TarConstants | |||
| char ch2 = name.charAt( 1 ); | |||
| if( ch2 == ':' | |||
| && ( ( ch1 >= 'a' && ch1 <= 'z' ) | |||
| || ( ch1 >= 'A' && ch1 <= 'Z' ) ) ) | |||
| && ( ( ch1 >= 'a' && ch1 <= 'z' ) | |||
| || ( ch1 >= 'A' && ch1 <= 'Z' ) ) ) | |||
| { | |||
| name = name.substring( 2 ); | |||
| } | |||
| @@ -406,15 +407,15 @@ public class TarEntry implements TarConstants | |||
| { | |||
| if( this.file == null || !this.file.isDirectory() ) | |||
| { | |||
| return new TarEntry[0]; | |||
| return new TarEntry[ 0 ]; | |||
| } | |||
| 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 ) | |||
| { | |||
| result[i] = new TarEntry( new File( this.file, list[i] ) ); | |||
| result[ i ] = new TarEntry( new File( this.file, list[ i ] ) ); | |||
| } | |||
| return result; | |||
| @@ -490,7 +491,6 @@ public class TarEntry implements TarConstants | |||
| return this.size; | |||
| } | |||
| /** | |||
| * Get this entry's user id. | |||
| * | |||
| @@ -549,7 +549,6 @@ public class TarEntry implements TarConstants | |||
| return false; | |||
| } | |||
| /** | |||
| * 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 ); | |||
| offset += NAMELEN; | |||
| this.mode = ( int )TarUtils.parseOctal( header, offset, MODELEN ); | |||
| this.mode = (int)TarUtils.parseOctal( header, offset, MODELEN ); | |||
| offset += MODELEN; | |||
| this.userId = ( int )TarUtils.parseOctal( header, offset, UIDLEN ); | |||
| this.userId = (int)TarUtils.parseOctal( header, offset, UIDLEN ); | |||
| offset += UIDLEN; | |||
| this.groupId = ( int )TarUtils.parseOctal( header, offset, GIDLEN ); | |||
| this.groupId = (int)TarUtils.parseOctal( header, offset, GIDLEN ); | |||
| offset += GIDLEN; | |||
| this.size = TarUtils.parseOctal( header, offset, SIZELEN ); | |||
| offset += SIZELEN; | |||
| this.modTime = TarUtils.parseOctal( header, offset, MODTIMELEN ); | |||
| offset += MODTIMELEN; | |||
| this.checkSum = ( int )TarUtils.parseOctal( header, offset, CHKSUMLEN ); | |||
| this.checkSum = (int)TarUtils.parseOctal( header, offset, CHKSUMLEN ); | |||
| offset += CHKSUMLEN; | |||
| this.linkFlag = header[offset++]; | |||
| this.linkFlag = header[ offset++ ]; | |||
| this.linkName = TarUtils.parseName( header, offset, NAMELEN ); | |||
| offset += NAMELEN; | |||
| this.magic = TarUtils.parseName( header, offset, MAGICLEN ); | |||
| @@ -606,9 +605,9 @@ public class TarEntry implements TarConstants | |||
| offset += UNAMELEN; | |||
| this.groupName = TarUtils.parseName( header, offset, GNAMELEN ); | |||
| offset += GNAMELEN; | |||
| this.devMajor = ( int )TarUtils.parseOctal( header, offset, DEVLEN ); | |||
| this.devMajor = (int)TarUtils.parseOctal( header, 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 ) | |||
| { | |||
| 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.magic, outbuf, offset, MAGICLEN ); | |||
| offset = TarUtils.getNameBytes( this.userName, outbuf, offset, UNAMELEN ); | |||
| @@ -644,7 +643,7 @@ public class TarEntry implements TarConstants | |||
| while( offset < outbuf.length ) | |||
| { | |||
| outbuf[offset++] = 0; | |||
| outbuf[ offset++ ] = 0; | |||
| } | |||
| long checkSum = TarUtils.computeCheckSum( outbuf ); | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.FilterInputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| @@ -48,7 +49,7 @@ public class TarInputStream extends FilterInputStream | |||
| this.buffer = new TarBuffer( is, blockSize, recordSize ); | |||
| this.readBuf = null; | |||
| this.oneBuf = new byte[1]; | |||
| this.oneBuf = new byte[ 1 ]; | |||
| this.debug = false; | |||
| this.hasHitEOF = false; | |||
| } | |||
| @@ -90,10 +91,10 @@ public class TarInputStream extends FilterInputStream | |||
| if( this.debug ) | |||
| { | |||
| 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 ) | |||
| @@ -131,56 +132,56 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| 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.entryOffset = 0; | |||
| this.currEntry = null; | |||
| 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 ) | |||
| { | |||
| System.err.println( "TarInputStream: SET CURRENTRY '" | |||
| + this.currEntry.getName() | |||
| + "' size = " | |||
| + this.currEntry.getSize() ); | |||
| + this.currEntry.getName() | |||
| + "' size = " | |||
| + this.currEntry.getSize() ); | |||
| } | |||
| this.entryOffset = 0; | |||
| // 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() ) | |||
| { | |||
| // read in the name | |||
| StringBuffer longName = new StringBuffer(); | |||
| byte[] buffer = new byte[256]; | |||
| byte[] buffer = new byte[ 256 ]; | |||
| int length = 0; | |||
| while( ( length = read( buffer ) ) >= 0 ) | |||
| { | |||
| @@ -240,7 +241,7 @@ public class TarInputStream extends FilterInputStream | |||
| public void copyEntryContents( OutputStream out ) | |||
| throws IOException | |||
| { | |||
| byte[] buf = new byte[32 * 1024]; | |||
| byte[] buf = new byte[ 32 * 1024 ]; | |||
| while( true ) | |||
| { | |||
| @@ -260,7 +261,9 @@ public class TarInputStream extends FilterInputStream | |||
| * | |||
| * @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. | |||
| @@ -290,7 +293,7 @@ public class TarInputStream extends FilterInputStream | |||
| } | |||
| else | |||
| { | |||
| return ( int )this.oneBuf[0]; | |||
| return (int)this.oneBuf[ 0 ]; | |||
| } | |||
| } | |||
| @@ -337,7 +340,7 @@ public class TarInputStream extends FilterInputStream | |||
| if( this.readBuf != null ) | |||
| { | |||
| int sz = ( numToRead > this.readBuf.length ) ? this.readBuf.length | |||
| : numToRead; | |||
| : numToRead; | |||
| System.arraycopy( this.readBuf, 0, buf, offset, sz ); | |||
| @@ -348,7 +351,7 @@ public class TarInputStream extends FilterInputStream | |||
| else | |||
| { | |||
| int newLen = this.readBuf.length - sz; | |||
| byte[] newBuf = new byte[newLen]; | |||
| byte[] newBuf = new byte[ newLen ]; | |||
| System.arraycopy( this.readBuf, sz, newBuf, 0, newLen ); | |||
| @@ -368,7 +371,7 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| // Unexpected EOF! | |||
| throw new IOException( "unexpected EOF with " + numToRead | |||
| + " bytes unread" ); | |||
| + " bytes unread" ); | |||
| } | |||
| int sz = numToRead; | |||
| @@ -378,7 +381,7 @@ public class TarInputStream extends FilterInputStream | |||
| { | |||
| 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 ); | |||
| } | |||
| @@ -402,7 +405,9 @@ public class TarInputStream extends FilterInputStream | |||
| /** | |||
| * 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 | |||
| @@ -420,13 +425,13 @@ public class TarInputStream extends FilterInputStream | |||
| // This is horribly inefficient, but it ensures that we | |||
| // 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, | |||
| ( num > skipBuf.length ? skipBuf.length | |||
| : num ) ); | |||
| ( num > skipBuf.length ? skipBuf.length | |||
| : num ) ); | |||
| if( numRead == -1 ) | |||
| { | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.tar; | |||
| import java.io.FilterOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| @@ -50,9 +51,9 @@ public class TarOutputStream extends FilterOutputStream | |||
| this.buffer = new TarBuffer( os, blockSize, recordSize ); | |||
| this.debug = false; | |||
| 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 ); | |||
| } | |||
| /** | |||
| * Sets the debugging flag. | |||
| * | |||
| @@ -120,7 +120,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| { | |||
| for( int i = this.assemLen; i < this.assemBuf.length; ++i ) | |||
| { | |||
| this.assemBuf[i] = 0; | |||
| this.assemBuf[ i ] = 0; | |||
| } | |||
| this.buffer.writeRecord( this.assemBuf ); | |||
| @@ -132,8 +132,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( this.currBytes < this.currSize ) | |||
| { | |||
| 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 | |||
| // of which are the entry's name | |||
| TarEntry longLinkEntry = new TarEntry( TarConstants.GNU_LONGLINK, | |||
| TarConstants.LF_GNUTYPE_LONGNAME ); | |||
| TarConstants.LF_GNUTYPE_LONGNAME ); | |||
| longLinkEntry.setSize( entry.getName().length() + 1 ); | |||
| putNextEntry( longLinkEntry ); | |||
| @@ -182,8 +182,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| else if( longFileMode != LONGFILE_TRUNCATE ) | |||
| { | |||
| 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 | |||
| { | |||
| this.currSize = ( int )entry.getSize(); | |||
| this.currSize = (int)entry.getSize(); | |||
| } | |||
| } | |||
| @@ -212,7 +212,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| public void write( int b ) | |||
| throws IOException | |||
| { | |||
| this.oneBuf[0] = ( byte )b; | |||
| this.oneBuf[ 0 ] = (byte)b; | |||
| this.write( this.oneBuf, 0, 1 ); | |||
| } | |||
| @@ -249,8 +249,8 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( ( this.currBytes + numToWrite ) > this.currSize ) | |||
| { | |||
| 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!!! | |||
| // 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; | |||
| System.arraycopy( this.assemBuf, 0, this.recordBuf, 0, | |||
| this.assemLen ); | |||
| this.assemLen ); | |||
| System.arraycopy( wBuf, wOffset, this.recordBuf, | |||
| this.assemLen, aLen ); | |||
| this.assemLen, aLen ); | |||
| this.buffer.writeRecord( this.recordBuf ); | |||
| this.currBytes += this.recordBuf.length; | |||
| @@ -280,7 +280,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| else | |||
| { | |||
| System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| numToWrite ); | |||
| numToWrite ); | |||
| wOffset += numToWrite; | |||
| this.assemLen += numToWrite; | |||
| @@ -298,7 +298,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| if( numToWrite < this.recordBuf.length ) | |||
| { | |||
| System.arraycopy( wBuf, wOffset, this.assemBuf, this.assemLen, | |||
| numToWrite ); | |||
| numToWrite ); | |||
| this.assemLen += numToWrite; | |||
| @@ -326,7 +326,7 @@ public class TarOutputStream extends FilterOutputStream | |||
| { | |||
| for( int i = 0; i < this.recordBuf.length; ++i ) | |||
| { | |||
| this.recordBuf[i] = 0; | |||
| this.recordBuf[ i ] = 0; | |||
| } | |||
| this.buffer.writeRecord( this.recordBuf ); | |||
| @@ -30,8 +30,8 @@ public class TarUtils | |||
| { | |||
| 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; | |||
| } | |||
| @@ -47,7 +47,7 @@ public class TarUtils | |||
| */ | |||
| 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 ); | |||
| System.arraycopy( temp, 0, buf, offset, length ); | |||
| @@ -70,12 +70,12 @@ public class TarUtils | |||
| 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 ) | |||
| { | |||
| buf[offset + i] = 0; | |||
| buf[ offset + i ] = 0; | |||
| } | |||
| return offset + length; | |||
| @@ -92,31 +92,31 @@ public class TarUtils | |||
| */ | |||
| 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; | |||
| buf[offset + idx] = 0; | |||
| buf[ offset + idx ] = 0; | |||
| --idx; | |||
| buf[offset + idx] = ( byte )' '; | |||
| buf[ offset + idx ] = (byte)' '; | |||
| --idx; | |||
| if( value == 0 ) | |||
| { | |||
| buf[offset + idx] = ( byte )'0'; | |||
| buf[ offset + idx ] = (byte)'0'; | |||
| --idx; | |||
| } | |||
| else | |||
| { | |||
| 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; | |||
| } | |||
| } | |||
| for( ; idx >= 0; --idx ) | |||
| { | |||
| buf[offset + idx] = ( byte )' '; | |||
| buf[ offset + idx ] = (byte)' '; | |||
| } | |||
| return offset + length; | |||
| @@ -134,7 +134,7 @@ public class TarUtils | |||
| for( int i = 0; i < buf.length; ++i ) | |||
| { | |||
| sum += 255 & buf[i]; | |||
| sum += 255 & buf[ i ]; | |||
| } | |||
| return sum; | |||
| @@ -155,12 +155,12 @@ public class TarUtils | |||
| for( int i = offset; i < end; ++i ) | |||
| { | |||
| if( header[i] == 0 ) | |||
| if( header[ i ] == 0 ) | |||
| { | |||
| break; | |||
| } | |||
| result.append( ( char )header[i] ); | |||
| result.append( (char)header[ i ] ); | |||
| } | |||
| return result; | |||
| @@ -183,26 +183,26 @@ public class TarUtils | |||
| for( int i = offset; i < end; ++i ) | |||
| { | |||
| if( header[i] == 0 ) | |||
| if( header[ i ] == 0 ) | |||
| { | |||
| break; | |||
| } | |||
| if( header[i] == ( byte )' ' || header[i] == '0' ) | |||
| if( header[ i ] == (byte)' ' || header[ i ] == '0' ) | |||
| { | |||
| if( stillPadding ) | |||
| { | |||
| continue; | |||
| } | |||
| if( header[i] == ( byte )' ' ) | |||
| if( header[ i ] == (byte)' ' ) | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| stillPadding = false; | |||
| result = ( result << 3 ) + ( header[i] - '0' ); | |||
| result = ( result << 3 ) + ( header[ i ] - '0' ); | |||
| } | |||
| return result; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.ZipException; | |||
| @@ -79,7 +80,9 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| */ | |||
| private CRC32 crc = new CRC32(); | |||
| public AsiExtraField() { } | |||
| public AsiExtraField() | |||
| { | |||
| } | |||
| /** | |||
| * Indicate whether this entry is a directory. | |||
| @@ -205,17 +208,17 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| public byte[] getLocalFileDataData() | |||
| { | |||
| // 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 ); | |||
| byte[] linkArray = getLinkedFile().getBytes(); | |||
| System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(), | |||
| 0, data, 2, 4 ); | |||
| 0, data, 2, 4 ); | |||
| System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(), | |||
| 0, data, 6, 2 ); | |||
| 0, data, 6, 2 ); | |||
| System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(), | |||
| 0, data, 8, 2 ); | |||
| 0, data, 8, 2 ); | |||
| System.arraycopy( linkArray, 0, data, 10, linkArray.length ); | |||
| @@ -223,7 +226,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| crc.update( data ); | |||
| 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( data, 0, result, 4, data.length ); | |||
| return result; | |||
| @@ -239,11 +242,11 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| public ZipShort getLocalFileDataLength() | |||
| { | |||
| 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(); | |||
| byte[] tmp = new byte[length - 4]; | |||
| byte[] tmp = new byte[ length - 4 ]; | |||
| System.arraycopy( data, offset + 4, tmp, 0, length - 4 ); | |||
| crc.reset(); | |||
| crc.update( tmp ); | |||
| @@ -312,13 +315,13 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable | |||
| if( givenChecksum != realChecksum ) | |||
| { | |||
| 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(); | |||
| 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(); | |||
| gid = ( new ZipShort( tmp, 8 ) ).getValue(); | |||
| @@ -92,7 +92,7 @@ public class UnrecognizedExtraField implements ZipExtraField | |||
| 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 ); | |||
| setLocalFileDataData( tmp ); | |||
| } | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.util.ArrayList; | |||
| @@ -120,7 +121,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| public ZipEntry( ZipEntry entry ) | |||
| throws ZipException | |||
| { | |||
| this( ( java.util.zip.ZipEntry )entry ); | |||
| this( (java.util.zip.ZipEntry)entry ); | |||
| setInternalAttributes( entry.getInternalAttributes() ); | |||
| setExternalAttributes( entry.getExternalAttributes() ); | |||
| setExtraFields( entry.getExtraFields() ); | |||
| @@ -142,7 +143,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| { | |||
| setCompressedSizeMethod = | |||
| java.util.zip.ZipEntry.class.getMethod( "setCompressedSize", | |||
| new Class[]{Long.TYPE} ); | |||
| new Class[]{Long.TYPE} ); | |||
| } | |||
| catch( NoSuchMethodException nse ) | |||
| { | |||
| @@ -181,14 +182,14 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| { | |||
| Throwable nested = ite.getTargetException(); | |||
| throw new RuntimeException( "Exception setting the compressed size " | |||
| + "of " + ze + ": " | |||
| + nested.getMessage() ); | |||
| + "of " + ze + ": " | |||
| + nested.getMessage() ); | |||
| } | |||
| catch( Throwable other ) | |||
| { | |||
| 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(); | |||
| for( int i = 0; i < fields.length; i++ ) | |||
| { | |||
| extraFields.add( fields[i] ); | |||
| extraFields.add( fields[ i ] ); | |||
| } | |||
| setExtra(); | |||
| } | |||
| @@ -341,7 +342,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| public byte[] getLocalFileDataExtra() | |||
| { | |||
| 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; | |||
| 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 ); | |||
| done = true; | |||
| @@ -381,7 +382,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| ZipEntry e = null; | |||
| try | |||
| { | |||
| e = new ZipEntry( ( java.util.zip.ZipEntry )super.clone() ); | |||
| e = new ZipEntry( (java.util.zip.ZipEntry)super.clone() ); | |||
| } | |||
| catch( Exception ex ) | |||
| { | |||
| @@ -405,7 +406,7 @@ public class ZipEntry extends java.util.zip.ZipEntry | |||
| boolean done = false; | |||
| 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 ); | |||
| done = true; | |||
| @@ -6,6 +6,7 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.util.zip.ZipException; | |||
| /** | |||
| @@ -50,10 +50,10 @@ public class ZipLong implements Cloneable | |||
| */ | |||
| 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() | |||
| { | |||
| 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; | |||
| } | |||
| @@ -96,7 +96,7 @@ public class ZipLong implements Cloneable | |||
| { | |||
| return false; | |||
| } | |||
| return value == ( ( ZipLong )o ).getValue(); | |||
| return value == ( (ZipLong)o ).getValue(); | |||
| } | |||
| /** | |||
| @@ -107,7 +107,7 @@ public class ZipLong implements Cloneable | |||
| */ | |||
| public int hashCode() | |||
| { | |||
| return ( int )value; | |||
| return (int)value; | |||
| } | |||
| }// ZipLong | |||
| @@ -6,12 +6,13 @@ | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.tools.zip; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.Hashtable; | |||
| import java.util.ArrayList; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.Deflater; | |||
| import java.util.zip.DeflaterOutputStream; | |||
| @@ -216,17 +217,17 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| return DOS_TIME_MIN; | |||
| } | |||
| 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 ); | |||
| } | |||
| @@ -332,19 +333,19 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| if( entry.getCrc() != realCrc ) | |||
| { | |||
| 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 ) | |||
| { | |||
| 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 ); | |||
| for( int i = 0; i < entries.size(); i++ ) | |||
| { | |||
| writeCentralFileHeader( ( ZipEntry )entries.get( i ) ); | |||
| writeCentralFileHeader( (ZipEntry)entries.get( i ) ); | |||
| } | |||
| cdLength = new ZipLong( written - cdOffset.getValue() ); | |||
| writeCentralDirectoryEnd(); | |||
| @@ -593,7 +594,7 @@ public class ZipOutputStream extends DeflaterOutputStream | |||
| written += 4; | |||
| // relative offset of LFH | |||
| out.write( ( ( ZipLong )offsets.get( ze ) ).getBytes() ); | |||
| out.write( ( (ZipLong)offsets.get( ze ) ).getBytes() ); | |||
| written += 4; | |||
| // file name | |||
| @@ -50,8 +50,8 @@ public class ZipShort implements Cloneable | |||
| */ | |||
| 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() | |||
| { | |||
| 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; | |||
| } | |||
| @@ -92,7 +92,7 @@ public class ZipShort implements Cloneable | |||
| { | |||
| return false; | |||
| } | |||
| return value == ( ( ZipShort )o ).getValue(); | |||
| return value == ( (ZipShort)o ).getValue(); | |||
| } | |||
| /** | |||