From c2bb29a301cedaee218b989f74601d04ca7e4076 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 17 May 2010 11:33:01 +0000 Subject: [PATCH] More clean-up: - findCharXXX to findByteXXX - whitespace - make code consistent where possible git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@945095 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/connector/CoyoteAdapter.java | 2 +- java/org/apache/tomcat/util/buf/ByteChunk.java | 84 +++++++++++----------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java index c86cf8816..29b39ac62 100644 --- a/java/org/apache/catalina/connector/CoyoteAdapter.java +++ b/java/org/apache/catalina/connector/CoyoteAdapter.java @@ -663,7 +663,7 @@ public class CoyoteAdapter implements Adapter { int end = uriBC.getEnd(); int pathParamStart = semicolon + 1; - int pathParamEnd = ByteChunk.findChars(uriBC.getBuffer(), + int pathParamEnd = ByteChunk.findBytes(uriBC.getBuffer(), uriBC.getStart() + pathParamStart, uriBC.getEnd(), new byte[] {';', '/'}); diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java index 414829e34..a4fd986e4 100644 --- a/java/org/apache/tomcat/util/buf/ByteChunk.java +++ b/java/org/apache/tomcat/util/buf/ByteChunk.java @@ -745,7 +745,7 @@ public final class ByteChunk implements Cloneable, Serializable { * -1 if the character is not found. */ 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; } @@ -763,53 +763,56 @@ public final class ByteChunk implements Cloneable, Serializable { * if the character is not found. */ public static int indexOf(byte bytes[], int start, int end, char c) { - int i = start; + int offset = start; - while (i < end) { - byte b=bytes[i]; - if (b==c) - return i; - i++; + while (offset < end) { + byte b=bytes[offset]; + if (b == c) + return offset; + offset++; } return -1; } /** - * Returns the first instance of the given character in the given byte array - * between the specified start and end. - *
- * NOTE: This only works for characters in the range 0-127. + * Returns the first instance of the given byte in the byte array between + * the specified start and end. * * @param bytes The byte array to search * @param start The point to start searching from in the byte array * @param end The point to stop searching in the byte array - * @param c The character to search for - * @return The position of the first instance of the character or -1 - * if the character is not found. + * @param b The byte to search for + * @return The position of the first instance of the byte or -1 if the + * byte is not found. */ - public static int findChar(byte bytes[], int start, int end, char c) { - return indexOf(bytes, start, end, c); + public static int findByte(byte bytes[], int start, int end, byte b) { + int offset = start; + while (offset < end) { + if (bytes[offset] == b) { + return offset; + } + offset++; + } + return -1; } /** - * Returns the first instance of any of the given characters in the given - * byte array between the specified start and end. - *
- * NOTE: This only works for characters in the range 0-127. + * Returns the first instance of any of the given bytes in the byte array + * between the specified start and end. * * @param bytes The byte array to search * @param start The point to start searching from in the byte array * @param end The point to stop searching in the byte array - * @param c The array of characters to search for - * @return The position of the first instance of the character or -1 - * if the character is not found. + * @param b The array of bytes to search for + * @return The position of the first instance of the byte or -1 if the + * byte is not found. */ - public static int findChars(byte bytes[], int start, int end, byte c[]) { - int clen=c.length; + public static int findBytes(byte bytes[], int start, int end, byte b[]) { + int blen = b.length; int offset = start; while (offset < end) { - for (int i=0; i - * NOTE: This only works for characters in the range 0-127. + * Returns the first instance of any byte that is not one of the given bytes + * in the byte array between the specified start and end. * * @param bytes The byte array to search * @param start The point to start searching from in the byte array * @param end The point to stop searching in the byte array - * @param c The array of characters to search for - * @return The position of the first instance a character that is not - * in the specified start array or -1 if the character is - * not found. + * @param c The list of bytes to search for + * @return The position of the first instance a byte that is not + * in the list of bytes to search for or -1 if no such byte + * is found. */ - public static int findNotChars(byte bytes[], int start, int end, byte c[]) { - int clen=c.length; + public static int findNotBytes(byte bytes[], int start, int end, byte b[]) { + int blen = b.length; int offset = start; boolean found; while (offset < end) { - found=true; - for (int i=0; i