summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2008-04-07 19:41:59 (GMT)
committerandreas_kupries <akupries@shaw.ca>2008-04-07 19:41:59 (GMT)
commit4ef1119b6a57574cc2bc49f1c5f2060dc56509ea (patch)
treebf94974f5cd54afd750cbdaab55a4b933b118c9b
parent871b84cdfe3b833bb5d1496f8d8bc70013257619 (diff)
downloadtcl-4ef1119b6a57574cc2bc49f1c5f2060dc56509ea.zip
tcl-4ef1119b6a57574cc2bc49f1c5f2060dc56509ea.tar.gz
tcl-4ef1119b6a57574cc2bc49f1c5f2060dc56509ea.tar.bz2
* generic/tclIO.c (BUSY_STATE, CheckChannelErrors,
TclCopyChannel): New macro, and the places using it. This change allows for bi-directional fcopy on channels. Thanks to Alexandre Ferrieux <ferrieux@users.sourceforge.net> for the patch.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclIO.c12
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index c53d21a..a489de6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-07 Andreas Kupries <andreask@activestate.com>
+
+ * generic/tclIO.c (BUSY_STATE, CheckChannelErrors,
+ TclCopyChannel): New macro, and the places using it. This change
+ allows for bi-directional fcopy on channels. Thanks to Alexandre
+ Ferrieux <ferrieux@users.sourceforge.net> for the patch.
+
2008-04-07 Reinhard Max <max@suse.de>
* generic/tclStringObj.c (Tcl_AppendFormatToObj):
diff --git a/generic/tclIO.c b/generic/tclIO.c
index eadd56b..783011f 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.137.2.2 2008/04/03 18:06:24 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.137.2.3 2008/04/07 19:42:03 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -221,6 +221,10 @@ static Tcl_ObjType tclChannelType = {
#define SET_CHANNELSTATE(objPtr, storePtr) \
((objPtr)->internalRep.otherValuePtr = (void *) (storePtr))
+#define BUSY_STATE(st,fl) \
+ ((st)->csPtr && \
+ ( (((fl)&TCL_READABLE)&&((st)->csPtr->readPtr ==(st)->topChanPtr)) || \
+ (((fl)&TCL_WRITABLE)&&((st)->csPtr->writePtr==(st)->topChanPtr))))
/*
*---------------------------------------------------------------------------
@@ -6698,7 +6702,7 @@ CheckChannelErrors(
* retrieving and transforming the data to copy.
*/
- if ((statePtr->csPtr != NULL) && ((flags & CHANNEL_RAW_MODE) == 0)) {
+ if (BUSY_STATE(statePtr,flags) && ((flags & CHANNEL_RAW_MODE) == 0)) {
Tcl_SetErrno(EBUSY);
return -1;
}
@@ -8429,14 +8433,14 @@ TclCopyChannel(
inStatePtr = inPtr->state;
outStatePtr = outPtr->state;
- if (inStatePtr->csPtr) {
+ if (BUSY_STATE(inStatePtr,TCL_READABLE)) {
if (interp) {
Tcl_AppendResult(interp, "channel \"",
Tcl_GetChannelName(inChan), "\" is busy", NULL);
}
return TCL_ERROR;
}
- if (outStatePtr->csPtr) {
+ if (BUSY_STATE(outStatePtr,TCL_WRITABLE)) {
if (interp) {
Tcl_AppendResult(interp, "channel \"",
Tcl_GetChannelName(outChan), "\" is busy", NULL);