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/tar TarUtils.java
Date Mon, 28 Jan 2002 09:24:45 GMT
donaldp     02/01/28 01:24:45

  Modified:    proposal/myrmidon/src/java/org/apache/aut/tar TarUtils.java
  Log:
  Dont modify loop counters in for loops
  
  Revision  Changes    Path
  1.4       +34 -18    jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/tar/TarUtils.java
  
  Index: TarUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/tar/TarUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TarUtils.java	27 Jan 2002 01:17:30 -0000	1.3
  +++ TarUtils.java	28 Jan 2002 09:24:45 -0000	1.4
  @@ -24,7 +24,10 @@
        * @param buf Description of Parameter
        * @return The integer value of the entry's checksum.
        */
  -    public static int getCheckSumOctalBytes( long value, byte[] buf, int offset, int length
)
  +    public static int getCheckSumOctalBytes( final long value,
  +                                             final byte[] buf,
  +                                             final int offset,
  +                                             final int length )
       {
           getOctalBytes( value, buf, offset, length );
   
  @@ -43,7 +46,10 @@
        * @param buf Description of Parameter
        * @return The long value of the octal bytes.
        */
  -    public static int getLongOctalBytes( long value, byte[] buf, int offset, int length
)
  +    public static int getLongOctalBytes( final long value,
  +                                         final byte[] buf,
  +                                         final int offset,
  +                                         final int length )
       {
           byte[] temp = new byte[ length + 1 ];
   
  @@ -62,18 +68,21 @@
        * @param buf Description of Parameter
        * @return The number of bytes in a header's entry name.
        */
  -    public static int getNameBytes( StringBuffer name, byte[] buf, int offset, int length
)
  +    public static int getNameBytes( final StringBuffer name,
  +                                    final byte[] buffer,
  +                                    final int offset,
  +                                    final int length )
       {
           int i;
   
           for( i = 0; i < length && i < name.length(); ++i )
           {
  -            buf[ offset + i ] = (byte)name.charAt( i );
  +            buffer[ offset + i ] = (byte)name.charAt( i );
           }
   
           for( ; i < length; ++i )
           {
  -            buf[ offset + i ] = 0;
  +            buffer[ offset + i ] = 0;
           }
   
           return offset + length;
  @@ -87,34 +96,37 @@
        * @return The integer value of the octal bytes.
        */
       public static int getOctalBytes( final long value,
  -                                     final byte[] buf,
  +                                     final byte[] buffer,
                                        final int offset,
                                        final int length )
       {
           int idx = length - 1;
   
  -        buf[ offset + idx ] = 0;
  +        buffer[ offset + idx ] = 0;
           --idx;
  -        buf[ offset + idx ] = (byte)' ';
  +        buffer[ offset + idx ] = (byte)' ';
           --idx;
   
           if( value == 0 )
           {
  -            buf[ offset + idx ] = (byte)'0';
  +            buffer[ offset + idx ] = (byte)'0';
               --idx;
           }
           else
           {
  -            for( long val = value; idx >= 0 && val > 0; --idx )
  +            long val = value;
  +            while( idx >= 0 && val > 0 )
               {
  -                buf[ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
  +                buffer[ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
                   val = val >> 3;
  +                idx--;
               }
           }
   
  -        for( ; idx >= 0; --idx )
  +        while( idx >= 0 )
           {
  -            buf[ offset + idx ] = (byte)' ';
  +            buffer[ offset + idx ] = (byte)' ';
  +            idx--;
           }
   
           return offset + length;
  @@ -126,13 +138,13 @@
        * @param buf The tar entry's header buffer.
        * @return The computed checksum.
        */
  -    public static long computeCheckSum( byte[] buf )
  +    public static long computeCheckSum( final byte[] buffer )
       {
           long sum = 0;
   
  -        for( int i = 0; i < buf.length; ++i )
  +        for( int i = 0; i < buffer.length; ++i )
           {
  -            sum += 255 & buf[ i ];
  +            sum += 255 & buffer[ i ];
           }
   
           return sum;
  @@ -146,7 +158,9 @@
        * @param length The number of header bytes to parse.
        * @return The header's entry name.
        */
  -    public static StringBuffer parseName( byte[] header, int offset, int length )
  +    public static StringBuffer parseName( final byte[] header,
  +                                          final int offset,
  +                                          final int length )
       {
           StringBuffer result = new StringBuffer( length );
           int end = offset + length;
  @@ -173,7 +187,9 @@
        * @param length The number of header bytes to parse.
        * @return The long value of the octal string.
        */
  -    public static long parseOctal( byte[] header, int offset, int length )
  +    public static long parseOctal( final byte[] header,
  +                                   final int offset,
  +                                   final int length )
       {
           long result = 0;
           boolean stillPadding = true;
  
  
  

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