ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/tar TarInputStream.java
Date Mon, 21 Mar 2005 10:05:42 GMT
bodewig     2005/03/21 02:05:42

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/tar TarInputStream.java
  Log:
  Fix TarInputStream#read() and remove unneeded override of single-array-arg read method at
the same time.  PR 34097
  
  Revision  Changes    Path
  1.786     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.785
  retrieving revision 1.786
  diff -u -r1.785 -r1.786
  --- WHATSNEW	17 Mar 2005 12:01:18 -0000	1.785
  +++ WHATSNEW	21 Mar 2005 10:05:42 -0000	1.786
  @@ -420,6 +420,9 @@
   * The VAJ tasks could fail if the project name contained characters
     that need to get URL encoded.  Bugzilla Report 23322.
   
  +* TarInputStream#read() wasn't implemented correctly.  Bugzilla Report
  +  34097.
  +
   Changes from Ant 1.6.1 to Ant 1.6.2
   ===================================
   
  
  
  
  1.19      +8 -20     ant/src/main/org/apache/tools/tar/TarInputStream.java
  
  Index: TarInputStream.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarInputStream.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TarInputStream.java	11 Jan 2005 18:41:21 -0000	1.18
  +++ TarInputStream.java	21 Mar 2005 10:05:42 -0000	1.19
  @@ -40,13 +40,19 @@
       protected boolean hasHitEOF;
       protected int entrySize;
       protected int entryOffset;
  -    protected byte[] oneBuf;
       protected byte[] readBuf;
       protected TarBuffer buffer;
       protected TarEntry currEntry;
       private boolean v7Format;
   
       /**
  +     * This contents of this array is not used at all in this class,
  +     * it is only here to avoid repreated object creation during calls
  +     * to the no-arg read method.
  +     */
  +    protected byte[] oneBuf;
  +
  +    /**
        * Constructor for TarInputStream.
        * @param is the input stream to use
        */
  @@ -278,25 +284,7 @@
        */
       public int read() throws IOException {
           int num = this.read(this.oneBuf, 0, 1);
  -
  -        if (num == -1) {
  -            return num;
  -        } else {
  -            return (int) this.oneBuf[0];
  -        }
  -    }
  -
  -    /**
  -     * Reads bytes from the current tar archive entry.
  -     *
  -     * This method simply calls read( byte[], int, int ).
  -     *
  -     * @param buf The buffer into which to place bytes read.
  -     * @return The number of bytes read, or -1 at EOF.
  -     * @throws IOException on error
  -     */
  -    public int read(byte[] buf) throws IOException {
  -        return this.read(buf, 0, buf.length);
  +        return num == -1 ? -1 : ((int) this.oneBuf[0]) & 0xFF;
       }
   
       /**
  
  
  

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


Mime
View raw message