DataInputStream.java (readLine): Corrected handling of empty lines, from null to "".
authorUrban Widmark <urban@svenskatest.se>
Mon, 12 Apr 1999 18:27:56 +0000 (20:27 +0200)
committerWarren Levy <warrenl@gcc.gnu.org>
Mon, 12 Apr 1999 18:27:56 +0000 (18:27 +0000)
1999-04-12  Urban Widmark <urban@svenskatest.se>
* java/io/DataInputStream.java (readLine): Corrected handling of
empty lines, from null to "".

From-SVN: r26381

libjava/ChangeLog
libjava/java/io/DataInputStream.java

index 3beb48cbc6215edf076310736b12b15d12d1adf7..9b8323a7c0d4752c5b92e694e59d23e73dd15315 100644 (file)
@@ -1,3 +1,8 @@
+1999-04-12  Urban Widmark <urban@svenskatest.se>
+
+       * java/io/DataInputStream.java (readLine): Corrected handling of
+       empty lines, from null to "".
+
 1999-04-12  Tom Tromey  <tromey@cygnus.com>
 
        * Makefile.in: Rebuilt.
index 7c90008c6e08e05ca7499d6e9935c42faf9d2449..d03f8f4da3e17f7856a6de491a070cdea269e9f0 100644 (file)
@@ -105,8 +105,11 @@ public class DataInputStream extends FilterInputStream implements DataInput
 
     while (true)
       {
-       char ch = (char) read();
-       if (ch < 0 || (ch &= 0xFF) == '\n')
+       int c = read();
+       if (c < 0)      // got an EOF
+         return strb.length() > 0 ? strb.toString() : null;
+       char ch = (char) c;
+       if ((ch &= 0xFF) == '\n')
          break;
        if (ch == '\r')
          {
@@ -148,7 +151,7 @@ public class DataInputStream extends FilterInputStream implements DataInput
        strb.append(ch);
       }
 
-    return strb.length() > 0 ? strb.toString() : null;
+    return strb.length() > 0 ? strb.toString() : "";
   }
 
   public final long readLong() throws IOException