Commit 6cd167e1 by Tom Tromey Committed by Tom Tromey

PipedInputStream.java, [...]: Yet another new version from Classpath.

	* java/io/PipedInputStream.java, java/io/PipedOutputStream.java:
	Yet another new version from Classpath.

From-SVN: r33328
parent 7f13af23
2000-04-21 Tom Tromey <tromey@cygnus.com> 2000-04-21 Tom Tromey <tromey@cygnus.com>
* java/io/PipedInputStream.java, java/io/PipedOutputStream.java:
Yet another new version from Classpath.
Fix for PR libgcj/15: Fix for PR libgcj/15:
* java/util/natGregorianCalendar.cc (_REENTRANT, * java/util/natGregorianCalendar.cc (_REENTRANT,
_POSIX_PTHREAD_SEMANTICS): Don't define. _POSIX_PTHREAD_SEMANTICS): Don't define.
......
...@@ -398,30 +398,19 @@ read(byte[] buf, int offset, int len) throws IOException ...@@ -398,30 +398,19 @@ read(byte[] buf, int offset, int len) throws IOException
* If there is no data ready to be written, or if the internal circular * If there is no data ready to be written, or if the internal circular
* buffer is full, this method blocks. * buffer is full, this method blocks.
* *
* *****What is this method really supposed to do ********* * @param byte_received The byte to write to this stream
*
* @exception IOException if error occurs
*
*/ */
protected synchronized void protected synchronized void
receive(int byte_received) throws IOException receive(int byte_received) throws IOException
{ {
int orig_in = in; // This is really slow, but it has the benefit of not duplicating
// the complicated machinery in receive(byte[],int,int).
for (;;) byte[] buf = new byte[1];
{ buf[0] = (byte) (byte_received & 0xff);
// Wait for something to happen receive (buf, 0, 1);
try
{
wait();
}
catch(InterruptedException e) { ; }
// See if we woke up because the stream was closed on us
if (closed)
throw new IOException("Stream closed before receiving byte");
// See if a byte of data was received
if (in != orig_in)
return;
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -439,7 +428,7 @@ receive(int byte_received) throws IOException ...@@ -439,7 +428,7 @@ receive(int byte_received) throws IOException
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
synchronized void synchronized void
write(byte[] buf, int offset, int len) throws IOException receive(byte[] buf, int offset, int len) throws IOException
{ {
if (len <= 0) if (len <= 0)
return; return;
......
/* PipedOutputStream.java -- Write portion of piped streams. /* PipedOutputStream.java -- Write portion of piped streams.
Copyright (C) 1998 Free Software Foundation, Inc. Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -164,10 +164,7 @@ close() throws IOException ...@@ -164,10 +164,7 @@ close() throws IOException
public synchronized void public synchronized void
write(int b) throws IOException write(int b) throws IOException
{ {
byte[] buf = new byte[1]; snk.receive (b);
buf[0] = (byte)(b & 0xFF);
snk.write(buf, 0, buf.length);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -188,7 +185,7 @@ write(int b) throws IOException ...@@ -188,7 +185,7 @@ write(int b) throws IOException
public void public void
write(byte[] buf, int offset, int len) throws IOException write(byte[] buf, int offset, int len) throws IOException
{ {
snk.write(buf, 0, len); snk.receive (buf, 0, len);
} }
/*************************************************************************/ /*************************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment