[kaffe] CVS kaffe (kaz): libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java,

Kaffe CVS cvs-commits at kaffe.org
Thu Oct 20 08:12:46 PDT 2005


PatchSet 6951 
Date: 2005/10/20 14:59:56
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2005-10-20  Ito Kazumitsu  <kaz at maczuka.gcd.org>

        * libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java,
        libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java,
        libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:
        Proposed patch for GCC Bugzilla Bug 23008 and 22968.

Members: 
	ChangeLog:1.4475->1.4476 
	libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java:1.1->1.2 
	libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java:1.1->1.2 
	libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4475 kaffe/ChangeLog:1.4476
--- kaffe/ChangeLog:1.4475	Wed Oct 19 20:48:10 2005
+++ kaffe/ChangeLog	Thu Oct 20 14:59:56 2005
@@ -1,3 +1,10 @@
+2005-10-20  Ito Kazumitsu  <kaz at maczuka.gcd.org>
+
+	* libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java,
+	libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java,
+	libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:
+	Proposed patch for GCC Bugzilla Bug 23008 and 22968.
+
 2005-10-19  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* developers/update-vm-list: New script adapted from update-class-list
Index: kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java
diff -u kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java:1.1 kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java:1.2
--- kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java:1.1	Wed Oct 19 20:36:31 2005
+++ kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UTF_16Decoder.java	Thu Oct 20 15:00:03 2005
@@ -54,6 +54,8 @@
   static final int BIG_ENDIAN = 0;
   static final int LITTLE_ENDIAN = 1;
   static final int UNKNOWN_ENDIAN = 2;
+  static final int MAYBE_BIG_ENDIAN = 3;
+  static final int MAYBE_LITTLE_ENDIAN = 4;
 
   private static final char BYTE_ORDER_MARK = 0xFEFF;
   private static final char REVERSED_BYTE_ORDER_MARK = 0xFFFE;
@@ -81,26 +83,37 @@
             byte b2 = in.get ();
 
             // handle byte order mark
-            if (byteOrder == UNKNOWN_ENDIAN)
+            if (byteOrder == UNKNOWN_ENDIAN ||
+                byteOrder == MAYBE_BIG_ENDIAN ||
+                byteOrder == MAYBE_LITTLE_ENDIAN)
               {
                 char c = (char) (((b1 & 0xFF) << 8) | (b2 & 0xFF));
                 if (c == BYTE_ORDER_MARK)
                   {
+                    if (byteOrder == MAYBE_LITTLE_ENDIAN)
+                      {
+                        return CoderResult.malformedForLength (2);
+                      }
                     byteOrder = BIG_ENDIAN;
                     inPos += 2;
                     continue;
                   }
                 else if (c == REVERSED_BYTE_ORDER_MARK)
                   {
+                    if (byteOrder == MAYBE_BIG_ENDIAN)
+                      {
+                        return CoderResult.malformedForLength (2);
+                      }
                     byteOrder = LITTLE_ENDIAN;
                     inPos += 2;
                     continue;
                   }
                 else
                   {
-                    // assume big endian, do not consume bytes,
+                    // assume big or little endian, do not consume bytes,
                     // continue with normal processing
-                    byteOrder = BIG_ENDIAN;
+                    byteOrder = (byteOrder == MAYBE_LITTLE_ENDIAN ?
+                                 LITTLE_ENDIAN : BIG_ENDIAN);
                   }
               }
 
Index: kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java
diff -u kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java:1.1 kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java:1.2
--- kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java:1.1	Wed Oct 19 20:36:31 2005
+++ kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/UnicodeLittle.java	Thu Oct 20 15:00:03 2005
@@ -64,7 +64,7 @@
 
   public CharsetDecoder newDecoder ()
   {
-    return new UTF_16Decoder (this, UTF_16Decoder.UNKNOWN_ENDIAN);
+    return new UTF_16Decoder (this, UTF_16Decoder.MAYBE_LITTLE_ENDIAN);
   }
 
   public CharsetEncoder newEncoder ()
Index: kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java
diff -u kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:1.1 kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:1.2
--- kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java:1.1	Wed Oct 19 20:36:32 2005
+++ kaffe/libraries/javalib/external/classpath/gnu/java/nio/charset/iconv/IconvProvider.java	Thu Oct 20 15:00:04 2005
@@ -62,7 +62,11 @@
         }
     }
 
-  private IconvProvider()
+  // Declaring the construtor public may violate the use of singleton.
+  // But it must be public so that an instance of this class can be
+  // created by Class.newInstance(), which is the case when this provider is
+  // defined in META-INF/services/java.nio.charset.spi.CharsetProvider.
+  public IconvProvider()
   {
     IconvMetaData.setup();
   }




More information about the kaffe mailing list