cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2004-12-15 Thread remm
remm2004/12/15 03:49:20

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  - If the encoding is invalid, this will cause a weird NPE. This avoids it.
  - The usage of a bad encoding should have been logged elsewhere in all cases, 
so I don't see the point of logging again.
  
  Revision  ChangesPath
  1.24  +4 -4  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ByteChunk.java12 Nov 2004 10:51:49 -  1.23
  +++ ByteChunk.java15 Dec 2004 11:49:20 -  1.24
  @@ -478,11 +478,11 @@
// Method is commented out, in:
 return B2CConverter.decodeString( enc );
 */
  -} catch (java.io.IOException e) {
  -// FIXME 
  +} catch (java.io.UnsupportedEncodingException e) {
  +// Use the platform encoding in that case; the usage of a bad
  +// encoding will have been logged elsewhere already
  +strValue = new String(buff, start, end-start);
   }
  -//System.out.println(BC toString:  + strValue);
  -//Thread.dumpStack();
   return strValue;
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java

2004-03-08 Thread remm
remm2004/03/08 15:46:37

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
CharChunk.java
  Log:
  - The optimized write (direct writing when data appended is the size of the
buffer and the buffer is empty) works good when we would want to overflow
only when the data is actually bigger than the buffer.
  - Add flag to allow disabling this.
  
  Revision  ChangesPath
  1.19  +6 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ByteChunk.java5 Mar 2004 13:06:13 -   1.18
  +++ ByteChunk.java8 Mar 2004 23:46:37 -   1.19
  @@ -92,6 +92,7 @@
   private ByteOutputChannel out = null;
   
   private boolean isOutput=false;
  +private boolean optimizedWrite=true;
   
   /**
* Creates a new, uninitialized ByteChunk object.
  @@ -158,6 +159,10 @@
isSet=true;
   }
   
  +public void setOptimizedWrite(boolean optimizedWrite) {
  +this.optimizedWrite = optimizedWrite;
  +}
  +
   public void setEncoding( String enc ) {
this.enc=enc;
   }
  @@ -285,7 +290,7 @@
   // If the buffer is empty and the source is going to fill up all the
   // space in buffer, may as well write it directly to the output,
   // and avoid an extra copy
  -if ( len == limit  end == start) {
  +if ( optimizedWrite  len == limit  end == start) {
   out.realWriteBytes( src, off, len );
   return;
   }
  
  
  
  1.13  +7 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java
  
  Index: CharChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CharChunk.java5 Mar 2004 13:08:00 -   1.12
  +++ CharChunk.java8 Mar 2004 23:46:37 -   1.13
  @@ -72,6 +72,8 @@
   private CharInputChannel in = null;
   private CharOutputChannel out = null;
   
  +private boolean optimizedWrite=true;
  +
   /**
* Creates a new, uninitialized CharChunk object.
*/
  @@ -126,6 +128,10 @@
   }
   
   
  +public void setOptimizedWrite(boolean optimizedWrite) {
  +this.optimizedWrite = optimizedWrite;
  +}
  +
   public void setChars( char[] c, int off, int len ) {
recycle();
isSet=true;
  @@ -251,7 +257,7 @@
   // Optimize on a common case.
   // If the source is going to fill up all the space in buffer, may
   // as well write it directly to the output, and avoid an extra copy
  -if ( len == limit  end == start) {
  +if ( optimizedWrite  len == limit  end == start) {
   out.realWriteChars( src, off, len );
   return;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2004-03-05 Thread remm
remm2004/03/05 05:06:13

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  - In makeSpace, we should compare the desiredSpace to the limit, so that
we actually allow enough. Otherwise, the amount would be slower, violating
the makeSpace assertion.
  - This doesn't fix anything for ByteChunk as AFAIK start is (almost ?) always 0
for growable buffers.
  
  Revision  ChangesPath
  1.18  +2 -2  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ByteChunk.java24 Feb 2004 08:50:06 -  1.17
  +++ ByteChunk.java5 Mar 2004 13:06:13 -   1.18
  @@ -406,8 +406,8 @@
   
// Can't grow above the limit
if( limit  0 
  - desiredSize  limit -start  ) {
  - desiredSize=limit -start;
  + desiredSize  limit) {
  + desiredSize=limit;
}
   
if( buff==null ) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2003-12-05 Thread larryi
larryi  2003/12/05 16:50:08

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  Port optimization from CharChunk to prevent needless allocation of byte
  arrays.
  
  Revision  ChangesPath
  1.16  +9 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ByteChunk.java12 Sep 2003 12:58:53 -  1.15
  +++ ByteChunk.java6 Dec 2003 00:50:08 -   1.16
  @@ -324,6 +324,14 @@
return;
}
   
  +// Optimize on a common case.
  +// If the buffer is empty and the source is going to fill up all the
  +// space in buffer, may as well write it directly to the output,
  +// and avoid an extra copy
  +if ( len == limit  end == start) {
  +out.realWriteBytes( src, off, len );
  +return;
  +}
// if we have limit and we're below
if( len = limit - end ) {
// makeSpace will grow the buffer to the limit,
  @@ -452,7 +460,7 @@

// limit  buf.length ( the buffer is already big )
// or we already have space XXX
  - if( desiredSize  buff.length ) {
  + if( desiredSize = buff.length ) {
return;
}
// grow in larger chunks
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2003-09-12 Thread remm
remm2003/09/12 05:58:53

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  - Refactor byte chunk buffering so that the written data fits inside the limit.
The number of byte copies is similar to what it was before.
  
  Revision  ChangesPath
  1.15  +19 -28
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ByteChunk.java2 Sep 2003 21:34:38 -   1.14
  +++ ByteChunk.java12 Sep 2003 12:58:53 -  1.15
  @@ -338,34 +338,25 @@
   
// 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
  - // copy the first part, flush, then copy the second part - 1 write
  - // and still have some space for more. We'll still have 2 writes, but
  - // we write more on the first.
  -
  - if( len + end  2 * limit ) {
  - /* If the request length exceeds the size of the output buffer,
  -flush the output buffer and then write the data directly.
  -We can't avoid 2 writes, but we can write more on the second
  - */
  - 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
  - flushBuffer();
  - 
  - out.realWriteBytes( src, off, len );
  - }
  +// We chunk the data into slices fitting in the buffer limit, although
  +// if the data is written directly if it doesn't fit
  +
  +int avail=limit-end;
  +System.arraycopy(src, off, buff, end, avail);
  +end += avail;
  +
  +flushBuffer();
  +
  +int remain = len - avail;
  +
  +while (remain  (limit - end)) {
  +out.realWriteBytes( src, (off + len) - remain, limit - end );
  +remain = remain - (limit - end);
  +}
  +
  +System.arraycopy(src, (off + len) - remain, buff, end, remain);
  +end += remain;
  +
   }
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java

2003-01-14 Thread remm
remm2003/01/14 10:20:02

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
CharChunk.java
  Log:
  - Add alternate substract methods.
  
  Revision  ChangesPath
  1.13  +22 -0 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ByteChunk.java5 Jan 2003 11:22:16 -   1.12
  +++ ByteChunk.java14 Jan 2003 18:20:02 -  1.13
  @@ -377,6 +377,8 @@
   throws IOException {
   
   if ((end - start) == 0) {
  +if (in == null)
  +return -1;
   int n = in.realReadBytes( buff, 0, buff.length );
   if (n  0)
   return -1;
  @@ -386,10 +388,30 @@
   
   }
   
  +public int substract(ByteChunk src)
  +throws IOException {
  +
  +if ((end - start) == 0) {
  +if (in == null)
  +return -1;
  +int n = in.realReadBytes( buff, 0, buff.length );
  +if (n  0)
  +return -1;
  +}
  +
  +int len = getLength();
  +src.append(buff, start, len);
  +start = end;
  +return len;
  +
  +}
  +
   public int substract( byte src[], int off, int len )
   throws IOException {
   
   if ((end - start) == 0) {
  +if (in == null)
  +return -1;
   int n = in.realReadBytes( buff, 0, buff.length );
   if (n  0)
   return -1;
  
  
  
  1.6   +22 -0 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java
  
  Index: CharChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CharChunk.java5 Jan 2003 11:22:16 -   1.5
  +++ CharChunk.java14 Jan 2003 18:20:02 -  1.6
  @@ -403,6 +403,8 @@
   throws IOException {
   
   if ((end - start) == 0) {
  +if (in == null)
  +return -1;
   int n = in.realReadChars(buff, 0, buff.length);
   if (n  0)
   return -1;
  @@ -412,10 +414,30 @@
   
   }
   
  +public int substract(CharChunk src)
  +throws IOException {
  +
  +if ((end - start) == 0) {
  +if (in == null)
  +return -1;
  +int n = in.realReadChars( buff, 0, buff.length );
  +if (n  0)
  +return -1;
  +}
  +
  +int len = getLength();
  +src.append(buff, start, len);
  +start = end;
  +return len;
  +
  +}
  +
   public int substract( char src[], int off, int len )
   throws IOException {
   
   if ((end - start) == 0) {
  +if (in == null)
  +return -1;
   int n = in.realReadChars( buff, 0, buff.length );
   if (n  0)
   return -1;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java

2003-01-05 Thread remm
remm2003/01/05 03:22:16

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
CharChunk.java
  Log:
  - Add input support to ByteChunk and CharChunk.
  - I don't know if the new method names are well chosen.
  
  Revision  ChangesPath
  1.12  +65 -8 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ByteChunk.java23 Apr 2002 20:07:57 -  1.11
  +++ ByteChunk.java5 Jan 2003 11:22:16 -   1.12
  @@ -85,18 +85,31 @@
*
* The buffer can be modified and used for both input and output.
*
  - * @author [EMAIL PROTECTED]
  - * @author James Todd [[EMAIL PROTECTED]]
  + * @author [EMAIL PROTECTED]
  + * @author James Todd [[EMAIL PROTECTED]]
* @author Costin Manolache
  + * @author Remy Maucherat
*/
   public final class ByteChunk implements Cloneable, Serializable {
  +
  +// Input interface, used when the buffer is emptied.
  +public static interface ByteInputChannel {
  +/** 
  + * Read new bytes ( usually the internal conversion buffer ).
  + * The implementation is allowed to ignore the parameters, 
  + * and mutate the chunk if it wishes to implement its own buffering.
  + */
  +public int realReadBytes(byte cbuf[], int off, int len)
  +throws IOException;
  +}
   // Output interface, used when the buffer is filled.
   public static interface ByteOutputChannel {
  - /** Send the bytes ( usually the internal conversion buffer ).
  -  *  Expect 8k output if the buffer is full.
  -  */
  - public void realWriteBytes( byte cbuf[], int off, int len)
  - throws IOException;
  +/** 
  + * Send the bytes ( usually the internal conversion buffer ).
  + * Expect 8k output if the buffer is full.
  + */
  +public void realWriteBytes(byte cbuf[], int off, int len)
  +throws IOException;
   }
   
   // 
  @@ -120,7 +133,8 @@
   // How much can it grow, when data is added
   private int limit=-1;
   
  -private ByteOutputChannel out=null;
  +private ByteInputChannel in = null;
  +private ByteOutputChannel out = null;
   
   private boolean isOutput=false;
   
  @@ -247,6 +261,13 @@
return limit;
   }
   
  +/**
  + * When the buffer is empty, read the data from the input channel.
  + */
  +public void setByteInputChannel(ByteInputChannel in) {
  +this.in = in;
  +}
  +
   /** When the buffer is full, write the data to the output channel.
*   Also used when large amount of data is appended.
*
  @@ -348,6 +369,42 @@
out.realWriteBytes( src, off, len );
}
   }
  +
  +
  +//  Removing data from the buffer 
  +
  +public int substract()
  +throws IOException {
  +
  +if ((end - start) == 0) {
  +int n = in.realReadBytes( buff, 0, buff.length );
  +if (n  0)
  +return -1;
  +}
  +
  +return (buff[start++]  0xFF);
  +
  +}
  +
  +public int substract( byte src[], int off, int len )
  +throws IOException {
  +
  +if ((end - start) == 0) {
  +int n = in.realReadBytes( buff, 0, buff.length );
  +if (n  0)
  +return -1;
  +}
  +
  +int n = len;
  +if (len  getLength()) {
  +n = getLength();
  +}
  +System.arraycopy(buff, start, src, off, n);
  +start += n;
  +return n;
  +
  +}
  +
   
   public void flushBuffer()
throws IOException
  
  
  
  1.5   +60 -5 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java
  
  Index: CharChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CharChunk.java16 Mar 2002 06:49:15 -  1.4
  +++ CharChunk.java5 Jan 2003 11:22:16 -   1.5
  @@ -70,11 +70,23 @@
* it is known to not be the most efficient solution - Strings are
* designed as imutable and secure objects.
* 
  - * @author [EMAIL PROTECTED]
  - * @author James Todd [[EMAIL PROTECTED]]
  + * @author [EMAIL PROTECTED]
  + * @author James Todd [[EMAIL PROTECTED]]
* @author Costin Manolache
  + * @author Remy Maucherat
*/
   public final class CharChunk implements Cloneable, Serializable {
  +
  +// 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2002-03-15 Thread remm

remm02/03/15 21:34:57

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  - Fix an off-by-one bug: if the requested string was the last bytes in the chunk,
it wouldn't be found.
  
  Revision  ChangesPath
  1.8   +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ByteChunk.java15 Mar 2002 05:28:35 -  1.7
  +++ ByteChunk.java16 Mar 2002 05:34:57 -  1.8
  @@ -574,7 +574,7 @@
// Look for first char 
int srcEnd = srcOff + srcLen;
   
  - for( int i=myOff+start; i end - srcLen ; i++ ) {
  + for( int i=myOff+start; i = (end - srcLen); i++ ) {
if( buff[i] != first ) continue;
// found first char, now look for a match
   int myPos=i+1;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2002-03-15 Thread billbarker

billbarker02/03/15 22:37:46

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  When looking at Remy's change, this caught my eye.
  
  If I'm doing something really stupid here, please -1.  util/buf is not one of the 
packages I've studied a lot.
  
  Revision  ChangesPath
  1.9   +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ByteChunk.java16 Mar 2002 05:34:57 -  1.8
  +++ ByteChunk.java16 Mar 2002 06:37:46 -  1.9
  @@ -403,8 +403,8 @@
System.arraycopy(buff, start, tmp, 0, end-start);
buff = tmp;
tmp = null;
  - start=0;
end=end-start;
  + start=0;
   }
   
   //  Conversion and getters 
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2002-03-15 Thread Bill Barker

Just checked in to 3.3.
- Original Message -
From: [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, March 15, 2002 11:03 PM
Subject: Re: cvs commit:
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf
ByteChunk.java


 On 16 Mar 2002 [EMAIL PROTECTED] wrote:

  billbarker02/03/15 22:37:46
 
Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
Log:
When looking at Remy's change, this caught my eye.
 
If I'm doing something really stupid here, please -1.  util/buf is not
one of the packages I've studied a lot.

 Just please make sure you keep the 3.3 in sync. I hope soon we'll not have
 to do that and use a single copy.

 ( good catch ! )

 Costin


 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java

2002-03-14 Thread remm

remm02/03/14 21:28:35

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  - Made the offsets relative to the start of the chunk (instead of relative to the
start of the internal byte buffer). This looks more consistent with the other 
indexOf.
  - Also fix an off-by-one but in the matching algorithm.
  - If this patch is not ok, let me know.
  
  Revision  ChangesPath
  1.7   +7 -7  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ByteChunk.java7 Feb 2002 05:37:35 -   1.6
  +++ ByteChunk.java15 Mar 2002 05:28:35 -  1.7
  @@ -572,16 +572,16 @@
char first=src.charAt( srcOff );
   
// Look for first char 
  - int srcEnd=srcOff + srcLen;
  - 
  - for( int i=myOff; i end - srcLen ; i++ ) {
  + int srcEnd = srcOff + srcLen;
  +
  + for( int i=myOff+start; i end - srcLen ; i++ ) {
if( buff[i] != first ) continue;
// found first char, now look for a match
  - int myPos=i+1;
  - for( int srcPos=srcOff; srcPos srcEnd; ) {
  - if( buff[myPos++] != src.charAt( srcPos++ ))
  +int myPos=i+1;
  + for( int srcPos=srcOff + 1; srcPos srcEnd; ) {
  +if( buff[myPos++] != src.charAt( srcPos++ ))
break;
  - if( srcPos==srcEnd ) return i; // found it
  +if( srcPos==srcEnd ) return i-start; // found it
}
}
return -1;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java

2002-02-06 Thread keith

keith   02/02/06 21:37:35

  Modified:util/java/org/apache/tomcat/util/buf ByteChunk.java
CharChunk.java
  Log:
  indexOf should return an index relative to the internal
  starting point of the string rather than the beginning
  of the array.  Ported over from main j-t repository.
  
  Revision  ChangesPath
  1.6   +2 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ByteChunk.java31 Dec 2001 18:20:04 -  1.5
  +++ ByteChunk.java7 Feb 2002 05:37:35 -   1.6
  @@ -626,7 +626,8 @@
* @param s the string
*/
   public int indexOf(char c, int starting) {
  - return indexOf( buff, start+starting, end, c);
  + int ret = indexOf( buff, start+starting, end, c);
  + return (ret = start) ? ret - start : -1;
   }
   
   public static int  indexOf( byte bytes[], int off, int end, char qq )
  
  
  
  1.3   +2 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java
  
  Index: CharChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/CharChunk.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CharChunk.java29 May 2001 06:22:53 -  1.2
  +++ CharChunk.java7 Feb 2002 05:37:35 -   1.3
  @@ -597,7 +597,8 @@
* @param s the string
*/
   public int indexOf(char c, int starting) {
  - return indexOf( buff, start+starting, end, c );
  + int ret = indexOf( buff, start+starting, end, c );
  + return (ret = start) ? ret - start : -1;
   }
   
   public static int indexOf( char chars[], int off, int cend, char qq )
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]