tcurdt 02/01/18 11:16:49
Modified: src/java/org/apache/cocoon/components/sax
XMLByteStreamInterpreter.java
Log:
removed while(true) waiting for the endDocument event
fixed a wrong buffer length check (>/>= comparison)
Revision Changes Path
1.2 +16 -9
xml-cocoon2/src/java/org/apache/cocoon/components/sax/XMLByteStreamInterpreter.java
Index: XMLByteStreamInterpreter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/sax/XMLByteStreamInterpreter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLByteStreamInterpreter.java 3 Jan 2002 12:31:13 -0000 1.1
+++ XMLByteStreamInterpreter.java 18 Jan 2002 19:16:48 -0000 1.2
@@ -20,7 +20,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:13 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/01/18 19:16:48 $
*/
public final class XMLByteStreamInterpreter
@@ -41,7 +41,7 @@
private ArrayList list = new ArrayList();
private byte[] input;
- private int currentPos;
+ private int currentPos;
public void recycle() {
super.recycle();
@@ -60,14 +60,14 @@
}
private void parse() throws SAXException {
- while (true) {
+ while ( currentPos < input.length) {
switch (this.readEvent()) {
case START_DOCUMENT:
contentHandler.startDocument();
break;
case END_DOCUMENT:
contentHandler.endDocument();
- return;
+ break;
case START_PREFIX_MAPPING:
contentHandler.startPrefixMapping(this.readString(),
this.readString());
break;
@@ -110,12 +110,12 @@
break;
case LOCATOR:
{
- String publidId = this.readString();
+ String publicId = this.readString();
String systemId = this.readString();
int lineNumber = this.read();
int columnNumber = this.read();
org.xml.sax.helpers.LocatorImpl locator = new
org.xml.sax.helpers.LocatorImpl();
- locator.setPublicId(publidId);
+ locator.setPublicId(publicId);
locator.setSystemId(systemId);
locator.setLineNumber(lineNumber);
locator.setColumnNumber(columnNumber);
@@ -139,7 +139,7 @@
if (valid != 6) throw new SAXException("Unrecognized file format.");
}
- private int readEvent() throws SAXException {
+ protected int readEvent() throws SAXException {
return this.read();
}
@@ -230,7 +230,15 @@
private void readBytes(byte[] b)
throws SAXException {
- if (this.currentPos + b.length >= this.input.length) {
+ if (this.currentPos + b.length > this.input.length) {
+ // TC:
+ // >= prevents getting the last byte
+ // 0 1 2 3 4 input.length = 5
+ // |_ currentPos = 2
+ // b.length = 3
+ // 2 + 3 > 5 ok
+ // 2 + 3 >= 5 wrong
+ // why has this worked before?
throw new SAXException("End of input reached.");
}
System.arraycopy(this.input, this.currentPos, b, 0, b.length);
@@ -242,5 +250,4 @@
int ch2 = this.read();
return ((ch1 << 8) + (ch2 << 0));
}
-
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]