Author: markt Date: Mon May 17 07:51:31 2010 New Revision: 945007 URL: http://svn.apache.org/viewvc?rev=945007&view=rev Log: Revert r944918
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java?rev=945007&r1=945006&r2=945007&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java Mon May 17 07:51:31 2010 @@ -64,8 +64,6 @@ import java.io.Serializable; */ public final class ByteChunk implements Cloneable, Serializable { - private static final long serialVersionUID = 1L; - /** Input interface, used when the buffer is empty * * Same as java.nio.channel.ReadableByteChannel @@ -121,7 +119,6 @@ public final class ByteChunk implements * Creates a new, uninitialized ByteChunk object. */ public ByteChunk() { - // NO-OP } public ByteChunk( int initial ) { @@ -738,29 +735,30 @@ public final class ByteChunk implements * @param starting The start position */ public int indexOf(char c, int starting) { - int ret = indexOf(buff, start+starting, end, c); + int ret = indexOf( buff, start+starting, end, c); return (ret >= start) ? ret - start : -1; } - /** - * Find a character, no side effects. Only works for single-byte character - * sets. - * @return index of char if found, -1 if not - */ - public static int indexOf(byte bytes[], int start, int end, char c) { - return findChar(bytes, start, end, c); + public static int indexOf( byte bytes[], int off, int end, char qq ) + { + // Works only for UTF + while( off < end ) { + byte b=bytes[off]; + if( b==qq ) + return off; + off++; + } + return -1; } - /** - * Find a character, no side effects. Only works for single-byte character - * sets. - * @return index of char if found, -1 if not + /** Find a character, no side effects. + * @return index of char if found, -1 if not */ - public static int findChar( byte buf[], int start, int end, char c) { - // Works only for single byte character sets + public static int findChar( byte buf[], int start, int end, char c ) { + byte b=(byte)c; int offset = start; while (offset < end) { - if (buf[offset] == c) { + if (buf[offset] == b) { return offset; } offset++; @@ -768,10 +766,8 @@ public final class ByteChunk implements return -1; } - /** - * Find any one of an array of characters. No side effects. Only works for - * single-byte character sets. - * @return index of char if found, -1 if not + /** Find a character, no side effects. + * @return index of char if found, -1 if not */ public static int findChars( byte buf[], int start, int end, byte c[] ) { int clen=c.length; @@ -786,15 +782,15 @@ public final class ByteChunk implements return -1; } - /** - * Find the first character not in an array of characters. No side effects. - * Only works for single-byte character sets. - * @return index of char if found, -1 if not + /** Find the first character != c + * @return index of char if found, -1 if not */ - public static int findNotChars(byte buf[], int start, int end, byte c[]) { + public static int findNotChars( byte buf[], int start, int end, byte c[] ) + { int clen=c.length; int offset = start; boolean found; + while (offset < end) { found=true; for( int i=0; i<clen; i++ ) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org