tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevin seguin <seg...@motive.com>
Subject Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java
Date Sun, 03 Jun 2001 18:16:25 GMT
i was looking at the diffs here because i was going to propagate this
change to jakarta-tomcat-connectors, but i'm no sure i understand this:

>        public int getOffset() {
>   -     return getStart();
>   +     return getEnd();
>        }

perhaps i'm missing something, but it looks like the offset returned by
getOffset() should be the offset into the byte array contained in
ByteChunk, which would be the start position in this case, rather than
the end position.

also, if you look at the append() and equals() methods that take
ByteChunk's as arguments, if getOffset() returns the end position rather
than the start position, these methods won't work as intended.  for
example, equals() will start comparing comparing bytes at the end of the
ByteChunk, rather than the start of it.

just a sanity check...

-kevin.

nacho@apache.org wrote:
> 
> nacho       01/06/02 14:53:46
> 
>   Modified:    src/share/org/apache/tomcat/util/buf ByteChunk.java
>   Log:
>   Latest encoding fixes left some problems in the way.
>   Fixing a hack is a hazardous task..
> 
>   Revision  Changes    Path
>   1.5       +11 -10    jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
> 
>   Index: ByteChunk.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- ByteChunk.java    2001/05/27 23:16:19     1.4
>   +++ ByteChunk.java    2001/06/02 21:53:46     1.5
>   @@ -208,12 +208,13 @@
>        public int getStart() {
>         return start;
>        }
>   -
>   +
>        public int getOffset() {
>   -     return getStart();
>   +     return getEnd();
>        }
> 
>        public void setOffset(int off) {
>   +        if (end < off ) end=off;
>         start=off;
>        }
> 
>   @@ -263,7 +264,7 @@
>        {
>         append( (byte)c);
>        }
>   -
>   +
>        public void append( byte b )
>         throws IOException
>        {
>   @@ -275,13 +276,13 @@
>         }
>         buff[end++]=b;
>        }
>   -
>   +
>        public void append( ByteChunk src )
>         throws IOException
>        {
>         append( src.getBytes(), src.getOffset(), src.getLength());
>        }
>   -
>   +
>        /** Add data to the buffer
>         */
>        public void append( byte src[], int off, int len )
>   @@ -297,7 +298,7 @@
>             end+=len;
>             return;
>         }
>   -
>   +
>         // if we have limit and we're below
>         if( len <= limit - end ) {
>             // makeSpace will grow the buffer to the limit,
>   @@ -311,7 +312,7 @@
>         // buffer
> 
>         // the buffer is already at ( or bigger than ) limit
>   -
>   +
>         // Optimization:
>         // If len-avail < length ( i.e. after we fill the buffer with
>         // what we can, the remaining will fit in the buffer ) we'll just
>   @@ -327,12 +328,12 @@
>             int avail=limit-end;
>             System.arraycopy(src, off, buff, end, avail);
>             end += avail;
>   -
>   +
>             flushBuffer();
>   -
>   +
>             System.arraycopy(src, off+avail, buff, end, len - avail);
>             end+= len - avail;
>   -
>   +
>         } else {        // len > buf.length + avail
>             // long write - flush the buffer and write the rest
>             // directly from source
> 
> 
>

Mime
View raw message