Re: java.io.OutputStreamWriter: too small buffer

2000-03-01 Thread ito


In message "Re: java.io.OutputStreamWriter: too small buffer"
on 00/03/01, "Edouard G. Parmelan" <[EMAIL PROTECTED]> writes:

> Could you try the following more general patch ?

This patch worked fine. Tank you.



Re: java.io.OutputStreamWriter: too small buffer

2000-03-01 Thread Edouard G. Parmelan

[EMAIL PROTECTED] wrote:

> The output buffer of java.io.OutputStreamWriter is too small to
> safely run XT, the XSLT processor.  The following error occurs
> when processing a XML document containing Japanese characters:
> 
> And enlarging the buffer, that is, applying the following
> patch to OutputStreamWriter.java helps solve this problem
> although this is nothing but a workaround.

Could you try the following more general patch ?
-- 
Edouard G. Parmelan
http://egp.free.fr


Index: libraries/javalib/kaffe/io/CharToByteUTF8.java
===
RCS file: /cvs/kaffe/kaffe/libraries/javalib/kaffe/io/CharToByteUTF8.java,v
retrieving revision 1.1
diff -u -r1.1 CharToByteUTF8.java
--- libraries/javalib/kaffe/io/CharToByteUTF8.java  1999/10/09 20:10:10 1.1
+++ libraries/javalib/kaffe/io/CharToByteUTF8.java  2000/03/01 10:38:42
@@ -21,16 +21,25 @@
int i = fpos;
int ie = fpos + flen;
 
-   for (; i < ie && o < oe; i++) {
+   for (; i < ie; i++) {
 char chr = from[i];
 if (chr >= '\u0001' && chr <= '\u007F') {
+   if (o >= oe) {
+   break;
+   }
to[o++] = (byte)chr;
}
 else if (chr <= '\u07FF') {
+   if (o + 1 >= oe) {
+   break;
+   }
 to[o++] = (byte)(0xC0 | (0x3F & (chr >> 6)));
 to[o++] = (byte)(0x80 | (0x3F & chr));
 }
 else {
+   if (o + 2 >= oe) {
+   break;
+   }
 to[o++] = (byte)(0xE0 | (0x0F & (chr >> 12)));
 to[o++] = (byte)(0x80 | (0x3F & (chr >>  6)));
 to[o++] = (byte)(0x80 | (0x3F & chr));



java.io.OutputStreamWriter: too small buffer

2000-02-29 Thread ito


I posted this bug report through http://www.kaffe.org/cgi-bin/kaffe,
but it did not reach [EMAIL PROTECTED]
because kaffe.novare.net said "550 <[EMAIL PROTECTED]>
... Relaying denied."

I do not know whether this report was accepted by
the Kaffe Bug Tracking System, so I would like to send it to
this mailing list again.

From: [EMAIL PROTECTED]
Date: Tue, 29 Feb 2000 03:05:11 -0600
Message-Id: <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: java.io.OutputStreamWriter: too small buffer

Full_Name: Ito Kazumitsu
Version: kaffe-1.0.5 (snap)
OS: Linux 2.0.38
Submission from: (NULL) (210.225.95.3)


The output buffer of java.io.OutputStreamWriter is too small to
safely run XT, the XSLT processor.  The following error occurs
when processing a XML document containing Japanese characters:

## o = 1017 ## oe = 1024## o = 1020 ## oe = 1024## o = 1023
## oe = 1024java.lang.ArrayIndexOutOfBoundsException
at kaffe.io.CharToByteUTF8.convert(CharToByteUTF8.java:37)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:79)
at com.jclark.xsl.sax.HTMLOutputHandler.flushBuf(HTMLOutputHandler.java:721)
at com.jclark.xsl.sax.HTMLOutputHandler.endDocument(HTMLOutputHandler.java:732)
at com.jclark.xsl.sax.ResultBase.end(ResultBase.java:line unknown, pc
0x8390dc5)
at com.jclark.xsl.tr.SheetImpl.process(SheetImpl.java:line unknown, pc
0x83dccc7)
at com.jclark.xsl.sax.XSLProcessorImpl.parse(XSLProcessorImpl.java:line
unknown, pc 0x8394bc4)
at com.jclark.xsl.sax.Driver.transform(Driver.java:line unknown, pc
0x81f8c60)
at com.jclark.xsl.sax.Driver.transformFile(Driver.java:line unknown, pc
0x81f5517)
at com.jclark.xsl.sax.Driver.main(Driver.java:line unknown, pc
0x81e54c3)

where CharToByteUTF8.java is patched for debugging as follows:

==
$ diff -c ~/kaffe/kaffe-snap/libraries/javalib/kaffe/io/CharToByteUTF8.java
kaffe/io/CharToByteUTF8.java
*** /home/ito/kaffe/kaffe-snap/libraries/javalib/kaffe/io/CharToByteUTF8.java 
Sun Oct 10 05:09:48 1999
--- kaffe/io/CharToByteUTF8.javaTue Feb 29 17:13:37 2000
***
*** 22,27 
--- 22,29 
int ie = fpos + flen;

for (; i < ie && o < oe; i++) {
+   System.err.print("## o = " + o +"\t");
+   System.err.print("## oe = " + oe + "\t");
  char chr = from[i];
  if (chr >= '\u0001' && chr <= '\u007F') {
to[o++] = (byte)chr;
==

And enlarging the buffer, that is, applying the following
patch to OutputStreamWriter.java helps solve this problem
although this is nothing but a workaround.

==
diff -c ~/kaffe/kaffe-snap/libraries/javalib/java/io/OutputStreamWriter.java
java/io/OutputStreamWriter.java
*** /home/ito/kaffe/kaffe-snap/libraries/javalib/java/io/OutputStreamWriter.javFri
Aug 13 10:56:01 1999
--- java/io/OutputStreamWriter.java Tue Feb 29 17:58:37 2000
***
*** 15,21 
  public class OutputStreamWriter
extends Writer
  {
!   private final static int BUFDEFAULT = 1024;
private final static int MINMARGIN = 32;
private OutputStream strm;
private CharToByteConverter encoding;
--- 15,22 
  public class OutputStreamWriter
extends Writer
  {
!   //private final static int BUFDEFAULT = 1024;
!   private final static int BUFDEFAULT = 8*1024;
private final static int MINMARGIN = 32;
private OutputStream strm;
private CharToByteConverter encoding;
==