ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/bzip2 CBZip2OutputStream.java
Date Sun, 27 Jan 2002 03:16:03 GMT
donaldp     02/01/26 19:16:03

  Modified:    proposal/myrmidon/src/java/org/apache/aut/bzip2
                        CBZip2OutputStream.java
  Log:
  Fixup location of []s
  
  Revision  Changes    Path
  1.3       +289 -165  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/bzip2/CBZip2OutputStream.java
  
  Index: CBZip2OutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/bzip2/CBZip2OutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CBZip2OutputStream.java	20 Jan 2002 17:32:56 -0000	1.2
  +++ CBZip2OutputStream.java	27 Jan 2002 03:16:03 -0000	1.3
  @@ -12,19 +12,20 @@
   
   /**
    * An output stream that compresses into the BZip2 format (without the file
  - * header chars) into another stream.
  + * header chars) into another stream. TODO: Update to BZip2 1.0.1
    *
  - * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a> TODO: Update
to
  - *      BZip2 1.0.1
  + * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
    */
  -public class CBZip2OutputStream extends OutputStream implements BZip2Constants
  +public class CBZip2OutputStream
  +    extends OutputStream
  +    implements BZip2Constants
   {
  -    protected final static int SETMASK = ( 1 << 21 );
  -    protected final static int CLEARMASK = ( ~SETMASK );
  -    protected final static int GREATER_ICOST = 15;
  -    protected final static int LESSER_ICOST = 0;
  -    protected final static int SMALL_THRESH = 20;
  -    protected final static int DEPTH_THRESH = 10;
  +    private final static int SETMASK = ( 1 << 21 );
  +    private final static int CLEARMASK = ( ~SETMASK );
  +    private final static int GREATER_ICOST = 15;
  +    private final static int LESSER_ICOST = 0;
  +    private final static int SMALL_THRESH = 20;
  +    private final static int DEPTH_THRESH = 10;
   
       /*
        * If you are ever unlucky/improbable enough
  @@ -34,18 +35,19 @@
        * stack go above 27 elems, so the following
        * limit seems very generous.
        */
  -    protected final static int QSORT_STACK_SIZE = 1000;
  -    CRC mCrc = new CRC();
  +    private final static int QSORT_STACK_SIZE = 1000;
   
  -    private boolean inUse[] = new boolean[ 256 ];
  +    private CRC m_crc = new CRC();
   
  -    private char seqToUnseq[] = new char[ 256 ];
  -    private char unseqToSeq[] = new char[ 256 ];
  +    private boolean[] m_inUse = new boolean[ 256 ];
   
  -    private char selector[] = new char[ MAX_SELECTORS ];
  -    private char selectorMtf[] = new char[ MAX_SELECTORS ];
  +    private char[] seqToUnseq = new char[ 256 ];
  +    private char[] unseqToSeq = new char[ 256 ];
   
  -    private int mtfFreq[] = new int[ MAX_ALPHA_SIZE ];
  +    private char[] selector = new char[ MAX_SELECTORS ];
  +    private char[] selectorMtf = new char[ MAX_SELECTORS ];
  +
  +    private int[] mtfFreq = new int[ MAX_ALPHA_SIZE ];
   
       private int currentChar = -1;
       private int runLength = 0;
  @@ -58,9 +60,12 @@
        * because the number of elems to sort is
        * usually small, typically <= 20.
        */
  -    private int incs[] = {1, 4, 13, 40, 121, 364, 1093, 3280,
  -                          9841, 29524, 88573, 265720,
  -                          797161, 2391484};
  +    private int[] incs = new int[]
  +    {
  +        1, 4, 13, 40, 121, 364, 1093, 3280,
  +        9841, 29524, 88573, 265720,
  +        797161, 2391484
  +    };
   
       boolean blockRandomised;
   
  @@ -88,19 +93,19 @@
   
       private int allowableBlockSize;
   
  -    private char block[];
  +    private char[] block;
   
       private int blockCRC, combinedCRC;
   
       private OutputStream bsStream;
       private boolean firstAttempt;
  -    private int ftab[];
  +    private int[] ftab;
       private int nBlocksRandomised;
       private int nInUse;
   
       private int nMTF;
  -    private int quadrant[];
  -    private short szptr[];
  +    private int[] quadrant;
  +    private short[] szptr;
       private int workDone;
   
       /*
  @@ -110,7 +115,7 @@
        */
       private int workFactor;
       private int workLimit;
  -    private int zptr[];
  +    private int[] zptr;
   
       public CBZip2OutputStream( OutputStream inStream )
           throws IOException
  @@ -183,11 +188,12 @@
           int k;
           boolean tooLong;
   
  -        int heap[] = new int[ MAX_ALPHA_SIZE + 2 ];
  -        int weight[] = new int[ MAX_ALPHA_SIZE * 2 ];
  -        int parent[] = new int[ MAX_ALPHA_SIZE * 2 ];
  +        int[] heap = new int[ MAX_ALPHA_SIZE + 2 ];
  +        int[] weight = new int[ MAX_ALPHA_SIZE * 2 ];
  +        int[] parent = new int[ MAX_ALPHA_SIZE * 2 ];
   
  -        for( i = 0; i < alphaSize; i++ ) {
  +        for( i = 0; i < alphaSize; i++ )
  +        {
               weight[ i + 1 ] = ( freq[ i ] == 0 ? 1 : freq[ i ] ) << 8;
           }
   
  @@ -218,7 +224,8 @@
                       heap[ zz ] = tmp;
                   }
               }
  -            if( !( nHeap < ( MAX_ALPHA_SIZE + 2 ) ) ) {
  +            if( !( nHeap < ( MAX_ALPHA_SIZE + 2 ) ) )
  +            {
                   panic();
               }
   
  @@ -236,14 +243,17 @@
                       while( true )
                       {
                           yy = zz << 1;
  -                        if( yy > nHeap ) {
  +                        if( yy > nHeap )
  +                        {
                               break;
                           }
                           if( yy < nHeap &&
  -                            weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) {
  +                            weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] )
  +                        {
                               yy++;
                           }
  -                        if( weight[ tmp ] < weight[ heap[ yy ] ] ) {
  +                        if( weight[ tmp ] < weight[ heap[ yy ] ] )
  +                        {
                               break;
                           }
                           heap[ zz ] = heap[ yy ];
  @@ -263,14 +273,17 @@
                       while( true )
                       {
                           yy = zz << 1;
  -                        if( yy > nHeap ) {
  +                        if( yy > nHeap )
  +                        {
                               break;
                           }
                           if( yy < nHeap &&
  -                            weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] ) {
  +                            weight[ heap[ yy + 1 ] ] < weight[ heap[ yy ] ] )
  +                        {
                               yy++;
                           }
  -                        if( weight[ tmp ] < weight[ heap[ yy ] ] ) {
  +                        if( weight[ tmp ] < weight[ heap[ yy ] ] )
  +                        {
                               break;
                           }
                           heap[ zz ] = heap[ yy ];
  @@ -304,7 +317,8 @@
                       heap[ zz ] = tmp;
                   }
               }
  -            if( !( nNodes < ( MAX_ALPHA_SIZE * 2 ) ) ) {
  +            if( !( nNodes < ( MAX_ALPHA_SIZE * 2 ) ) )
  +            {
                   panic();
               }
   
  @@ -319,12 +333,14 @@
                       j++;
                   }
                   len[ i - 1 ] = (char)j;
  -                if( j > maxLen ) {
  +                if( j > maxLen )
  +                {
                       tooLong = true;
                   }
               }
   
  -            if( !tooLong ) {
  +            if( !tooLong )
  +            {
                   break;
               }
   
  @@ -346,11 +362,13 @@
       public void close()
           throws IOException
       {
  -        if( closed ) {
  +        if( closed )
  +        {
               return;
           }
   
  -        if( runLength > 0 ) {
  +        if( runLength > 0 )
  +        {
               writeRun();
           }
           currentChar = -1;
  @@ -533,7 +551,8 @@
           }
   
           origPtr = -1;
  -        for( i = 0; i <= last; i++ ) {
  +        for( i = 0; i <= last; i++ )
  +        {
               if( zptr[ i ] == 0 )
               {
                   origPtr = i;
  @@ -542,7 +561,8 @@
           }
           ;
   
  -        if( origPtr == -1 ) {
  +        if( origPtr == -1 )
  +        {
               panic();
           }
       }
  @@ -550,7 +570,7 @@
       private void endBlock()
           throws IOException
       {
  -        blockCRC = mCrc.getFinalCRC();
  +        blockCRC = m_crc.getFinalCRC();
           combinedCRC = ( combinedCRC << 1 ) | ( combinedCRC >>> 31 );
           combinedCRC ^= blockCRC;
   
  @@ -635,7 +655,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -643,7 +664,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -651,7 +673,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -659,7 +682,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -667,7 +691,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -675,7 +700,8 @@
   
           c1 = block[ i1 + 1 ];
           c2 = block[ i2 + 1 ];
  -        if( c1 != c2 ) {
  +        if( c1 != c2 )
  +        {
               return ( c1 > c2 );
           }
           i1++;
  @@ -687,12 +713,14 @@
           {
               c1 = block[ i1 + 1 ];
               c2 = block[ i2 + 1 ];
  -            if( c1 != c2 ) {
  +            if( c1 != c2 )
  +            {
                   return ( c1 > c2 );
               }
               s1 = quadrant[ i1 ];
               s2 = quadrant[ i2 ];
  -            if( s1 != s2 ) {
  +            if( s1 != s2 )
  +            {
                   return ( s1 > s2 );
               }
               i1++;
  @@ -700,12 +728,14 @@
   
               c1 = block[ i1 + 1 ];
               c2 = block[ i2 + 1 ];
  -            if( c1 != c2 ) {
  +            if( c1 != c2 )
  +            {
                   return ( c1 > c2 );
               }
               s1 = quadrant[ i1 ];
               s2 = quadrant[ i2 ];
  -            if( s1 != s2 ) {
  +            if( s1 != s2 )
  +            {
                   return ( s1 > s2 );
               }
               i1++;
  @@ -713,12 +743,14 @@
   
               c1 = block[ i1 + 1 ];
               c2 = block[ i2 + 1 ];
  -            if( c1 != c2 ) {
  +            if( c1 != c2 )
  +            {
                   return ( c1 > c2 );
               }
               s1 = quadrant[ i1 ];
               s2 = quadrant[ i2 ];
  -            if( s1 != s2 ) {
  +            if( s1 != s2 )
  +            {
                   return ( s1 > s2 );
               }
               i1++;
  @@ -726,12 +758,14 @@
   
               c1 = block[ i1 + 1 ];
               c2 = block[ i2 + 1 ];
  -            if( c1 != c2 ) {
  +            if( c1 != c2 )
  +            {
                   return ( c1 > c2 );
               }
               s1 = quadrant[ i1 ];
               s2 = quadrant[ i2 ];
  -            if( s1 != s2 ) {
  +            if( s1 != s2 )
  +            {
                   return ( s1 > s2 );
               }
               i1++;
  @@ -759,7 +793,7 @@
   
       private void generateMTFValues()
       {
  -        char yy[] = new char[ 256 ];
  +        char[] yy = new char[ 256 ];
           int i;
           int j;
           char tmp;
  @@ -771,13 +805,15 @@
           makeMaps();
           EOB = nInUse + 1;
   
  -        for( i = 0; i <= EOB; i++ ) {
  +        for( i = 0; i <= EOB; i++ )
  +        {
               mtfFreq[ i ] = 0;
           }
   
           wr = 0;
           zPend = 0;
  -        for( i = 0; i < nInUse; i++ ) {
  +        for( i = 0; i < nInUse; i++ )
  +        {
               yy[ i ] = (char)i;
           }
   
  @@ -824,7 +860,8 @@
                                   break;
                           }
                           ;
  -                        if( zPend < 2 ) {
  +                        if( zPend < 2 )
  +                        {
                               break;
                           }
                           zPend = ( zPend - 2 ) / 2;
  @@ -856,7 +893,8 @@
                           mtfFreq[ RUNB ]++;
                           break;
                   }
  -                if( zPend < 2 ) {
  +                if( zPend < 2 )
  +                {
                       break;
                   }
                   zPend = ( zPend - 2 ) / 2;
  @@ -880,7 +918,8 @@
           vec = 0;
           for( n = minLen; n <= maxLen; n++ )
           {
  -            for( i = 0; i < alphaSize; i++ ) {
  +            for( i = 0; i < alphaSize; i++ )
  +            {
                   if( length[ i ] == n )
                   {
                       code[ i ] = vec;
  @@ -895,12 +934,13 @@
       private void initBlock()
       {
           //        blockNo++;
  -        mCrc.initialiseCRC();
  +        m_crc.initialiseCRC();
           last = -1;
           //        ch = 0;
   
  -        for( int i = 0; i < 256; i++ ) {
  -            inUse[ i ] = false;
  +        for( int i = 0; i < 256; i++ )
  +        {
  +            m_inUse[ i ] = false;
           }
   
           /*
  @@ -932,9 +972,9 @@
           int j;
           int ss;
           int sb;
  -        int runningOrder[] = new int[ 256 ];
  -        int copy[] = new int[ 256 ];
  -        boolean bigDone[] = new boolean[ 256 ];
  +        int[] runningOrder = new int[ 256 ];
  +        int[] copy = new int[ 256 ];
  +        boolean[] bigDone = new boolean[ 256 ];
           int c1;
           int c2;
           int numQSorted;
  @@ -945,10 +985,12 @@
            * set up the overshoot area for block.
            */
           //   if (verbosity >= 4) fprintf ( stderr, "        sort initialise ...\n" );
  -        for( i = 0; i < NUM_OVERSHOOT_BYTES; i++ ) {
  +        for( i = 0; i < NUM_OVERSHOOT_BYTES; i++ )
  +        {
               block[ last + i + 2 ] = block[ ( i % ( last + 1 ) ) + 1 ];
           }
  -        for( i = 0; i <= last + NUM_OVERSHOOT_BYTES; i++ ) {
  +        for( i = 0; i <= last + NUM_OVERSHOOT_BYTES; i++ )
  +        {
               quadrant[ i ] = 0;
           }
   
  @@ -960,7 +1002,8 @@
                * Use simpleSort(), since the full sorting mechanism
                * has quite a large constant overhead.
                */
  -            for( i = 0; i <= last; i++ ) {
  +            for( i = 0; i <= last; i++ )
  +            {
                   zptr[ i ] = i;
               }
               firstAttempt = false;
  @@ -970,11 +1013,13 @@
           else
           {
               numQSorted = 0;
  -            for( i = 0; i <= 255; i++ ) {
  +            for( i = 0; i <= 255; i++ )
  +            {
                   bigDone[ i ] = false;
               }
   
  -            for( i = 0; i <= 65536; i++ ) {
  +            for( i = 0; i <= 65536; i++ )
  +            {
                   ftab[ i ] = 0;
               }
   
  @@ -986,7 +1031,8 @@
                   c1 = c2;
               }
   
  -            for( i = 1; i <= 65536; i++ ) {
  +            for( i = 1; i <= 65536; i++ )
  +            {
                   ftab[ i ] += ftab[ i - 1 ];
               }
   
  @@ -1009,16 +1055,17 @@
                * Calculate the running order, from smallest to largest
                * big bucket.
                */
  -            for( i = 0; i <= 255; i++ ) {
  +            for( i = 0; i <= 255; i++ )
  +            {
                   runningOrder[ i ] = i;
               }
               {
                   int vv;
                   int h = 1;
  -                do {
  +                do
  +                {
                       h = 3 * h + 1;
  -                }
  -                while( h <= 256 );
  +                } while( h <= 256 );
                   do
                   {
                       h = h / 3;
  @@ -1032,7 +1079,8 @@
                           {
                               runningOrder[ j ] = runningOrder[ j - h ];
                               j = j - h;
  -                            if( j <= ( h - 1 ) ) {
  +                            if( j <= ( h - 1 ) )
  +                            {
                                   break;
                               }
                           }
  @@ -1070,7 +1118,8 @@
                           {
                               qSort3( lo, hi, 2 );
                               numQSorted += ( hi - lo + 1 );
  -                            if( workDone > workLimit && firstAttempt ) {
  +                            if( workDone > workLimit && firstAttempt )
  +                            {
                                   return;
                               }
                           }
  @@ -1094,7 +1143,8 @@
                       int bbSize = ( ftab[ ( ss + 1 ) << 8 ] & CLEARMASK ) - bbStart;
                       int shifts = 0;
   
  -                    while( ( bbSize >> shifts ) > 65534 ) {
  +                    while( ( bbSize >> shifts ) > 65534 )
  +                    {
                           shifts++;
                       }
   
  @@ -1103,12 +1153,14 @@
                           int a2update = zptr[ bbStart + j ];
                           int qVal = ( j >> shifts );
                           quadrant[ a2update ] = qVal;
  -                        if( a2update < NUM_OVERSHOOT_BYTES ) {
  +                        if( a2update < NUM_OVERSHOOT_BYTES )
  +                        {
                               quadrant[ a2update + last + 1 ] = qVal;
                           }
                       }
   
  -                    if( !( ( ( bbSize - 1 ) >> shifts ) <= 65535 ) ) {
  +                    if( !( ( ( bbSize - 1 ) >> shifts ) <= 65535 ) )
  +                    {
                           panic();
                       }
                   }
  @@ -1117,7 +1169,8 @@
                    * Now scan this big bucket so as to synthesise the
                    * sorted order for small buckets [t, ss] for all t != ss.
                    */
  -                for( j = 0; j <= 255; j++ ) {
  +                for( j = 0; j <= 255; j++ )
  +                {
                       copy[ j ] = ftab[ ( j << 8 ) + ss ] & CLEARMASK;
                   }
   
  @@ -1132,7 +1185,8 @@
                       }
                   }
   
  -                for( j = 0; j <= 255; j++ ) {
  +                for( j = 0; j <= 255; j++ )
  +                {
                       ftab[ ( j << 8 ) + ss ] |= SETMASK;
                   }
               }
  @@ -1143,8 +1197,9 @@
       {
           int i;
           nInUse = 0;
  -        for( i = 0; i < 256; i++ ) {
  -            if( inUse[ i ] )
  +        for( i = 0; i < 256; i++ )
  +        {
  +            if( m_inUse[ i ] )
               {
                   seqToUnseq[ nInUse ] = (char)i;
                   unseqToSeq[ i ] = (char)nInUse;
  @@ -1168,7 +1223,8 @@
               b = c;
               c = t;
           }
  -        if( a > b ) {
  +        if( a > b )
  +        {
               b = a;
           }
           return b;
  @@ -1196,7 +1252,8 @@
           int hi;
           int d;
           StackElem[] stack = new StackElem[ QSORT_STACK_SIZE ];
  -        for( int count = 0; count < QSORT_STACK_SIZE; count++ ) {
  +        for( int count = 0; count < QSORT_STACK_SIZE; count++ )
  +        {
               stack[ count ] = new StackElem();
           }
   
  @@ -1209,7 +1266,8 @@
   
           while( sp > 0 )
           {
  -            if( sp >= QSORT_STACK_SIZE ) {
  +            if( sp >= QSORT_STACK_SIZE )
  +            {
                   panic();
               }
   
  @@ -1221,7 +1279,8 @@
               if( hi - lo < SMALL_THRESH || d > DEPTH_THRESH )
               {
                   simpleSort( lo, hi, d );
  -                if( workDone > workLimit && firstAttempt ) {
  +                if( workDone > workLimit && firstAttempt )
  +                {
                       return;
                   }
                   continue;
  @@ -1238,7 +1297,8 @@
               {
                   while( true )
                   {
  -                    if( unLo > unHi ) {
  +                    if( unLo > unHi )
  +                    {
                           break;
                       }
                       n = ( (int)block[ zptr[ unLo ] + d + 1 ] ) - med;
  @@ -1253,14 +1313,16 @@
                           continue;
                       }
                       ;
  -                    if( n > 0 ) {
  +                    if( n > 0 )
  +                    {
                           break;
                       }
                       unLo++;
                   }
                   while( true )
                   {
  -                    if( unLo > unHi ) {
  +                    if( unLo > unHi )
  +                    {
                           break;
                       }
                       n = ( (int)block[ zptr[ unHi ] + d + 1 ] ) - med;
  @@ -1275,12 +1337,14 @@
                           continue;
                       }
                       ;
  -                    if( n < 0 ) {
  +                    if( n < 0 )
  +                    {
                           break;
                       }
                       unHi--;
                   }
  -                if( unLo > unHi ) {
  +                if( unLo > unHi )
  +                {
                       break;
                   }
                   int temp = 0;
  @@ -1330,8 +1394,9 @@
           int i;
           int rNToGo = 0;
           int rTPos = 0;
  -        for( i = 0; i < 256; i++ ) {
  -            inUse[ i ] = false;
  +        for( i = 0; i < 256; i++ )
  +        {
  +            m_inUse[ i ] = false;
           }
   
           for( i = 0; i <= last; i++ )
  @@ -1340,7 +1405,8 @@
               {
                   rNToGo = (char)RAND_NUMS[ rTPos ];
                   rTPos++;
  -                if( rTPos == 512 ) {
  +                if( rTPos == 512 )
  +                {
                       rTPos = 0;
                   }
               }
  @@ -1349,14 +1415,14 @@
               // handle 16 bit signed numbers
               block[ i + 1 ] &= 0xFF;
   
  -            inUse[ block[ i + 1 ] ] = true;
  +            m_inUse[ block[ i + 1 ] ] = true;
           }
       }
   
       private void sendMTFValues()
           throws IOException
       {
  -        char len[][] = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ];
  +        char[][] len = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ];
   
           int v;
   
  @@ -1386,8 +1452,10 @@
           int nBytes;
   
           alphaSize = nInUse + 2;
  -        for( t = 0; t < N_GROUPS; t++ ) {
  -            for( v = 0; v < alphaSize; v++ ) {
  +        for( t = 0; t < N_GROUPS; t++ )
  +        {
  +            for( v = 0; v < alphaSize; v++ )
  +            {
                   len[ t ][ v ] = (char)GREATER_ICOST;
               }
           }
  @@ -1395,21 +1463,31 @@
           /*
            * Decide how many coding tables to use
            */
  -        if( nMTF <= 0 ) {
  +        if( nMTF <= 0 )
  +        {
               panic();
           }
   
  -        if( nMTF < 200 ) {
  +        if( nMTF < 200 )
  +        {
               nGroups = 2;
  -        } else if( nMTF < 600 ) {
  +        }
  +        else if( nMTF < 600 )
  +        {
               nGroups = 3;
  -               } else if( nMTF < 1200 ) {
  +        }
  +        else if( nMTF < 1200 )
  +        {
               nGroups = 4;
  -                      } else if( nMTF < 2400 ) {
  +        }
  +        else if( nMTF < 2400 )
  +        {
               nGroups = 5;
  -                             } else {
  +        }
  +        else
  +        {
               nGroups = 6;
  -                             }
  +        }
           {
               /*
                * Generate an initial set of coding tables
  @@ -1440,10 +1518,14 @@
                       ge--;
                   }
   
  -                for( v = 0; v < alphaSize; v++ ) {
  -                    if( v >= gs && v <= ge ) {
  +                for( v = 0; v < alphaSize; v++ )
  +                {
  +                    if( v >= gs && v <= ge )
  +                    {
                           len[ nPart - 1 ][ v ] = (char)LESSER_ICOST;
  -                    } else {
  +                    }
  +                    else
  +                    {
                           len[ nPart - 1 ][ v ] = (char)GREATER_ICOST;
                       }
                   }
  @@ -1454,20 +1536,23 @@
               }
           }
   
  -        int rfreq[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
  -        int fave[] = new int[ N_GROUPS ];
  -        short cost[] = new short[ N_GROUPS ];
  +        int[][] rfreq = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
  +        int[] fave = new int[ N_GROUPS ];
  +        short[] cost = new short[ N_GROUPS ];
           /*
            * Iterate up to N_ITERS times to improve the tables.
            */
           for( iter = 0; iter < N_ITERS; iter++ )
           {
  -            for( t = 0; t < nGroups; t++ ) {
  +            for( t = 0; t < nGroups; t++ )
  +            {
                   fave[ t ] = 0;
               }
   
  -            for( t = 0; t < nGroups; t++ ) {
  -                for( v = 0; v < alphaSize; v++ ) {
  +            for( t = 0; t < nGroups; t++ )
  +            {
  +                for( v = 0; v < alphaSize; v++ )
  +                {
                       rfreq[ t ][ v ] = 0;
                   }
               }
  @@ -1481,11 +1566,13 @@
                   /*
                    * Set group start & end marks.
                    */
  -                if( gs >= nMTF ) {
  +                if( gs >= nMTF )
  +                {
                       break;
                   }
                   ge = gs + G_SIZE - 1;
  -                if( ge >= nMTF ) {
  +                if( ge >= nMTF )
  +                {
                       ge = nMTF - 1;
                   }
   
  @@ -1493,7 +1580,8 @@
                    * Calculate the cost of this group as coded
                    * by each of the coding tables.
                    */
  -                for( t = 0; t < nGroups; t++ ) {
  +                for( t = 0; t < nGroups; t++ )
  +                {
                       cost[ t ] = 0;
                   }
   
  @@ -1528,7 +1616,8 @@
                       for( i = gs; i <= ge; i++ )
                       {
                           short icv = szptr[ i ];
  -                        for( t = 0; t < nGroups; t++ ) {
  +                        for( t = 0; t < nGroups; t++ )
  +                        {
                               cost[ t ] += len[ t ][ icv ];
                           }
                       }
  @@ -1540,7 +1629,8 @@
                    */
                   bc = 999999999;
                   bt = -1;
  -                for( t = 0; t < nGroups; t++ ) {
  +                for( t = 0; t < nGroups; t++ )
  +                {
                       if( cost[ t ] < bc )
                       {
                           bc = cost[ t ];
  @@ -1556,7 +1646,8 @@
                   /*
                    * Increment the symbol frequencies for the selected table.
                    */
  -                for( i = gs; i <= ge; i++ ) {
  +                for( i = gs; i <= ge; i++ )
  +                {
                       rfreq[ bt ][ szptr[ i ] ]++;
                   }
   
  @@ -1566,7 +1657,8 @@
               /*
                * Recompute the tables based on the accumulated frequencies.
                */
  -            for( t = 0; t < nGroups; t++ ) {
  +            for( t = 0; t < nGroups; t++ )
  +            {
                   hbMakeCodeLengths( len[ t ], rfreq[ t ], alphaSize, 20 );
               }
           }
  @@ -1575,21 +1667,24 @@
           fave = null;
           cost = null;
   
  -        if( !( nGroups < 8 ) ) {
  +        if( !( nGroups < 8 ) )
  +        {
               panic();
           }
  -        if( !( nSelectors < 32768 && nSelectors <= ( 2 + ( 900000 / G_SIZE
) ) ) ) {
  +        if( !( nSelectors < 32768 && nSelectors <= ( 2 + ( 900000 / G_SIZE
) ) ) )
  +        {
               panic();
           }
           {
               /*
                * Compute MTF values for the selectors.
                */
  -            char pos[] = new char[ N_GROUPS ];
  +            char[] pos = new char[ N_GROUPS ];
               char ll_i;
               char tmp2;
               char tmp;
  -            for( i = 0; i < nGroups; i++ ) {
  +            for( i = 0; i < nGroups; i++ )
  +            {
                   pos[ i ] = (char)i;
               }
               for( i = 0; i < nSelectors; i++ )
  @@ -1609,7 +1704,7 @@
               }
           }
   
  -        int code[][] = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
  +        int[][] code = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
   
           /*
            * Assign actual codes for the tables.
  @@ -1620,17 +1715,21 @@
               maxLen = 0;
               for( i = 0; i < alphaSize; i++ )
               {
  -                if( len[ t ][ i ] > maxLen ) {
  +                if( len[ t ][ i ] > maxLen )
  +                {
                       maxLen = len[ t ][ i ];
                   }
  -                if( len[ t ][ i ] < minLen ) {
  +                if( len[ t ][ i ] < minLen )
  +                {
                       minLen = len[ t ][ i ];
                   }
               }
  -            if( maxLen > 20 ) {
  +            if( maxLen > 20 )
  +            {
                   panic();
               }
  -            if( minLen < 1 ) {
  +            if( minLen < 1 )
  +            {
                   panic();
               }
               hbAssignCodes( code[ t ], len[ t ], minLen, maxLen, alphaSize );
  @@ -1639,32 +1738,44 @@
               /*
                * Transmit the mapping table.
                */
  -            boolean inUse16[] = new boolean[ 16 ];
  +            boolean[] inUse16 = new boolean[ 16 ];
               for( i = 0; i < 16; i++ )
               {
                   inUse16[ i ] = false;
  -                for( j = 0; j < 16; j++ ) {
  -                    if( inUse[ i * 16 + j ] ) {
  +                for( j = 0; j < 16; j++ )
  +                {
  +                    if( m_inUse[ i * 16 + j ] )
  +                    {
                           inUse16[ i ] = true;
                       }
                   }
               }
   
               nBytes = bytesOut;
  -            for( i = 0; i < 16; i++ ) {
  -                if( inUse16[ i ] ) {
  +            for( i = 0; i < 16; i++ )
  +            {
  +                if( inUse16[ i ] )
  +                {
                       bsW( 1, 1 );
  -                } else {
  +                }
  +                else
  +                {
                       bsW( 1, 0 );
                   }
               }
   
  -            for( i = 0; i < 16; i++ ) {
  -                if( inUse16[ i ] ) {
  -                    for( j = 0; j < 16; j++ ) {
  -                        if( inUse[ i * 16 + j ] ) {
  +            for( i = 0; i < 16; i++ )
  +            {
  +                if( inUse16[ i ] )
  +                {
  +                    for( j = 0; j < 16; j++ )
  +                    {
  +                        if( m_inUse[ i * 16 + j ] )
  +                        {
                               bsW( 1, 1 );
  -                        } else {
  +                        }
  +                        else
  +                        {
                               bsW( 1, 0 );
                           }
                       }
  @@ -1681,7 +1792,8 @@
           bsW( 15, nSelectors );
           for( i = 0; i < nSelectors; i++ )
           {
  -            for( j = 0; j < selectorMtf[ i ]; j++ ) {
  +            for( j = 0; j < selectorMtf[ i ]; j++ )
  +            {
                   bsW( 1, 1 );
               }
               bsW( 1, 0 );
  @@ -1726,11 +1838,13 @@
           gs = 0;
           while( true )
           {
  -            if( gs >= nMTF ) {
  +            if( gs >= nMTF )
  +            {
                   break;
               }
               ge = gs + G_SIZE - 1;
  -            if( ge >= nMTF ) {
  +            if( ge >= nMTF )
  +            {
                   ge = nMTF - 1;
               }
               for( i = gs; i <= ge; i++ )
  @@ -1742,7 +1856,8 @@
               gs = ge + 1;
               selCtr++;
           }
  -        if( !( selCtr == nSelectors ) ) {
  +        if( !( selCtr == nSelectors ) )
  +        {
               panic();
           }
       }
  @@ -1757,12 +1872,14 @@
           int v;
   
           bigN = hi - lo + 1;
  -        if( bigN < 2 ) {
  +        if( bigN < 2 )
  +        {
               return;
           }
   
           hp = 0;
  -        while( incs[ hp ] < bigN ) {
  +        while( incs[ hp ] < bigN )
  +        {
               hp++;
           }
           hp--;
  @@ -1777,7 +1894,8 @@
                   /*
                    * copy 1
                    */
  -                if( i > hi ) {
  +                if( i > hi )
  +                {
                       break;
                   }
                   v = zptr[ i ];
  @@ -1786,7 +1904,8 @@
                   {
                       zptr[ j ] = zptr[ j - h ];
                       j = j - h;
  -                    if( j <= ( lo + h - 1 ) ) {
  +                    if( j <= ( lo + h - 1 ) )
  +                    {
                           break;
                       }
                   }
  @@ -1796,7 +1915,8 @@
                   /*
                    * copy 2
                    */
  -                if( i > hi ) {
  +                if( i > hi )
  +                {
                       break;
                   }
                   v = zptr[ i ];
  @@ -1805,7 +1925,8 @@
                   {
                       zptr[ j ] = zptr[ j - h ];
                       j = j - h;
  -                    if( j <= ( lo + h - 1 ) ) {
  +                    if( j <= ( lo + h - 1 ) )
  +                    {
                           break;
                       }
                   }
  @@ -1815,7 +1936,8 @@
                   /*
                    * copy 3
                    */
  -                if( i > hi ) {
  +                if( i > hi )
  +                {
                       break;
                   }
                   v = zptr[ i ];
  @@ -1824,14 +1946,16 @@
                   {
                       zptr[ j ] = zptr[ j - h ];
                       j = j - h;
  -                    if( j <= ( lo + h - 1 ) ) {
  +                    if( j <= ( lo + h - 1 ) )
  +                    {
                           break;
                       }
                   }
                   zptr[ j ] = v;
                   i++;
   
  -                if( workDone > workLimit && firstAttempt ) {
  +                if( workDone > workLimit && firstAttempt )
  +                {
                       return;
                   }
               }
  @@ -1857,10 +1981,10 @@
       {
           if( last < allowableBlockSize )
           {
  -            inUse[ currentChar ] = true;
  +            m_inUse[ currentChar ] = true;
               for( int i = 0; i < runLength; i++ )
               {
  -                mCrc.updateCRC( (char)currentChar );
  +                m_crc.updateCRC( (char)currentChar );
               }
               switch( runLength )
               {
  @@ -1883,7 +2007,7 @@
                       block[ last + 1 ] = (char)currentChar;
                       break;
                   default:
  -                    inUse[ runLength - 4 ] = true;
  +                    m_inUse[ runLength - 4 ] = true;
                       last++;
                       block[ last + 1 ] = (char)currentChar;
                       last++;
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message