diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2008-12-11 17:27:38 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2008-12-11 17:27:38 (GMT) |
commit | a64e15b056ee65d6af9691dd03ac6bc730a074e5 (patch) | |
tree | 553d3544448a4e969943ddb32f8918876bd0e50d /generic/tclIO.c | |
parent | c24197d58c095fc488e34b0a72604fb43d38a129 (diff) | |
download | tcl-a64e15b056ee65d6af9691dd03ac6bc730a074e5.zip tcl-a64e15b056ee65d6af9691dd03ac6bc730a074e5.tar.gz tcl-a64e15b056ee65d6af9691dd03ac6bc730a074e5.tar.bz2 |
* generic/tclIO.c (SetChannelFromAny and related): Modified the
* tests/io.test: internal representation of the tclChannelType to
contain not only the ChannelState pointer, but also a reference to
the interpreter it was made in. Invalidate and recompute the
internal representation when it is used in a different interpreter
(Like cmdName intrep's). Added testcase. [Bug 2407783].
FossilOrigin-Name: cfad9b09d706bbf55a25ef409fd92c4601a0e85d
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 2e8b7dc..3553286 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.9 2008/12/02 18:23:51 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.137.2.10 2008/12/11 17:27:39 andreas_kupries Exp $ */ #include "tclInt.h" @@ -220,6 +220,10 @@ static Tcl_ObjType tclChannelType = { ((ChannelState *) (objPtr)->internalRep.otherValuePtr) #define SET_CHANNELSTATE(objPtr, storePtr) \ ((objPtr)->internalRep.otherValuePtr = (void *) (storePtr)) +#define GET_CHANNELINTERP(objPtr) \ + ((Interp *) (objPtr)->internalRep.twoPtrValue.ptr2) +#define SET_CHANNELINTERP(objPtr, storePtr) \ + ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (storePtr)) #define BUSY_STATE(st,fl) \ ((((st)->csPtrR) && ((fl) & TCL_READABLE)) || \ @@ -10612,8 +10616,11 @@ DupChannelIntRep( register Tcl_Obj *copyPtr) /* Object with internal rep to set. Must not * currently have an internal rep.*/ { - ChannelState *statePtr = GET_CHANNELSTATE(srcPtr); + ChannelState *statePtr = GET_CHANNELSTATE(srcPtr); + Interp *interpPtr = GET_CHANNELINTERP(srcPtr); + SET_CHANNELSTATE(copyPtr, statePtr); + SET_CHANNELINTERP(copyPtr, interpPtr); Tcl_Preserve((ClientData) statePtr); copyPtr->typePtr = &tclChannelType; } @@ -10641,18 +10648,24 @@ SetChannelFromAny( register Tcl_Obj *objPtr) /* The object to convert. */ { ChannelState *statePtr; + Interp *interpPtr; if (objPtr->typePtr == &tclChannelType) { /* * The channel is valid until any call to DetachChannel occurs. * Ensure consistency checks are done. */ - statePtr = GET_CHANNELSTATE(objPtr); + statePtr = GET_CHANNELSTATE(objPtr); + interpPtr = GET_CHANNELINTERP(objPtr); if (statePtr->flags & (CHANNEL_TAINTED|CHANNEL_CLOSED)) { ResetFlag(statePtr, CHANNEL_TAINTED); Tcl_Release((ClientData) statePtr); UpdateStringOfChannel(objPtr); objPtr->typePtr = NULL; + } else if (interpPtr != (Interp*) interp) { + Tcl_Release((ClientData) statePtr); + UpdateStringOfChannel(objPtr); + objPtr->typePtr = NULL; } } if (objPtr->typePtr != &tclChannelType) { @@ -10675,6 +10688,7 @@ SetChannelFromAny( statePtr = ((Channel *)chan)->state; Tcl_Preserve((ClientData) statePtr); SET_CHANNELSTATE(objPtr, statePtr); + SET_CHANNELINTERP(objPtr, interp); objPtr->typePtr = &tclChannelType; } return TCL_OK; |