summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-10 02:53:17 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-10 02:53:17 +0000
commitead59d03720cae28f1525c8d7f2ceb2601a9f1d5 (patch)
treefa9364795f38b5bc6f0e8a62faa6651caa3aa516 /libjava
parentd8d2ab79f1390cf162aa55e82916ff38e72235f5 (diff)
downloadgcc-ead59d03720cae28f1525c8d7f2ceb2601a9f1d5.tar.gz
* java/io/PrintStream.java (print): Always flush if auto_flush is
set. Don't check for newline characters. (write (int)): Implement without using a temporary array. (write (byte[], int, int): Always flush if auto_flush is set. Don't check for newline characters. Fixes PR libgcj/11778. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70284 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog9
-rw-r--r--libjava/java/io/PrintStream.java41
2 files changed, 33 insertions, 17 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 1ada88c0a36..d790e60fbd9 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-10 Bryce McKinlay <bryce@mckinlay.net.nz>
+
+ * java/io/PrintStream.java (print): Always flush if auto_flush is
+ set. Don't check for newline characters.
+ (write (int)): Implement without using a temporary array.
+ (write (byte[], int, int): Always flush if auto_flush is set. Don't
+ check for newline characters.
+ Fixes PR libgcj/11778.
+
2003-08-08 Andrew Haley <aph@redhat.com>
* Makefile.am (AM_CXXFLAGS): Define BOOT_CLASS_PATH.
diff --git a/libjava/java/io/PrintStream.java b/libjava/java/io/PrintStream.java
index 83668523ab8..d2a211744e2 100644
--- a/libjava/java/io/PrintStream.java
+++ b/libjava/java/io/PrintStream.java
@@ -95,7 +95,9 @@ public class PrintStream extends FilterOutputStream
* This method intializes a new <code>PrintStream</code> object to write
* to the specified output sink. This constructor also allows "auto-flush"
* functionality to be specified where the stream will be flushed after
- * every line is terminated or newline character is written.
+ * every <code>print</code> or <code>println</code> call, when the
+ * <code>write</code> methods with array arguments are called, or when a
+ * single new-line character is written.
* <p>
*
* @param out The <code>OutputStream</code> to write to.
@@ -114,7 +116,9 @@ public class PrintStream extends FilterOutputStream
* This method intializes a new <code>PrintStream</code> object to write
* to the specified output sink. This constructor also allows "auto-flush"
* functionality to be specified where the stream will be flushed after
- * every line is terminated or newline character is written.
+ * every <code>print</code> or <code>println</code> call, when the
+ * <code>write</code> methods with array arguments are called, or when a
+ * single new-line character is written.
* <p>
*
* @param out The <code>OutputStream</code> to write to.
@@ -256,10 +260,8 @@ public class PrintStream extends FilterOutputStream
{
pw.print (str);
- if (str != null && auto_flush)
- if ((str.indexOf ('\r') != -1)
- || (str.indexOf ('\n') != -1))
- flush ();
+ if (auto_flush)
+ flush ();
}
/**
@@ -422,9 +424,21 @@ public class PrintStream extends FilterOutputStream
*/
public void write (int oneByte)
{
- byte[] data = new byte [1];
- data [0] = (byte) (oneByte & 0xff);
- write (data, 0, 1);
+ // We actually have to implement this method. Flush first so that
+ // things get written in the right order.
+ flush();
+
+ try
+ {
+ out.write (oneByte & 0xff);
+
+ if (auto_flush && (oneByte == '\n'))
+ flush ();
+ }
+ catch (IOException e)
+ {
+ setError ();
+ }
}
/**
@@ -446,19 +460,12 @@ public class PrintStream extends FilterOutputStream
out.write (buffer, offset, len);
if (auto_flush)
- for (int i = offset; i < len; i++)
- if ((buffer [i] == '\r')
- || (buffer [i] == '\n'))
- {
- flush ();
- break;
- }
+ flush ();
}
catch (IOException e)
{
setError ();
}
}
-
} // class PrintStream