patches to slove an OutputStreamWriter problem
ito at htk.hitachi-cable.co.jp
ito at htk.hitachi-cable.co.jp
Sun May 14 17:43:01 PDT 2000
In message "patches to slove an OutputStreamWriter problem"
on 00/05/14, Ito Kazumitsu <ito at maczuka.gcd.org> writes:
> So I prepared a method "convertALAP" (convert as long as possible)
> in CharToByteConverter, which may not necessarily convert the
> whole input specified by fpos and flen, but tries to convert
> the input as long as possible, and returns not only the output
> length but also the input length actually processed.
I made another patch to OutputStreamWriter.java without
introducing such a new method.
Just using encoding.flush will solve the problem.
*** java/io/OutputStreamWriter.java.orig Fri Aug 13 10:56:01 1999
--- java/io/OutputStreamWriter.java Mon May 15 09:25:43 2000
***************
*** 74,88 ****
}
synchronized (lock) {
! while (len > 0) {
int outlen = encoding.convert(cbuf, off, len,
outbuf, buflen, outbuf.length - buflen);
! buflen += outlen;
! if (outlen == 0 || outbuf.length - buflen < MINMARGIN) {
flush();
}
- off += outlen;
- len -= outlen;
}
}
}
--- 74,93 ----
}
synchronized (lock) {
! if (len > 0) {
int outlen = encoding.convert(cbuf, off, len,
outbuf, buflen, outbuf.length - buflen);
! if (outlen == 0) {
flush();
+ outlen = encoding.flush(outbuf, buflen, outbuf.length - buflen);
+ }
+ while (outlen > 0) {
+ buflen += outlen;
+ if (outbuf.length - buflen < MINMARGIN) {
+ flush();
+ }
+ outlen = encoding.flush(outbuf, buflen, outbuf.length - buflen);
}
}
}
}
More information about the kaffe
mailing list