summaryrefslogtreecommitdiffstats
path: root/generic/tclIORChan.c
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2008-04-04 17:19:40 (GMT)
committerandreas_kupries <akupries@shaw.ca>2008-04-04 17:19:40 (GMT)
commit3554b9e788ccb6740c210c1d3d1c8f01eea7a6fc (patch)
tree54a18a3101532c359328a9075e7c1f09a20fc896 /generic/tclIORChan.c
parentdd13549c2381c348b6536501d389e513a6082f5d (diff)
downloadtcl-3554b9e788ccb6740c210c1d3d1c8f01eea7a6fc.zip
tcl-3554b9e788ccb6740c210c1d3d1c8f01eea7a6fc.tar.gz
tcl-3554b9e788ccb6740c210c1d3d1c8f01eea7a6fc.tar.bz2
* generic/tclIORChan.c (ReflectOutput): Allow zero return from
write when input was zero-length anyway. Otherwise keept it an error, and separate the message from 'written too much'. * tests/ioCmd.test (iocmd-24.6): Testcase updated for changed message.
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r--generic/tclIORChan.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 905a773..157e712 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIORChan.c,v 1.28.2.1 2008/04/04 16:45:50 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIORChan.c,v 1.28.2.2 2008/04/04 17:19:42 andreas_kupries Exp $
*/
#include <tclInt.h>
@@ -434,6 +434,7 @@ static const char *msg_read_unsup = "{read not supported by Tcl driver}";
static const char *msg_read_toomuch = "{read delivered more than requested}";
static const char *msg_write_unsup = "{write not supported by Tcl driver}";
static const char *msg_write_toomuch = "{write wrote more than requested}";
+static const char *msg_write_nothing = "{write wrote nothing}";
static const char *msg_seek_beforestart = "{Tried to seek before origin}";
#ifdef TCL_THREADS
static const char *msg_send_originlost = "{Origin thread lost}";
@@ -1290,7 +1291,17 @@ ReflectOutput(
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
- if ((written == 0) || (toWrite < written)) {
+ if ((written == 0) && (toWrite > 0)) {
+ /*
+ * The handler claims to have written nothing of what it was
+ * given. That is bad.
+ */
+
+ SetChannelErrorStr(rcPtr->chan, msg_write_nothing);
+ *errorCodePtr = EINVAL;
+ return -1;
+ }
+ if (toWrite < written) {
/*
* The handler claims to have written more than it was given. That is
* bad. Note that the I/O core would crash if we were to return this