java.io.PipedReader

YAMAGUCHI Yuji yamag at distribution.co.jp
Mon Jun 28 11:37:56 PDT 1999


Hi, all.

Here is a patch for PipedReader.
Attached is the test program.

Index: PipedReader.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/io/PipedReader.java,v
retrieving revision 1.1
diff -c -r1.1 PipedReader.java
*** PipedReader.java	1998/07/14 17:02:05	1.1
--- PipedReader.java	1999/06/28 19:07:57
***************
*** 45,68 ****
  
      synchronized(lock) {
  
!       while (size == 0) {
!         if (wr == null) {
!           return (-1);
          }
! 	try {
!           lock.wait();
! 	}
! 	catch (InterruptedException _) {
! 	}
        }
  
-       for (i = 0; i < len && size > 0; i++) {
- 	cbuf[off++] = buf[outpos++];
- 	size--;
- 	if (outpos == buf.length) {
- 	  outpos = 0;
- 	}
-       }
      }
      return (i);
    }
--- 45,71 ----
  
      synchronized(lock) {
  
!       for (i = 0; i < len;) {
!         while (size == 0) {
!           if (wr == null) {
! 	    return i > 0 ? i : -1;
!           }
! 	  try {
!             lock.wait();
! 	  }
! 	  catch (InterruptedException _) {
! 	  }
          }
!         for (; i < len && size > 0; i++) {
! 	  cbuf[off++] = buf[outpos++];
! 	  size--;
! 	  if (outpos == buf.length) {
! 	    outpos = 0;
! 	  }
!         }
! 	lock.notifyAll();
        }
  
      }
      return (i);
    }
***************
*** 71,77 ****
    {
      synchronized(lock) {
  
!       for (int i = 0; i < len; i++) {
          for (;;) {
            if (size < buf.length) {
              break;
--- 74,80 ----
    {
      synchronized(lock) {
  
!       for (int i = 0; i < len;) {
          for (;;) {
            if (size < buf.length) {
              break;
***************
*** 81,92 ****
            }
            catch (InterruptedException _) {
            }
-         }
-         buf[inpos++] = cbuf[off++];
-         size++;
-         if (inpos == buf.length) {
-           inpos = 0;
          }
        }
  
      }
--- 84,98 ----
            }
            catch (InterruptedException _) {
            }
          }
+         for (; i < len && size < buf.length; i++) {
+           buf[inpos++] = cbuf[off++];
+           size++;
+           if (inpos == buf.length) {
+             inpos = 0;
+           }
+ 	}
+ 	lock.notifyAll();
        }
  
      }
***************
*** 99,104 ****
--- 105,111 ----
  	wr.rd = null;
          wr = null;
        }
+       lock.notifyAll();
      }
    }
  

--
// YAMAGUCHI Yuji - yamag at distribution.co.jp -
// Freeware Distribution Services Co.,Ltd.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PipeTest.java
Type: application/octet-stream
Size: 1143 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/19990629/df3702f0/attachment-0003.obj 


More information about the kaffe mailing list