Author: markt
Date: Mon Mar 4 13:24:24 2013
New Revision: 1452294
URL: http://svn.apache.org/r1452294
Log:
Review current code with respect to original Harmony code.
- Revert a couple of incorrect changes made along the way.
- Fix formatting for cleaner diff
- Adjust comments ready for wider use
Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java?rev=1452294&r1=1452293&r2=1452294&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java Mon Mar 4
13:24:24 2013
@@ -98,15 +98,14 @@ public class Utf8Decoder extends Charset
}
if (limit - pos < 1 + tail) {
// No early test for invalid sequences here as peeking
- // at the next byte is harder (and Tomcat's WebSocket
- // implementation always uses array backed buffers)
+ // at the next byte is harder
return CoderResult.UNDERFLOW;
}
int nextByte;
for (int i = 0; i < tail; i++) {
nextByte = in.get() & 0xFF;
if ((nextByte & 0xC0) != 0x80) {
- return CoderResult.malformedForLength(1);
+ return CoderResult.malformedForLength(1 + i);
}
jchar = (jchar << 6) + nextByte;
}
@@ -252,7 +251,7 @@ public class Utf8Decoder extends Charset
if ((nextByte & 0xC0) != 0x80) {
in.position(inIndex - in.arrayOffset());
out.position(outIndex - out.arrayOffset());
- return CoderResult.malformedForLength(1);
+ return CoderResult.malformedForLength(1 + i);
}
jchar = (jchar << 6) + nextByte;
}
@@ -287,7 +286,8 @@ public class Utf8Decoder extends Charset
}
in.position(inIndex - in.arrayOffset());
out.position(outIndex - out.arrayOffset());
- return (outRemaining == 0 && inIndex < inIndexLimit) ?
CoderResult.OVERFLOW
- : CoderResult.UNDERFLOW;
+ return (outRemaining == 0 && inIndex < inIndexLimit) ?
+ CoderResult.OVERFLOW :
+ CoderResult.UNDERFLOW;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]