[kaffe] CVS kaffe (kaz): libraries/clib/native/ByteToCharIconv.c,
Kaffe CVS
cvs-commits at kaffe.org
Fri Dec 12 08:17:01 PST 2003
PatchSet 4218
Date: 2003/12/12 16:14:18
Author: kaz
Branch: HEAD
Tag: (none)
Log:
2003-12-12 Atsushi Nemoto <anemo at mba.ocn.ne.jp>
* libraries/clib/native/ByteToCharIconv.c,
libraries/clib/native/CharToByteIconv.c:
The endianness of UCS-2 varys depending on the version of
iconv. So we use UCS-2BE or UCS-2LE depending on the endianness
of the configuration.
Commited by Ito Kazumitsu <kaz at maczuka.gcd.org>.
Members:
ChangeLog:1.1808->1.1809
libraries/clib/native/ByteToCharIconv.c:1.5->1.6
libraries/clib/native/CharToByteIconv.c:1.3->1.4
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1808 kaffe/ChangeLog:1.1809
--- kaffe/ChangeLog:1.1808 Fri Dec 12 15:58:49 2003
+++ kaffe/ChangeLog Fri Dec 12 16:14:18 2003
@@ -1,3 +1,12 @@
+2003-12-12 Atsushi Nemoto <anemo at mba.ocn.ne.jp>
+
+ * libraries/clib/native/ByteToCharIconv.c,
+ libraries/clib/native/CharToByteIconv.c:
+ The endianness of UCS-2 varys depending on the version of
+ iconv. So we use UCS-2BE or UCS-2LE depending on the endianness
+ of the configuration.
+ Commited by Ito Kazumitsu <kaz at maczuka.gcd.org>.
+
2003-12-12 Dalibor Topic <robilad at kaffe.org>
* config/m68k/sysdepCallMethod.h: New file.
Index: kaffe/libraries/clib/native/ByteToCharIconv.c
diff -u kaffe/libraries/clib/native/ByteToCharIconv.c:1.5 kaffe/libraries/clib/native/ByteToCharIconv.c:1.6
--- kaffe/libraries/clib/native/ByteToCharIconv.c:1.5 Tue May 6 15:24:08 2003
+++ kaffe/libraries/clib/native/ByteToCharIconv.c Fri Dec 12 16:14:19 2003
@@ -41,7 +41,11 @@
iconv_t cd;
str = (*env)->GetStringUTFChars(env, enc, 0);
- cd = iconv_open ("UCS-2", (char *)str);
+#ifdef WORDS_BIGENDIAN
+ cd = iconv_open ("UCS-2BE", (char *)str);
+#else
+ cd = iconv_open ("UCS-2LE", (char *)str);
+#endif
(*env)->ReleaseStringUTFChars(env, enc, str);
if (cd != (iconv_t)-1) {
(*env)->SetObjectField(env, _this, cd_id, (jobject)cd);
@@ -74,25 +78,7 @@
size_t icv_outlen = toLen * 2;
iconv_t cd = (iconv_t) (*env)->GetObjectField(env, _this, cd_id);
int ret;
-#ifndef WORDS_BIGENDIAN
- char *buffer;
-#endif
-
-#ifndef WORDS_BIGENDIAN
- if (icv_outlen == 0) {
- return 0;
- }
- buffer = KMALLOC (icv_outlen);
- if (!buffer) {
- jclass oom;
- (*env)->ReleaseByteArrayElements(env, fromBytes, jb, JNI_ABORT);
- (*env)->ReleaseCharArrayElements(env, toChars, jc, 0);
- oom = (*env)->FindClass(env, "java.lang.OutOfMemory");
- (*env)->ThrowNew(env, oom, "iconv()");
- }
- icv_out = buffer;
-#endif
ret = iconv (cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
if (ret < 0) {
/* convert the begining of an invalid multibyte sequence to '?' */
@@ -104,10 +90,6 @@
icv_outlen -= 2;
}
}
-#ifndef WORDS_BIGENDIAN
- swab (buffer, jc + toPos, toLen * 2 - icv_outlen);
- KFREE (buffer);
-#endif
if (icv_inlen > 0) {
/* In case we have some bytes left, save them */
(*env)->CallVoidMethod(env, _this, carry_id,
Index: kaffe/libraries/clib/native/CharToByteIconv.c
diff -u kaffe/libraries/clib/native/CharToByteIconv.c:1.3 kaffe/libraries/clib/native/CharToByteIconv.c:1.4
--- kaffe/libraries/clib/native/CharToByteIconv.c:1.3 Tue May 6 15:24:08 2003
+++ kaffe/libraries/clib/native/CharToByteIconv.c Fri Dec 12 16:14:19 2003
@@ -39,7 +39,11 @@
iconv_t cd;
str = (*env)->GetStringUTFChars(env, enc, 0);
- cd = iconv_open ((char *)str, "UCS-2");
+#ifdef WORDS_BIGENDIAN
+ cd = iconv_open ((char *)str, "UCS-2BE");
+#else
+ cd = iconv_open ((char *)str, "UCS-2LE");
+#endif
(*env)->ReleaseStringUTFChars(env, enc, str);
if (cd != (iconv_t)-1) {
(*env)->SetObjectField(env, _this, cd_id, (jobject)cd);
@@ -72,32 +76,8 @@
size_t icv_outlen = toLen;
iconv_t cd = (iconv_t) (*env)->GetObjectField(env, _this, cd_id);
int ret;
-#ifndef WORDS_BIGENDIAN
- char *buffer;
-#endif
-#ifndef WORDS_BIGENDIAN
- if (icv_inlen > 0) {
- buffer = KMALLOC (icv_inlen);
- if (!buffer) {
- jclass oom;
-
- (*env)->ReleaseCharArrayElements(env, fromChars, jc, JNI_ABORT);
- (*env)->ReleaseByteArrayElements(env, toBytes, jb, 0);
- oom = (*env)->FindClass(env, "java.lang.OutOfMemory");
- (*env)->ThrowNew(env, oom, "iconv()");
- }
- swab (icv_in, buffer, icv_inlen);
- icv_in = buffer;
- }
- else {
- buffer = NULL;
- }
-#endif
ret = iconv (cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
-#ifndef WORDS_BIGENDIAN
- KFREE (buffer);
-#endif
if (icv_inlen > 0) {
/* In case we have some bytes left, save them */
(*env)->CallVoidMethod(env, _this, carry_id,
More information about the kaffe
mailing list