remm 02/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 Changes Path
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.java 7 Feb 2002 05:37:35 -0000 1.6
+++ ByteChunk.java 15 Mar 2002 05:28:35 -0000 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]>