summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--doc/CrtChannel.36
-rw-r--r--generic/tclIO.c16
-rw-r--r--generic/tclIORChan.c4
4 files changed, 25 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 385c1a7..14d612b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-11-18 Jan Nijtmans <nijtmans@users.sf.net>
+ * doc/CrtChannel.3 Fix [Bug 2849797]: channel name inconsistencies
+ * generic/tclIORChan.c as suggested by DKF
+ * generic/tclIO.c minor *** POTENTIAL INCOMPATIBILITY *** because
+ Tcl_CreateChannel() and its derivatives, now
+ sometimes ignore their "chanName" argument.
+
+2009-11-18 Jan Nijtmans <nijtmans@users.sf.net>
+
* generic/tclAsync.c Eliminate various gcc warnings (in -Wextra mode)
* generic/tclBasic.c
* generic/tclBinary.c
diff --git a/doc/CrtChannel.3 b/doc/CrtChannel.3
index c5773a1..7b1c6d7 100644
--- a/doc/CrtChannel.3
+++ b/doc/CrtChannel.3
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: CrtChannel.3,v 1.43 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: CrtChannel.3,v 1.44 2009/11/18 22:41:41 nijtmans Exp $
.so man.macros
.TH Tcl_CreateChannel 3 8.4 Tcl "Tcl Library Procedures"
.BS
@@ -127,7 +127,9 @@ can be called to perform I/O and other functions on the channel.
.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 create 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.
diff --git a/generic/tclIO.c b/generic/tclIO.c
index e8d231a..7044381 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.167 2009/11/12 17:25:18 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.168 2009/11/18 22:41:41 nijtmans Exp $
*/
#include "tclInt.h"
@@ -1332,6 +1332,7 @@ Tcl_CreateChannel(
ChannelState *statePtr; /* The stack-level independent state info for
* the channel. */
const char *name;
+ char *tmp;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
@@ -1364,14 +1365,16 @@ Tcl_CreateChannel(
*/
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;
/*
@@ -1473,14 +1476,17 @@ Tcl_CreateChannel(
*/
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);
}
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 15e41d8..f2f8e1d 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.41 2009/10/07 17:07:07 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIORChan.c,v 1.42 2009/11/18 22:41:41 nijtmans Exp $
*/
#include <tclInt.h>
@@ -735,7 +735,7 @@ TclChanCreateObjCmd(
* Return handle as result of command.
*/
- Tcl_SetObjResult(interp, rcId);
+ Tcl_SetResult(interp, chanPtr->state->channelName, TCL_VOLATILE);
return TCL_OK;
error: