2010/5/17 Mark Thomas <ma...@apache.org>: > On 17/05/2010 00:03, Konstantin Kolinko wrote: >> 2010/5/17 <ma...@apache.org>: >>> Author: markt >>> Date: Sun May 16 21:31:57 2010 >>> New Revision: 944918 >>> >>> URL: http://svn.apache.org/viewvc?rev=944918&view=rev >>> Log: >>> Code clean-up >>> >>> Modified: >>> tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java >>> >> >>> + public static int indexOf(byte bytes[], int start, int end, char c) { >>> + return findChar(bytes, start, end, c); >>> } >> >> There is a difference in behaviour between ByteChunk#indexOf(..) and >> ByteChunk#findChar(..) how they were implemented before this change. >> >> indexOf() relied on (byte == char) comparison, which performs widening. >> findChar() does byte b=(byte)c; and compares bytes. >> >> The difference is that indexOf() can find ASCII (0-127) characters >> only, while findChar() can find any ISO-8859-1 char. > > Thanks for the catch. I'll restore the original behaviour and add some > comments to make this clearer. >
findChar() was the "correct" implementation. It is indexOf() that is 0-127. Thus the comments in r945014 and subsequent r945016 are wrong. byte is signed. Widening byte -> char preserves the sign, thus comparing (byte == char) does not work for the upper part of ISO-8859-1. Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org