Tcl Source Code

Check-in [c0b94338ed]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | potential incompatibility
Files: files | file ages | folders
SHA1: c0b94338ed879e407eaf743f782755106ec59256
User & Date: nijtmans 2009-11-18 22:41:41
References
2018-03-05
16:18 Ticket [1873ea0ee4] open channel "nul" within non-main thread on windows (not-console application) status still Open with 4 other changes artifact: ba7942e639 user: sebres
Context
2009-11-18
23:46
Fix [Bug 2883850]: pkgIndex.tcl doesn't get created with static Tcl build check-in: 39268397d9 user: nijtmans tags: trunk
22:41
Fix [Bug 2849797]: channel name inconsistencies as suggested by DKF minor *** POTENTIAL INCOMPATIBIL... check-in: c0b94338ed user: nijtmans tags: trunk, potential incompatibility
22:21
Eliminate unneccessary spaces check-in: 9ee875bb1f user: nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.









1
2
3
4
5
6
7







2009-11-18  Jan Nijtmans  <[email protected]>

	* generic/tclAsync.c  Eliminate various gcc warnings (in -Wextra mode)
	* generic/tclBasic.c
	* generic/tclBinary.c
	* generic/tclCmdAH.c
	* generic/tclCmdIL.c
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2009-11-18  Jan Nijtmans  <[email protected]>

	* 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  <[email protected]>

	* generic/tclAsync.c  Eliminate various gcc warnings (in -Wextra mode)
	* generic/tclBasic.c
	* generic/tclBinary.c
	* generic/tclCmdAH.c
	* generic/tclCmdIL.c

Changes to doc/CrtChannel.3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
123
124
125
126
127
128
129
130


131
132
133
134
135
136
137
'\"
'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
'\" Copyright (c) 1997-2000 Ajuba Solutions.
'\"
'\" 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 $
.so man.macros
.TH Tcl_CreateChannel 3 8.4 Tcl "Tcl Library Procedures"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, Tcl_GetChannelName, Tcl_GetChannelHandle, Tcl_GetChannelMode, Tcl_GetChannelBufferSize, Tcl_SetChannelBufferSize, Tcl_NotifyChannel, Tcl_BadChannelOption, Tcl_ChannelName, Tcl_ChannelVersion, Tcl_ChannelBlockModeProc, Tcl_ChannelCloseProc, Tcl_ChannelClose2Proc, Tcl_ChannelInputProc, Tcl_ChannelOutputProc, Tcl_ChannelSeekProc, Tcl_ChannelWideSeekProc, Tcl_ChannelTruncateProc, Tcl_ChannelSetOptionProc, Tcl_ChannelGetOptionProc, Tcl_ChannelWatchProc, Tcl_ChannelGetHandleProc, Tcl_ChannelFlushProc, Tcl_ChannelHandlerProc, Tcl_ChannelThreadActionProc, Tcl_IsChannelShared, Tcl_IsChannelRegistered, Tcl_CutChannel, Tcl_SpliceChannel, Tcl_IsChannelExisting, Tcl_ClearChannelHandlers, Tcl_GetChannelThread, Tcl_ChannelBuffered \- procedures for creating and manipulating channels
.SH SYNOPSIS
................................................................................
.AS "const Tcl_ChannelType" *channelName
.AP "const Tcl_ChannelType" *typePtr in
Points to a structure containing the addresses of procedures that
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.


.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.
.AP int mask in
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
whether a channel is readable and writable.
.AP Tcl_Channel channel in






|







 







|
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
'\"
'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
'\" Copyright (c) 1997-2000 Ajuba Solutions.
'\"
'\" 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.44 2009/11/18 22:41:41 nijtmans Exp $
.so man.macros
.TH Tcl_CreateChannel 3 8.4 Tcl "Tcl Library Procedures"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, Tcl_GetChannelName, Tcl_GetChannelHandle, Tcl_GetChannelMode, Tcl_GetChannelBufferSize, Tcl_SetChannelBufferSize, Tcl_NotifyChannel, Tcl_BadChannelOption, Tcl_ChannelName, Tcl_ChannelVersion, Tcl_ChannelBlockModeProc, Tcl_ChannelCloseProc, Tcl_ChannelClose2Proc, Tcl_ChannelInputProc, Tcl_ChannelOutputProc, Tcl_ChannelSeekProc, Tcl_ChannelWideSeekProc, Tcl_ChannelTruncateProc, Tcl_ChannelSetOptionProc, Tcl_ChannelGetOptionProc, Tcl_ChannelWatchProc, Tcl_ChannelGetHandleProc, Tcl_ChannelFlushProc, Tcl_ChannelHandlerProc, Tcl_ChannelThreadActionProc, Tcl_IsChannelShared, Tcl_IsChannelRegistered, Tcl_CutChannel, Tcl_SpliceChannel, Tcl_IsChannelExisting, Tcl_ClearChannelHandlers, Tcl_GetChannelThread, Tcl_ChannelBuffered \- procedures for creating and manipulating channels
.SH SYNOPSIS
................................................................................
.AS "const Tcl_ChannelType" *channelName
.AP "const Tcl_ChannelType" *typePtr in
Points to a structure containing the addresses of procedures that
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. 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.
.AP int mask in
OR-ed combination of \fBTCL_READABLE\fR and \fBTCL_WRITABLE\fR to indicate
whether a channel is readable and writable.
.AP Tcl_Channel channel in

Changes to generic/tclIO.c.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
....
1328
1329
1330
1331
1332
1333
1334

1335
1336
1337
1338
1339
1340
1341
....
1360
1361
1362
1363
1364
1365
1366
1367


1368
1369
1370
1371
1372


1373
1374

1375
1376
1377
1378
1379
1380
1381
....
1469
1470
1471
1472
1473
1474
1475

1476
1477
1478
1479

1480
1481
1482
1483

1484
1485
1486
1487
1488
1489
1490
 *
 * Copyright (c) 1998-2000 Ajuba Solutions
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * 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 $
 */

#include "tclInt.h"
#include "tclIO.h"
#include <assert.h>

/*
................................................................................
    int mask)			/* TCL_READABLE & TCL_WRITABLE to indicate if
				 * the channel is readable, writable. */
{
    Channel *chanPtr;		/* The channel structure newly created. */
    ChannelState *statePtr;	/* The stack-level independent state info for
				 * the channel. */
    const char *name;

    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    /*
     * With the change of the Tcl_ChannelType structure to use a version in
     * 8.3.2+, we have to make sure that our assumption that the structure
     * remains a binary compatible size is true.
     *
................................................................................

    /*
     * Set all the bits that are part of the stack-independent state
     * information for the channel.
     */

    if (chanName != NULL) {
	char *tmp = ckalloc((unsigned) (strlen(chanName) + 1));



	statePtr->channelName = tmp;
	strcpy(tmp, chanName);
    } else {
	Tcl_Panic("Tcl_CreateChannel: NULL channel name");


    }


    statePtr->flags = mask;

    /*
     * Set the channel to system default encoding.
     *
     * Note the strange bit of protection taking place here. If the system
     * encoding name is reported back as "binary", something weird is
................................................................................

    /*
     * Install this channel in the first empty standard channel slot, if the
     * channel was previously closed explicitly.
     */

    if ((tsdPtr->stdinChannel == NULL) && (tsdPtr->stdinInitialized == 1)) {

	Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDIN);
	Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
    } else if ((tsdPtr->stdoutChannel == NULL) &&
	    (tsdPtr->stdoutInitialized == 1)) {

	Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDOUT);
	Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
    } else if ((tsdPtr->stderrChannel == NULL) &&
	    (tsdPtr->stderrInitialized == 1)) {

	Tcl_SetStdChannel((Tcl_Channel) chanPtr, TCL_STDERR);
	Tcl_RegisterChannel(NULL, (Tcl_Channel) chanPtr);
    }
    return (Tcl_Channel) chanPtr;
}
 
/*






|







 







>







 







|
>
>

<


<
>
>

<
>







 







>




>




>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
....
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
....
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371

1372
1373

1374
1375
1376

1377
1378
1379
1380
1381
1382
1383
1384
....
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
 *
 * Copyright (c) 1998-2000 Ajuba Solutions
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * 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.168 2009/11/18 22:41:41 nijtmans Exp $
 */

#include "tclInt.h"
#include "tclIO.h"
#include <assert.h>

/*
................................................................................
    int mask)			/* TCL_READABLE & TCL_WRITABLE to indicate if
				 * the channel is readable, writable. */
{
    Channel *chanPtr;		/* The channel structure newly created. */
    ChannelState *statePtr;	/* The stack-level independent state info for
				 * the channel. */
    const char *name;
    char *tmp;
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    /*
     * With the change of the Tcl_ChannelType structure to use a version in
     * 8.3.2+, we have to make sure that our assumption that the structure
     * remains a binary compatible size is true.
     *
................................................................................

    /*
     * Set all the bits that are part of the stack-independent state
     * information for the channel.
     */

    if (chanName != NULL) {
   	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);


	strcpy(tmp, chanName);
    } else {

	tmp = ckalloc(7);
	tmp[0] = '\0';
    }

    statePtr->channelName = tmp;
    statePtr->flags = mask;

    /*
     * Set the channel to system default encoding.
     *
     * Note the strange bit of protection taking place here. If the system
     * encoding name is reported back as "binary", something weird is
................................................................................

    /*
     * Install this channel in the first empty standard channel slot, if the
     * channel was previously closed explicitly.
     */

    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);
    }
    return (Tcl_Channel) chanPtr;
}
 
/*

Changes to generic/tclIORChan.c.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
 *	See TIP #219 for the specification of this functionality.
 *
 * Copyright (c) 2004-2005 ActiveState, a divison of Sophos
 *
 * 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 $
 */

#include <tclInt.h>
#include <tclIO.h>
#include <assert.h>

#ifndef EINVAL
................................................................................
    Tcl_SetHashValue(hPtr, chan);
#endif

    /*
     * Return handle as result of command.
     */

    Tcl_SetObjResult(interp, rcId);
    return TCL_OK;

  error:
    /*
     * Signal to ReflectClose to not call 'finalize'.
     */







|







 







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
 *	See TIP #219 for the specification of this functionality.
 *
 * Copyright (c) 2004-2005 ActiveState, a divison of Sophos
 *
 * 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.42 2009/11/18 22:41:41 nijtmans Exp $
 */

#include <tclInt.h>
#include <tclIO.h>
#include <assert.h>

#ifndef EINVAL
................................................................................
    Tcl_SetHashValue(hPtr, chan);
#endif

    /*
     * Return handle as result of command.
     */

    Tcl_SetResult(interp, chanPtr->state->channelName, TCL_VOLATILE);
    return TCL_OK;

  error:
    /*
     * Signal to ReflectClose to not call 'finalize'.
     */