Tcl Source Code

Artifact [ab98e1e02d]
Login

Artifact ab98e1e02d019dcee26800df15b7d8747ecaf3a0:

Attachment "io.diff" to ticket [478856ffff] added by andreas_kupries 2001-11-07 05:38:09.
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.40
diff -u -r1.40 tclIO.c
--- generic/tclIO.c	2001/10/16 05:31:18	1.40
+++ generic/tclIO.c	2001/11/06 22:30:17
@@ -4641,16 +4652,24 @@
 	ChannelBuffer *nextPtr;
 	
 	nextPtr = bufPtr->nextPtr;
-	if (nextPtr == NULL) {
-	    /*
-	     * There isn't enough data in the buffers to complete the next
-	     * character, so we need to wait for more data before the next
-	     * file event can be delivered.
-	     */
+	  if (nextPtr == NULL) {
+	    if (srcLen > 0) {
+	      /*
+	       * There isn't enough data in the buffers to complete the next
+	       * character, so we need to wait for more data before the next
+	       * file event can be delivered.
+	       *
+	       * The exception to this is if the input buffer was
+	       * completely empty before we tried to convert its
+	       * contents. Nothing in, nothing out, and no incomplete
+	       * character data. The conversion before the current one
+	       * was complete.
+	       */
 
-	    statePtr->flags |= CHANNEL_NEED_MORE_DATA;
+	      statePtr->flags |= CHANNEL_NEED_MORE_DATA;
+	    }
 	    return -1;
-	}
+	  }
 	nextPtr->nextRemoved -= srcLen;
 	memcpy((VOID *) (nextPtr->buf + nextPtr->nextRemoved), (VOID *) src,
 		(size_t) srcLen);