]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
InputStreamReader.java (refill): Handle no-progress case correctly.
authorTom Tromey <tromey@redhat.com>
Wed, 6 Jul 2005 20:10:41 +0000 (20:10 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 6 Jul 2005 20:10:41 +0000 (20:10 +0000)
* java/io/InputStreamReader.java (refill): Handle no-progress
case correctly.
* gnu/gcj/convert/IOConverter.java: Add 'utf8' alias.

From-SVN: r101663

libjava/ChangeLog
libjava/gnu/gcj/convert/IOConverter.java
libjava/java/io/InputStreamReader.java

index 39e2fd0736eeceb6959d2f77f7f6839a3b3938a9..657e238d87924a450821470d37fb528044f3b257 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-06  Tom Tromey  <tromey@redhat.com>
+
+       * java/io/InputStreamReader.java (refill): Handle no-progress
+       case correctly.
+       * gnu/gcj/convert/IOConverter.java: Add 'utf8' alias.
+
 2005-07-06  Tom Tromey  <tromey@redhat.com>
 
        * testsuite/libjava.jacks/jacks.xfail: Removed 9.1.3-body-5.
index ba3260ac17e425278cc9043e957543b4619d78c1..2c6849ce7a37a66235167752df28019743c53fae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2001  Free Software Foundation
+/* Copyright (C) 2000, 2001, 2005  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -28,6 +28,8 @@ public abstract class IOConverter
     // canonical name.
     hash.put ("iso-latin-1", "8859_1");
     hash.put ("iso8859_1", "8859_1");
+    // At least one build script out there uses 'utf8'.
+    hash.put ("utf8", "UTF8");
     // On Solaris the default encoding, as returned by nl_langinfo(),
     // is `646' (aka ASCII), but the Solaris iconv_open() doesn't
     // understand that.  We work around the problem by adding an
index f8ad53cdd015051107c8b0502c31e313137a4307..e55f1352caa432ef90f855fa251da2f236741966 100644 (file)
@@ -289,9 +289,23 @@ public class InputStreamReader extends Reader
          return -1;
        converter.setInput(in.buf, in.pos, in.count);
        int count = converter.read(buf, offset, length);
-       in.skip(converter.inpos - in.pos);
-       if (count > 0)
-         return count;
+
+       // We might have bytes but not have made any progress.  In
+       // this case we try to refill.  If refilling fails, we assume
+       // we have a malformed character at the end of the stream.
+       if (count == 0 && converter.inpos == in.pos)
+         {
+           in.mark(in.count);
+           if (! in.refill ())
+             throw new CharConversionException ();
+           in.reset();
+         }
+       else
+         {
+           in.skip(converter.inpos - in.pos);
+           if (count > 0)
+             return count;
+         }
       }
   }
 }