[kaffe] CVS kaffe (kaz): libraries/clib/native/CharToByteIconv.c
Kaffe CVS
cvs-commits at kaffe.org
Wed Jan 12 08:28:33 PST 2005
PatchSet 5837
Date: 2005/01/12 16:18:42
Author: kaz
Branch: HEAD
Tag: (none)
Log:
2005-01-12 Ito Kazumitsu <kaz at maczuka.gcd.org>
* libraries/clib/native/CharToByteIconv.c
(Java_kaffe_io_CharToByteIconv_convert):
Check whether errno == EILSEQ.
* libraries/javalib/all.files:
Add kaffe/libraries/javalib/kaffe/io/KaffeCharset.java and
kaffe/libraries/javalib/kaffe/io/KaffeCharsetProvider.java.
* libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
(write(ByteBuffer)): Move the position of the source buffer forward.
* kaffe/libraries/javalib/kaffe/io/KaffeCharset.java:
Initial bugs fixed.
Members:
ChangeLog:1.3381->1.3382
libraries/clib/native/CharToByteIconv.c:1.10->1.11
libraries/javalib/all.files:1.70->1.71
libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.2->1.3
libraries/javalib/kaffe/io/KaffeCharset.java:1.1->1.2
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3381 kaffe/ChangeLog:1.3382
--- kaffe/ChangeLog:1.3381 Wed Jan 12 13:20:53 2005
+++ kaffe/ChangeLog Wed Jan 12 16:18:42 2005
@@ -1,3 +1,19 @@
+2005-01-12 Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+ * libraries/clib/native/CharToByteIconv.c
+ (Java_kaffe_io_CharToByteIconv_convert):
+ Check whether errno == EILSEQ.
+
+ * libraries/javalib/all.files:
+ Add kaffe/libraries/javalib/kaffe/io/KaffeCharset.java and
+ kaffe/libraries/javalib/kaffe/io/KaffeCharsetProvider.java.
+
+ * libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
+ (write(ByteBuffer)): Move the position of the source buffer forward.
+
+ * kaffe/libraries/javalib/kaffe/io/KaffeCharset.java:
+ Initial bugs fixed.
+
2005-01-12 Guilhem Lavaux <guilhem at kaffe.org>
* libraries/javalib/gnu/java/io/EncodingManager.java
Index: kaffe/libraries/clib/native/CharToByteIconv.c
diff -u kaffe/libraries/clib/native/CharToByteIconv.c:1.10 kaffe/libraries/clib/native/CharToByteIconv.c:1.11
--- kaffe/libraries/clib/native/CharToByteIconv.c:1.10 Tue Dec 21 05:49:58 2004
+++ kaffe/libraries/clib/native/CharToByteIconv.c Wed Jan 12 16:18:46 2005
@@ -25,6 +25,8 @@
#include <unistd.h>
#endif
+#include <errno.h>
+
static jfieldID cd_id;
static jmethodID carry_id;
@@ -82,6 +84,15 @@
int ret;
ret = iconv (cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+ if (ret < 0) {
+ /* convert the unmappable character to '?' */
+ if (errno == EILSEQ && icv_outlen > 0) {
+ icv_in += 2;
+ icv_inlen -= 2;
+ *(icv_out++) = '?';
+ icv_outlen--;
+ }
+ }
if (icv_inlen > 0) {
/* In case we have some bytes left, save them */
(*env)->CallVoidMethod(env, _this, carry_id,
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.70 kaffe/libraries/javalib/all.files:1.71
--- kaffe/libraries/javalib/all.files:1.70 Sun Jan 9 21:05:43 2005
+++ kaffe/libraries/javalib/all.files Wed Jan 12 16:18:48 2005
@@ -3381,6 +3381,8 @@
kaffe/io/CircularBuffer.java
kaffe/io/ClassLoaderObjectInputStream.java
kaffe/io/ConverterAlias.java
+kaffe/io/KaffeCharset.java
+kaffe/io/KaffeCharsetProvider.java
kaffe/io/NullOutputStream.java
kaffe/io/StdErrorStream.java
kaffe/io/StdInputStream.java
Index: kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.2 kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.3
--- kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.2 Tue May 18 16:13:29 2004
+++ kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java Wed Jan 12 16:18:50 2005
@@ -191,6 +191,7 @@
{
byte[] buffer = src.array();
write(buffer, src.arrayOffset() + src.position(), len);
+ src.position(src.position() + len);
}
else
{
Index: kaffe/libraries/javalib/kaffe/io/KaffeCharset.java
diff -u kaffe/libraries/javalib/kaffe/io/KaffeCharset.java:1.1 kaffe/libraries/javalib/kaffe/io/KaffeCharset.java:1.2
--- kaffe/libraries/javalib/kaffe/io/KaffeCharset.java:1.1 Mon Jan 10 15:13:34 2005
+++ kaffe/libraries/javalib/kaffe/io/KaffeCharset.java Wed Jan 12 16:18:52 2005
@@ -46,7 +46,7 @@
// I know nothing about any charset other than myself.
public boolean contains (Charset cs)
{
- return this.getClass().isInstance(cs);
+ return this.name().equalsIgnoreCase(cs.name());
}
private static final class Decoder extends CharsetDecoder
@@ -68,6 +68,8 @@
private kaffe.io.ByteToCharConverter b2c;
+ // Kaffe's BytetoCharConverter cannot report byte sequence being
+ // malformed. Undecodable bytes are always converted to '?'.
protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
{
byte[] inbuf = null;
@@ -80,7 +82,7 @@
if (in.hasArray())
{
inbuf = in.array();
- inPos = in.position();
+ inPos = in.arrayOffset() + in.position();
inLen = in.remaining();
in.position(in.limit());
}
@@ -94,7 +96,7 @@
if (out.hasArray())
{
outbuf = out.array();
- outPos = out.position();
+ outPos = out.arrayOffset() + out.position();
outLen = out.remaining();
}
else {
@@ -107,7 +109,7 @@
if (out.hasArray())
{
- out.position(outPos + l);
+ out.position(out.position() + l);
}
else
{
@@ -155,6 +157,8 @@
private kaffe.io.CharToByteConverter c2b;
+ // Kaffe's CharToByteConverter cannot report characters being unmappable.
+ // Unmappable characters are always converted to '?'.
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
char[] inbuf = null;
@@ -167,7 +171,7 @@
if (in.hasArray())
{
inbuf = in.array();
- inPos = in.position();
+ inPos = in.arrayOffset() + in.position();
inLen = in.remaining();
in.position(in.limit());
}
@@ -181,11 +185,11 @@
if (out.hasArray())
{
outbuf = out.array();
- outPos = out.position();
+ outPos = out.arrayOffset() + out.position();
outLen = out.remaining();
}
-else {
- outbuf = new byte[out.remaining()];
+ else {
+ outbuf = new byte[out.remaining()];
outPos = 0;
outLen = outbuf.length;
}
@@ -194,7 +198,7 @@
if (out.hasArray())
{
- out.position(outPos + l);
+ out.position(out.position() + l);
}
else
{
More information about the kaffe
mailing list