Attachment "channel.patch" to
ticket [2849797fff]
added by
nijtmans
2009-09-23 16:40:47.
Index: generic/tclIORChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIORChan.c,v
retrieving revision 1.40
diff -u -r1.40 tclIORChan.c
--- generic/tclIORChan.c 6 Aug 2009 22:28:11 -0000 1.40
+++ generic/tclIORChan.c 23 Sep 2009 05:41:09 -0000
@@ -735,7 +735,7 @@
* Return handle as result of command.
*/
- Tcl_SetObjResult(interp, rcId);
+ Tcl_SetResult(interp, chanPtr->state->channelName, TCL_VOLATILE);
return TCL_OK;
error:
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.161
diff -u -r1.161 tclIO.c
--- generic/tclIO.c 7 Sep 2009 07:28:38 -0000 1.161
+++ generic/tclIO.c 23 Sep 2009 05:41:05 -0000
@@ -1336,6 +1336,7 @@
ChannelState *statePtr; /* The stack-level independent state info for
* the channel. */
const char *name;
+ char *tmp;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
@@ -1368,14 +1369,16 @@
*/
if (chanName != NULL) {
- char *tmp = ckalloc((unsigned) (strlen(chanName) + 1));
+ unsigned len = strlen(chanName) + 1;
+ /* make sure we allocate at least 7 bytes, so it fits for "stdout" later */
+ tmp = ckalloc((len < 7) ? 7 : len);
- statePtr->channelName = tmp;
strcpy(tmp, chanName);
} else {
- Tcl_Panic("Tcl_CreateChannel: NULL channel name");
+ tmp = ckalloc(7);
+ tmp[0] = '\0';
}
-
+ statePtr->channelName = tmp;
statePtr->flags = mask;
/*
@@ -1477,14 +1480,17 @@
*/
if ((tsdPtr->stdinChannel == NULL) && (tsdPtr->stdinInitialized == 1)) {
+ strcpy(tmp, "stdin");
Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDIN);
Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
} else if ((tsdPtr->stdoutChannel == NULL) &&
(tsdPtr->stdoutInitialized == 1)) {
+ strcpy(tmp, "stdout");
Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDOUT);
Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
} else if ((tsdPtr->stderrChannel == NULL) &&
(tsdPtr->stderrInitialized == 1)) {
+ strcpy(tmp, "stderr");
Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDERR);
Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
}
Index: doc/CrtChannel.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/CrtChannel.3,v
retrieving revision 1.43
diff -u -r1.43 CrtChannel.3
--- doc/CrtChannel.3 17 Oct 2008 10:22:25 -0000 1.43
+++ doc/CrtChannel.3 23 Sep 2009 05:40:30 -0000
@@ -127,7 +127,9 @@
.AP "const char" *channelName in
The name of this channel, such as \fBfile3\fR; must not be in use
by any other channel. Can be NULL, in which case the channel is
-created without a name.
+created without a name. If the created channel is assigned to one
+of the standard channels (stdin, stdout or stderr), the assigned
+channel name will be the name of the standard channel.
.AP ClientData instanceData in
Arbitrary one-word value to be associated with this channel. This
value is passed to procedures in \fItypePtr\fR when they are invoked.