Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 32075 invoked from network); 28 Jan 2002 09:24:53 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 28 Jan 2002 09:24:53 -0000 Received: (qmail 5103 invoked by uid 97); 28 Jan 2002 09:24:59 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 5085 invoked by uid 97); 28 Jan 2002 09:24:59 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 5056 invoked by uid 97); 28 Jan 2002 09:24:58 -0000 Date: 28 Jan 2002 09:24:45 -0000 Message-ID: <20020128092445.41376.qmail@icarus.apache.org> From: donaldp@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/tar TarUtils.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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: For additional commands, e-mail: