PatchSet 4285 
Date: 2004/01/07 16:49:09
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2004-01-07  Ito Kazumitsu  <[EMAIL PROTECTED]>

        * libraries/javalib/kaffe/io/ByteToCharConverter.java,
        libraries/javalib/kaffe/io/CharToByteConverter.java:
        Refined (hopefully).

Members: 
        ChangeLog:1.1872->1.1873 
        libraries/javalib/kaffe/io/ByteToCharConverter.java:1.22->1.23 
        libraries/javalib/kaffe/io/CharToByteConverter.java:1.15->1.16 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1872 kaffe/ChangeLog:1.1873
--- kaffe/ChangeLog:1.1872      Wed Jan  7 16:11:38 2004
+++ kaffe/ChangeLog     Wed Jan  7 16:49:09 2004
@@ -1,11 +1,8 @@
-2004-01-07  Dalibor Topic <[EMAIL PROTECTED]>
+2004-01-07  Ito Kazumitsu  <[EMAIL PROTECTED]>
 
-       * libraries/clib/net/PlainSocketImpl.c
-       [KAFFE_VMDEBUG] Merged the separate KAFFE_VMDEBUG parts
-       of the file to a single part, and added !defined(NDEBUG).
-       Fixes a compiler warning on sparc-solaris.
-
-        Reported by: Riccardo Mottola <[EMAIL PROTECTED]>
+       * libraries/javalib/kaffe/io/ByteToCharConverter.java,
+       libraries/javalib/kaffe/io/CharToByteConverter.java:
+       Refined (hopefully).
 
 2004-01-06  Guilhem Lavaux <[EMAIL PROTECTED]>
 
Index: kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java
diff -u kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.22 
kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.23
--- kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java:1.22      Tue Jan  6 
16:27:54 2004
+++ kaffe/libraries/javalib/kaffe/io/ByteToCharConverter.java   Wed Jan  7 16:49:11 
2004
@@ -108,26 +108,16 @@
        if (cls == noConverter) {
                return (null);
        }
-       else if (cls == useIconv) {
-               try {
-                       return (new ByteToCharIconv (ConverterAlias.alias(enc)));
-               }
-               catch (UnsupportedEncodingException _) {
-                       return (null);
-               }
+       if (cls == useIconv) {
+               return (getByteToCharIconv(ConverterAlias.alias(enc)));
        }
        try {
                if (cls == null) {
                        String realenc = ConverterAlias.alias(enc);
                        if (ConverterAlias.shouldUseIconv(realenc)) {
-                               try {
-                                       cache.put(enc, useIconv);
-                                       return (new ByteToCharIconv (realenc));
-                               }
-                               catch (UnsupportedEncodingException _) {
-                                       cache.put(enc, noConverter);
-                                       return (null);
-                               }
+                               ByteToCharConverter conv = getByteToCharIconv(realenc);
+                               cache.put(enc, (conv != null ? useIconv : 
noConverter));
+                               return (conv);
                        }
                        realenc = encodingRoot + ".ByteToChar" + realenc;
                        cls = Class.forName(realenc);
@@ -157,8 +147,19 @@
        }
        catch (InstantiationException _) {
        }
-       cache.put(enc, noConverter);
-       return (null);
+       // Finally, try iconv.
+        ByteToCharConverter conv = getByteToCharIconv(ConverterAlias.alias(enc));
+       cache.put(enc, (conv != null ? useIconv : noConverter));
+       return (conv);
+}
+
+private static ByteToCharConverter getByteToCharIconv ( String enc ) {
+       try {
+               return (new ByteToCharIconv (enc));
+       }
+       catch (UnsupportedEncodingException _) {
+               return (null);
+       }
 }
 
 public static ByteToCharConverter getConverter ( String enc ) throws 
UnsupportedEncodingException {
@@ -166,7 +167,7 @@
        if (conv != null) {
                return (conv);
        }
-       return new ByteToCharIconv (enc);
+       throw new UnsupportedEncodingException(enc);
 }
 public static ByteToCharConverter getDefault() {
        try {
Index: kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java
diff -u kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.15 
kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.16
--- kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java:1.15      Tue Jan  6 
16:27:54 2004
+++ kaffe/libraries/javalib/kaffe/io/CharToByteConverter.java   Wed Jan  7 16:49:11 
2004
@@ -86,26 +86,16 @@
        if (cls == noConverter) {
                return (null);
        }
-       else if (cls == useIconv) {
-               try {
-                       return (new CharToByteIconv (ConverterAlias.alias(enc)));
-               }
-               catch (UnsupportedEncodingException _) {
-                       return (null);
-               }
+       if (cls == useIconv) {
+               return (getCharToByteIconv(ConverterAlias.alias(enc)));
        }
        try {
                if (cls == null) {
                        String realenc = ConverterAlias.alias(enc);
                        if (ConverterAlias.shouldUseIconv(realenc)) {
-                               try {
-                                       cache.put(enc, useIconv);
-                                       return (new CharToByteIconv (realenc));
-                               }
-                               catch (UnsupportedEncodingException _) {
-                                       cache.put(enc, noConverter);
-                                       return (null);
-                               }
+                               CharToByteConverter conv = getCharToByteIconv(realenc);
+                               cache.put(enc, (conv != null ? useIconv : 
noConverter));
+                               return (conv);
                        }
                        realenc = encodingRoot + ".CharToByte" + realenc;
                        cls = Class.forName(realenc);
@@ -135,8 +125,19 @@
        }
        catch (IllegalAccessException _) {
        }
-       cache.put(enc, noConverter);
-       return (null);
+       // Finally, try iconv.
+       CharToByteConverter conv = getCharToByteIconv(ConverterAlias.alias(enc));
+       cache.put(enc, (conv != null ? useIconv : noConverter));
+       return (conv);
+}
+
+public static CharToByteConverter getCharToByteIconv(String enc) {
+       try {
+               return (new CharToByteIconv (enc));
+       }
+       catch (UnsupportedEncodingException _) {
+               return (null);
+       }
 }
 
 public static CharToByteConverter getConverter(String enc) throws 
UnsupportedEncodingException {
@@ -144,7 +145,7 @@
        if (conv != null) {
                return (conv);
        }
-       return new CharToByteIconv (enc);
+       throw new UnsupportedEncodingException(enc);
 }
 
 public static CharToByteConverter getDefault() {

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to