summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2009-11-18 22:41:41 (GMT)
committernijtmans <nijtmans>2009-11-18 22:41:41 (GMT)
commitb57c08b7e2ccf91e1096b30f2170d2f603f59e0c (patch)
tree01d099afa4749afee67d0a99e9e442dcebb9cc45 /generic
parenta9191c772b1a15d5f705b2d4fa807388370ac0f8 (diff)
downloadtcl-b57c08b7e2ccf91e1096b30f2170d2f603f59e0c.zip
tcl-b57c08b7e2ccf91e1096b30f2170d2f603f59e0c.tar.gz
tcl-b57c08b7e2ccf91e1096b30f2170d2f603f59e0c.tar.bz2
Fix [Bug 2849797]: channel name inconsistencies as suggested by DKF
minor *** POTENTIAL INCOMPATIBILITY *** because Tcl_CreateChannel() and its derivatives, now sometimes ignore their "chanName" argument.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c16
-rw-r--r--generic/tclIORChan.c4
2 files changed, 13 insertions, 7 deletions
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: