This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: Patch: iconv()-based encoding and decoding
- To: tromey at cygnus dot com
- Subject: Re: Patch: iconv()-based encoding and decoding
- From: Anthony Green <green at cygnus dot com>
- Date: Mon, 31 Jan 2000 00:50:39 -0800
- CC: java-patches at sourceware dot cygnus dot com
- References: <87snzeu9nn.fsf@cygnus.com>
- Reply-to: green at redhat dot com
Tom wrote:
> I'm committing the appended patch. It changes libgcj to use iconv()
> as a fallback when looking for character set encoders. This code
> hasn't yet been tested, because for some reason (that I have yet to
> investigate) my system doesn't have iconv() in libc.
I'm committing these fixes which are needed in order to compile
natIconv.cc. I don't know if they are correct, but it builds now.
Mon Jan 31 00:43:15 2000 Anthony Green <green@cygnus.com>
* gnu/gcj/convert/natIconv.cc (read): Minor fixes.
(write): Ditto.
Index: natIconv.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/gnu/gcj/convert/natIconv.cc,v
retrieving revision 1.1
diff -u -p -u -r1.1 natIconv.cc
--- natIconv.cc 2000/01/31 04:53:47 1.1
+++ natIconv.cc 2000/01/31 08:46:16
@@ -69,9 +69,12 @@ gnu::gcj::convert::Input_iconv::read (jc
size_t outavail = count;
size_t old_out = outavail;
+ const char *inbuf = (const char *) &bytes[inpos];
+ char *outbuf = (char *) &out[outpos];
+
size_t r = iconv ((iconv_t) handle,
- &bytes[inpos], &inavail,
- &out[outpos], &outavail);
+ &inbuf, &inavail,
+ &outbuf, &outavail);
// FIXME: what if R==-1?
inpos += old_in - inavail;
@@ -118,7 +121,7 @@ gnu::gcj::convert::Output_iconv::write (
jint inpos, jint count)
{
#ifdef HAVE_ICONV
- jint origpos = outpos;
+ jint origpos = inpos;
jchar *chars = elements (inbuffer);
jbyte *out = elements (buf);
@@ -129,9 +132,12 @@ gnu::gcj::convert::Output_iconv::write (
size_t outavail = buf->length - count;
size_t old_out = outavail;
+ const char *inbuf = (const char *) &chars[inpos];
+ char *outbuf = (char *) &out[count];
+
size_t r = iconv ((iconv_t) handle,
- &chars[inpos], &inavail,
- &out[count], &outavail);
+ &inbuf, &inavail,
+ &outbuf, &outavail);
// FIXME: what if R==-1?
count += old_out - outavail;
AG
--
Anthony Green Red Hat
Sunnyvale, California