Tcl Source Code

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

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

Overview
Comment:
[kennykb-numerics-branch] Merge updates from HEAD
* generic/tclExecute.c: Bug fix. INST_*SHIFT* opcodes stack management. [expr 0<<6] should be 0, not 6.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | kennykb-numerics-branch
Files: files | file ages | folders
SHA1:6d651867f939300a4c15febd52fef1dac6f06733
User & Date: dgp 2005-08-25 15:46:30
Context
2005-08-25
21:21
[kennykb-numerics-branch]
* generic/tclExecute.c: Bug fix. INST_RSHIFT: shift of n...
check-in: 0e9fcc9b56 user: dgp tags: kennykb-numerics-branch
15:46
[kennykb-numerics-branch] Merge updates from HEAD
* generic/tclExecute.c: Bug fix. ...
check-in: 6d651867f9 user: dgp tags: kennykb-numerics-branch
14:58
[kennykb-numerics-branch]
* generic/tclBasic.c: Extended the domain of round(.) t...
check-in: 9bfc46124e user: dgp tags: kennykb-numerics-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.







1
2
3
4



5
6



































7
8
9
10
11
12
13
..
31
32
33
34
35
36
37







38
39
40
41
42
43
44
..
90
91
92
93
94
95
96




97
98
99
100
101
102
103
...
185
186
187
188
189
190
191

















192
193
194
195
196
197
198
...
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374






2005-08-25  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]




	* generic/tclBasic.c:	Extended the domain of round(.) to all
	non-Inf, non-NaN doubles, using bignums for the result as needed.




































2005-08-24  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclExecute.c: Corrected some TRACE bugs that prevented
	compilation with --enable-symbols=all.
................................................................................

	* generic/tclExecute.c:	Bug fix: TclBignumToDouble return -Inf when
	appropriate.  Removed declarations of removed routines.

	* generic/tclExecute.c:	Revised the type promotion rules of the
	comparison operators so that they form proper equivalence classes
	over the set of numeric strings.








2005-08-23  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]
	
	* generic/tclCmdMZ.c (Tcl_StringObjCmd):
	* generic/tclInt.h:
................................................................................

	* generic/tclInt.h:	New internal macros TclIsNaN and TclIsInfinite
	* generic/tclBasic.c:	replace the IS_NAN and IS_INF macros scattered
	* generic/tclExecute.c:	here and there.
	* generic/tclObj.c:
	* generic/tclStrToD.c:
	* generic/tclUtil.c:





2005-08-22  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclInt.h:	New ACCEPT_NAN macro to mark code that supports
	* generic/tclCmdAH.c:	or disables accepting of the NaN value at 
................................................................................
	* generic/tclExecute.c:		Fixed string rep invalidation bug in
	* tests/dict.test (dict-11.17):	INST_DICT_INCR_IMM rewrite.

	* generic/tclDictObj.c:	DictIncrCmd rewrite to use TclIncrObj.

	* generic/tclInt.h:	TclIncrObj static -> internal
	* generic/tclExecute.c:


















2005-08-17  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclBasic.c (Tcl_Expr{Long,Double}{,Obj}): Updated to
	* generic/tclTest.c:                                deal with
................................................................................
	(Note that we'll still see aborts if an unloaded DLL has TSD -
	that still needs to be fixed.

	* tests/compExpr-old.test (compExpr-3.8): Made tests conditional on
	* tests/expr.test (expr-3.8):             'unix' because they get
	                                          stack overflows on Win32
	                                          threaded builds,
	
2005-08-09  Vince Darley  <vincentdarley@users.sourceforge.net>

	* generic/tclPathObj.c: fix to [file rootname] bug in optimized
	code path reported on comp.lang.tcl.

2005-08-08  Don Porter  <dgp@users.sourceforge.net>

>
>
>
>
>
>


|

>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
2005-08-25  Donal K. Fellows  <donal.k.fellows@man.ac.uk>

	* generic/tclExecute.c (TEBC:INST_DICT_LAPPEND): Stop dropping a
	duplicated object on the floor, which was a memory leak (and a wrong
	result too). Thanks to Andreas Kupries for reporting this.

2005-08-25  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch] Merge updates from HEAD

	* generic/tclExecute.c:	Bug fix.  INST_*SHIFT* opcodes stack
	management. [expr 0<<6] should be 0, not 6.

	* generic/tclBasic.c:	Extended the domain of round(.) to all
	non-Inf, non-NaN doubles, using bignums for the result as needed.

2005-08-24  Andreas Kupries <andreask@activestate.com>

	TIP#219 IMPLEMENTATION

	* doc/SetChanErr.3: ** New File **. Documentation of the new
	  channel API functions.
	* generic/tcl.decls:  Stub declarations of the new channel API.
	* generic/tclDecls.h: Regenerated
	* generic/tclStubInit.c:

	* tclIORChan.c: ** New File **. Implementation of the reflected
	  channel.
	* generic/tclInt.h: Integration of reflected channel and new error
	* generic/tclIO.c:  propagation into the generic I/O core.
	* generic/tclIOCmd.c:
	* generic/tclIO.h:
	* library/init.tcl:

	* tests/io.test:    Extended testsuite.
	* tests/ioCmd.test:
	* tests/chan.test:
	* generic/tclTest.c:
	* generic/tclThreadTest.c:

	* unix/Makefile.in: Integration into the build machinery.
	* win/Makefile.in:
	* win/Makefile.vc:

2005-08-24  Kevin Kenny  <kennykb@acm.org>

	* generic/tclStrToD.c (Tcl_DoubleDigits): Fixed the corner cases of
	* tests/binary.test (binary-65.*)         formatting floating
	point numbers with the largest and smallest possible significands,
	and added test cases for them.

2005-08-24  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclExecute.c: Corrected some TRACE bugs that prevented
	compilation with --enable-symbols=all.
................................................................................

	* generic/tclExecute.c:	Bug fix: TclBignumToDouble return -Inf when
	appropriate.  Removed declarations of removed routines.

	* generic/tclExecute.c:	Revised the type promotion rules of the
	comparison operators so that they form proper equivalence classes
	over the set of numeric strings.

2005-08-23  Mo DeJong  <mdejong@users.sourceforge.net>

	* unix/configure.in:
	* win/configure: Regen.
	* win/configure.in: Update minimum autoconf version
	to 2.59.

2005-08-23  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]
	
	* generic/tclCmdMZ.c (Tcl_StringObjCmd):
	* generic/tclInt.h:
................................................................................

	* generic/tclInt.h:	New internal macros TclIsNaN and TclIsInfinite
	* generic/tclBasic.c:	replace the IS_NAN and IS_INF macros scattered
	* generic/tclExecute.c:	here and there.
	* generic/tclObj.c:
	* generic/tclStrToD.c:
	* generic/tclUtil.c:

2005-08-22  Daniel Steffen  <das@users.sourceforge.net>

	* unix/tclConfig.h.in: autoheader-2.59.

2005-08-22  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclInt.h:	New ACCEPT_NAN macro to mark code that supports
	* generic/tclCmdAH.c:	or disables accepting of the NaN value at 
................................................................................
	* generic/tclExecute.c:		Fixed string rep invalidation bug in
	* tests/dict.test (dict-11.17):	INST_DICT_INCR_IMM rewrite.

	* generic/tclDictObj.c:	DictIncrCmd rewrite to use TclIncrObj.

	* generic/tclInt.h:	TclIncrObj static -> internal
	* generic/tclExecute.c:

2005-08-17  George Peter Staplin <GeorgePS@XMission.com>

	* generic/tclBasic.c: eliminate a namespace clash caused by
	BuiltinFuncTable not being static.

	* generic/tclObj.c: fix a namespace clash caused by a missing
	static for pendingObjData.

2005-08-17  Kevin Kenny  <kennykb@acm.org>

	* generic/tclEvent.c (Tcl_Finalize): Removed a copy-and-paste
	accident that caused a (mostly harmless) double finalize of the
	load and filesystem subsystems.
	* tests/clock.test: Eliminated the bad test clock-43.1, and split
	clock-50.1 into two tests, with a more permissive check on the
	error message for an out-of-range value.

2005-08-17  Kevin Kenny  <kennykb@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclBasic.c (Tcl_Expr{Long,Double}{,Obj}): Updated to
	* generic/tclTest.c:                                deal with
................................................................................
	(Note that we'll still see aborts if an unloaded DLL has TSD -
	that still needs to be fixed.

	* tests/compExpr-old.test (compExpr-3.8): Made tests conditional on
	* tests/expr.test (expr-3.8):             'unix' because they get
	                                          stack overflows on Win32
	                                          threaded builds,

2005-08-09  Vince Darley  <vincentdarley@users.sourceforge.net>

	* generic/tclPathObj.c: fix to [file rootname] bug in optimized
	code path reported on comp.lang.tcl.

2005-08-08  Don Porter  <dgp@users.sourceforge.net>

Added doc/SetChanErr.3.























































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
'\"
'\" Copyright (c) 2005 Andreas Kupries <andreas_kupries@users.sourceforge.net>
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" RCS: @(#) $Id: SetChanErr.3,v 1.1.2.2 2005/08/25 15:46:30 dgp Exp $
.so man.macros
.TH Tcl_SetChannelError 3 8.5 Tcl "Tcl Library Procedures"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_SetChannelError, Tcl_SetChannelErrorInterp, Tcl_GetChannelError, Tcl_GetChannelErrorInterp \- functions to create/intercept Tcl errors by channel drivers.
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
void
\fBTcl_SetChannelError\fR(\fIchan, msg\fR)
.sp
void
\fBTcl_SetChannelErrorInterp\fR(\fIinterp, msg\fR)
.sp
void
\fBTcl_GetChannelError\fR(\fIchan, msgPtr\fR)
.sp
void
\fBTcl_GetChannelErrorInterp\fR(\fIinterp, msgPtr\fR)
.sp
.SH ARGUMENTS
.AS Tcl_Channel chan
.AP Tcl_Channel chan in
Refers to the Tcl channel whose bypass area is accessed.
.AP Tcl_Interp* interp in
Refers to the Tcl interpreter whose bypass area is accessed.
.AP Tcl_Obj* msg in
Error message put into a bypass area.  A list of return options and
values, followed by a string message.  Both message and the
option/value information are optional.
.AP Tcl_Obj** msgPtr out
Reference to a place where the message stored in the accessed bypass
area can be stored in.
.BE
.SH DESCRIPTION
.PP
The current definition of a Tcl channel driver does not permit the
direct return of arbitrary error messages, except for the setting and
retrieval of channel options. All other functions are restricted to
POSIX error codes.
.PP
The functions described here overcome this limitation. Channel drivers
are allowed to use \fBTcl_SetChannelError\fR and
\fBTcl_SetChannelErrorInterp\fR to place arbitrary error messages in
\fBbypass areas\fI defined for channels and interpreters. And the
generic I/O layer uses \fBTcl_GetChannelError\fR and
\fBTcl_GetChannelErrorInterp\fR to look for messages in the bypass
areas and arrange for their return as errors. The posix error codes
set by a driver are used now if and only if no messages are present.
.PP
\fBTcl_SetChannelError\fR stores error information in the bypass area
of the specified channel. The number of references to the \fBmsg\fI
object goes up by one. Previously stored information will be
discarded, by releasing the reference held by the channel. The channel
reference must not be NULL.
.PP
\fBTcl_SetChannelErrorInterp\fR stores error information in the bypass
area of the specified interpreter. The number of references to the
\fBmsg\fI object goes up by one. Previously stored information will be
discarded, by releasing the reference held by the interpreter. The
interpreter reference must not be NULL.
.PP
\fBTcl_GetChannelError\fR places either the error message held in the
bypass area of the specified channel into \fImsgPtr\fR, or NULL; and
resets the bypass. I.e. after an invokation all following invokations
will return NULL, until an intervening invokation of
\fBTcl_SetChannelError\fR with a non-NULL message. The \fImsgPtr\fR
must not be NULL. The reference count of the message is not touched.
The reference previously held by the channel is now held by the caller
of the function and it is its responsibility to release that reference
when it is done with the object.
.PP
\fBTcl_GetChannelErrorInterp\fR places either the error message held
in the bypass area of the specified interpreter into \fImsgPtr\fR, or
NULL; and resets the bypass. I.e. after an invokation all following
invokations will return NULL, until an intervening invokation of
\fBTcl_SetChannelErrorInterp\fR with a non-NULL message. The
\fImsgPtr\fR must not be NULL. The reference count of the message is
not touched.  The reference previously held by the interpreter is now
held by the caller of the function and it is its responsibility to
release that reference when it is done with the object.
.PP
Which functions of a channel driver are allowed to use which bypass
function is listed below, as is which functions of the public channel
API may leave a messages in the bypass areas.
.PP
.IP \fBTcl_DriverCloseProc\fR
May use \fBTcl_SetChannelErrorInterp\fR, and only this function.
.IP \fBTcl_DriverInputProc\fR
May use \fBTcl_SetChannelError\fR, and only this function.
.IP \fBTcl_DriverOutputProc\fR
May use \fBTcl_SetChannelError\fR, and only this function.
.IP \fBTcl_DriverSeekProc\fR
May use \fBTcl_SetChannelError\fR, and only this function.
.IP \fBTcl_DriverWideSeekProc
May use \fBTcl_SetChannelError\fR, and only this function.
.IP \fBTcl_DriverSetOptionProc\fR
Has already the ability to pass arbitrary error messages. Must
\fBnot\fR use any of the new functions.
.IP \fBTcl_DriverGetOptionProc\fR
Has already the ability to pass arbitrary error messages. Must
\fBnot\fR use any of the new functions.
.IP \fBTcl_DriverWatchProc\fR
Must \fBnot\fR use any of the new functions. Is internally called and
has no ability to return any type of error whatsoever.
.IP \fBTcl_DriverBlockModeProc\fR
May use \fBTcl_SetChannelError\fR, and only this function.
.IP \fBTcl_DriverGetHandleProc\fR
Must \fBnot\fR use any of the new functions. It is only a low-level
function, and not used by Tcl commands.
.IP \fBTcl_DriverHandlerProc\fR
Must \fBnot\fR use any of the new functions. Is internally called and
has no ability to return any type of error whatsoever.
.PP
Given the information above the following public functions of the Tcl
C API are affected by these changes. I.e. when these functions are
called the channel may now contain a stored arbitrary error message
requiring processing by the caller.
.PP
.IP \fBTcl_StackChannel\fR
.IP \fBTcl_Seek\fR
.IP \fBTcl_Tell\fR
.IP \fBTcl_ReadRaw\fR
.IP \fBTcl_Read\fR
.IP \fBTcl_ReadChars\fR
.IP \fBTcl_Gets\fR
.IP \fBTcl_GetsObj\fR
.IP \fBTcl_Flush\fR
.IP \fBTcl_WriteRaw\fR
.IP \fBTcl_WriteObj\fR
.IP \fBTcl_Write\fR
.IP \fBTcl_WriteChars\fR
.PP
All other API functions are unchanged. Especially the functions below
leave all their error information in the interpreter result.
.PP
.IP \fBTcl_Close\fR
.IP \fBTcl_UnregisterChannel\fR
.IP \fBTcl_UnstackChannel\fR
.PP

.SH "SEE ALSO"
Tcl_Close(3), Tcl_OpenFileChannel(3), Tcl_SetErrno(3)

.SH KEYWORDS
channel driver, error messages, channel type

Changes to generic/tcl.decls.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
2008
2009
2010
2011
2012
2013
2014















2015
2016
2017
2018
2019
2020
2021
#	
#
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# RCS: @(#) $Id: tcl.decls,v 1.105.2.7 2005/07/12 20:36:17 kennykb Exp $

library tcl

# Define the tcl interface with several sub interfaces:
#     tclPlat	 - platform specific public
#     tclInt	 - generic private
#     tclPlatInt - platform specific private
................................................................................
declare 559 generic {
    int Tcl_TruncateChannel(Tcl_Channel chan, Tcl_WideInt length)
}
declare 560 generic {
    Tcl_DriverTruncateProc *Tcl_ChannelTruncateProc(
	    Tcl_ChannelType *chanTypePtr)
}
















##############################################################################

# Define the platform specific public Tcl interface.  These functions are
# only available on the designated platform.

interface tclPlat







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
#	
#
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# RCS: @(#) $Id: tcl.decls,v 1.105.2.8 2005/08/25 15:46:30 dgp Exp $

library tcl

# Define the tcl interface with several sub interfaces:
#     tclPlat	 - platform specific public
#     tclInt	 - generic private
#     tclPlatInt - platform specific private
................................................................................
declare 559 generic {
    int Tcl_TruncateChannel(Tcl_Channel chan, Tcl_WideInt length)
}
declare 560 generic {
    Tcl_DriverTruncateProc *Tcl_ChannelTruncateProc(
	    Tcl_ChannelType *chanTypePtr)
}

# TIP#219 (Tcl Channel Reflection API) akupries

declare 561 generic {
    void Tcl_SetChannelErrorInterp (Tcl_Interp* interp, Tcl_Obj* msg)
}
declare 562 generic {
    void Tcl_GetChannelErrorInterp (Tcl_Interp* interp, Tcl_Obj** msg)
}
declare 563 generic {
    void Tcl_SetChannelError (Tcl_Channel chan, Tcl_Obj* msg)
}
declare 564 generic {
    void Tcl_GetChannelError (Tcl_Channel chan, Tcl_Obj** msg)
}

##############################################################################

# Define the platform specific public Tcl interface.  These functions are
# only available on the designated platform.

interface tclPlat

Changes to generic/tclBasic.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
396
397
398
399
400
401
402



403
404
405
406
407
408
409
...
522
523
524
525
526
527
528

529
530
531








532
533
534
535
536
537
538
...
966
967
968
969
970
971
972









973
974
975
976
977
978
979
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclBasic.c,v 1.136.2.28 2005/08/25 14:58:07 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include <float.h>
#include <math.h>
#include "tommath.h"
................................................................................
 */

typedef struct {
    CONST char* name;		/* Name of the function */
    Tcl_ObjCmdProc* objCmdProc;	/* Procedure that evaluates the function */
    ClientData clientData;	/* Client data for the procedure */
} BuiltinFuncDef;
BuiltinFuncDef BuiltinFuncTable[] = {
    { "::tcl::mathfunc::abs",	ExprAbsFunc,	NULL 			},
    { "::tcl::mathfunc::acos",	ExprUnaryFunc,	(ClientData) acos 	},
    { "::tcl::mathfunc::asin",	ExprUnaryFunc,	(ClientData) asin 	},
    { "::tcl::mathfunc::atan",	ExprUnaryFunc,	(ClientData) atan 	},
    { "::tcl::mathfunc::atan2",	ExprBinaryFunc,	(ClientData) atan2 	},
    { "::tcl::mathfunc::bool",	ExprBoolFunc,	NULL			},
    { "::tcl::mathfunc::ceil",	ExprCeilFunc,	NULL		 	},
................................................................................
     * TclCreateExecEnv after initializing namespaces since it tries to
     * reference a Tcl variable (it links to the Tcl "tcl_traceExec"
     * variable).
     */

    iPtr->execEnvPtr = TclCreateExecEnv(interp);




    /*
     * Initialize the compilation and execution statistics kept for this
     * interpreter.
     */

#ifdef TCL_COMPILE_STATS
    statsPtr = &(iPtr->stats);
................................................................................
	    (Tcl_CmdDeleteProc*) NULL);
    Tcl_CreateObjCommand(interp,	"::tcl::clock::Mktime",
	    TclClockMktimeObjCmd,	(ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);
    Tcl_CreateObjCommand(interp,	"::tcl::clock::Oldscan",
	    TclClockOldscanObjCmd,	(ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);

    Tcl_CreateObjCommand(interp, "::tcl::chan::Truncate",
	    TclChanTruncateObjCmd, (ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);









    /*
     * Register the built-in functions
     */


    /* Register the default [interp bgerror] handler. */
................................................................................
    /*
     * Mark the interpreter as deleted. No further evals will be allowed.
     * Increase the compileEpoch as a signal to compiled bytecodes.
     */

    iPtr->flags |= DELETED;
    iPtr->compileEpoch++;










    /*
     * Ensure that the interpreter is eventually deleted.
     */

    Tcl_EventuallyFree((ClientData) interp, (Tcl_FreeProc *) DeleteInterpProc);
}







|







 







|







 







>
>
>







 







>



>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
...
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
...
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclBasic.c,v 1.136.2.29 2005/08/25 15:46:30 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include <float.h>
#include <math.h>
#include "tommath.h"
................................................................................
 */

typedef struct {
    CONST char* name;		/* Name of the function */
    Tcl_ObjCmdProc* objCmdProc;	/* Procedure that evaluates the function */
    ClientData clientData;	/* Client data for the procedure */
} BuiltinFuncDef;
static BuiltinFuncDef BuiltinFuncTable[] = {
    { "::tcl::mathfunc::abs",	ExprAbsFunc,	NULL 			},
    { "::tcl::mathfunc::acos",	ExprUnaryFunc,	(ClientData) acos 	},
    { "::tcl::mathfunc::asin",	ExprUnaryFunc,	(ClientData) asin 	},
    { "::tcl::mathfunc::atan",	ExprUnaryFunc,	(ClientData) atan 	},
    { "::tcl::mathfunc::atan2",	ExprBinaryFunc,	(ClientData) atan2 	},
    { "::tcl::mathfunc::bool",	ExprBoolFunc,	NULL			},
    { "::tcl::mathfunc::ceil",	ExprCeilFunc,	NULL		 	},
................................................................................
     * TclCreateExecEnv after initializing namespaces since it tries to
     * reference a Tcl variable (it links to the Tcl "tcl_traceExec"
     * variable).
     */

    iPtr->execEnvPtr = TclCreateExecEnv(interp);

    /* TIP #219, Tcl Channel Reflection API */
    iPtr->chanMsg  = NULL;

    /*
     * Initialize the compilation and execution statistics kept for this
     * interpreter.
     */

#ifdef TCL_COMPILE_STATS
    statsPtr = &(iPtr->stats);
................................................................................
	    (Tcl_CmdDeleteProc*) NULL);
    Tcl_CreateObjCommand(interp,	"::tcl::clock::Mktime",
	    TclClockMktimeObjCmd,	(ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);
    Tcl_CreateObjCommand(interp,	"::tcl::clock::Oldscan",
	    TclClockOldscanObjCmd,	(ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);
    /* TIP #208 */
    Tcl_CreateObjCommand(interp, "::tcl::chan::Truncate",
	    TclChanTruncateObjCmd, (ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);
    /* TIP #219 */
    Tcl_CreateObjCommand(interp, "::tcl::chan::rCreate",
	    TclChanCreateObjCmd, (ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);

    Tcl_CreateObjCommand(interp, "::tcl::chan::rPostevent",
	    TclChanPostEventObjCmd, (ClientData) NULL,
	    (Tcl_CmdDeleteProc*) NULL);

    /*
     * Register the built-in functions
     */


    /* Register the default [interp bgerror] handler. */
................................................................................
    /*
     * Mark the interpreter as deleted. No further evals will be allowed.
     * Increase the compileEpoch as a signal to compiled bytecodes.
     */

    iPtr->flags |= DELETED;
    iPtr->compileEpoch++;

    /* TIP #219, Tcl Channel Reflection API.
     * Discard a leftover state.
     */

    if (iPtr->chanMsg != NULL) {
        Tcl_DecrRefCount (iPtr->chanMsg);
	iPtr->chanMsg = NULL;
    }

    /*
     * Ensure that the interpreter is eventually deleted.
     */

    Tcl_EventuallyFree((ClientData) interp, (Tcl_FreeProc *) DeleteInterpProc);
}

Changes to generic/tclDecls.h.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
3492
3493
3494
3495
3496
3497
3498
























3499
3500
3501
3502
3503
3504
3505
....
4094
4095
4096
4097
4098
4099
4100




4101
4102
4103
4104
4105
4106
4107
....
6378
6379
6380
6381
6382
6383
6384
















6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
 *	Declarations of functions in the platform independent public Tcl API.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclDecls.h,v 1.107.2.6 2005/07/12 20:36:25 kennykb Exp $
 */

#ifndef _TCLDECLS
#define _TCLDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
................................................................................
#endif
#ifndef Tcl_ChannelTruncateProc_TCL_DECLARED
#define Tcl_ChannelTruncateProc_TCL_DECLARED
/* 560 */
EXTERN Tcl_DriverTruncateProc * Tcl_ChannelTruncateProc _ANSI_ARGS_((
				Tcl_ChannelType * chanTypePtr));
#endif

























typedef struct TclStubHooks {
    struct TclPlatStubs *tclPlatStubs;
    struct TclIntStubs *tclIntStubs;
    struct TclIntPlatStubs *tclIntPlatStubs;
} TclStubHooks;

................................................................................
    Tcl_DriverThreadActionProc * (*tcl_ChannelThreadActionProc) _ANSI_ARGS_((Tcl_ChannelType * chanTypePtr)); /* 554 */
    Tcl_Obj* (*tcl_NewBignumObj) _ANSI_ARGS_((mp_int* value)); /* 555 */
    Tcl_Obj* (*tcl_DbNewBignumObj) _ANSI_ARGS_((mp_int* value, CONST char* file, int line)); /* 556 */
    void (*tcl_SetBignumObj) _ANSI_ARGS_((Tcl_Obj* obj, mp_int* value)); /* 557 */
    int (*tcl_GetBignumFromObj) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj* obj, mp_int* value)); /* 558 */
    int (*tcl_TruncateChannel) _ANSI_ARGS_((Tcl_Channel chan, Tcl_WideInt length)); /* 559 */
    Tcl_DriverTruncateProc * (*tcl_ChannelTruncateProc) _ANSI_ARGS_((Tcl_ChannelType * chanTypePtr)); /* 560 */




} TclStubs;

#ifdef __cplusplus
extern "C" {
#endif
extern TclStubs *tclStubsPtr;
#ifdef __cplusplus
................................................................................
#define Tcl_TruncateChannel \
	(tclStubsPtr->tcl_TruncateChannel) /* 559 */
#endif
#ifndef Tcl_ChannelTruncateProc
#define Tcl_ChannelTruncateProc \
	(tclStubsPtr->tcl_ChannelTruncateProc) /* 560 */
#endif

















#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */

/* !END!: Do not edit above this line. */

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

#endif /* _TCLDECLS */








|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
....
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
....
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
....
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
 *	Declarations of functions in the platform independent public Tcl API.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclDecls.h,v 1.107.2.7 2005/08/25 15:46:30 dgp Exp $
 */

#ifndef _TCLDECLS
#define _TCLDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
................................................................................
#endif
#ifndef Tcl_ChannelTruncateProc_TCL_DECLARED
#define Tcl_ChannelTruncateProc_TCL_DECLARED
/* 560 */
EXTERN Tcl_DriverTruncateProc * Tcl_ChannelTruncateProc _ANSI_ARGS_((
				Tcl_ChannelType * chanTypePtr));
#endif
#ifndef Tcl_SetChannelErrorInterp_TCL_DECLARED
#define Tcl_SetChannelErrorInterp_TCL_DECLARED
/* 561 */
EXTERN void		Tcl_SetChannelErrorInterp _ANSI_ARGS_((
				Tcl_Interp* interp, Tcl_Obj* msg));
#endif
#ifndef Tcl_GetChannelErrorInterp_TCL_DECLARED
#define Tcl_GetChannelErrorInterp_TCL_DECLARED
/* 562 */
EXTERN void		Tcl_GetChannelErrorInterp _ANSI_ARGS_((
				Tcl_Interp* interp, Tcl_Obj** msg));
#endif
#ifndef Tcl_SetChannelError_TCL_DECLARED
#define Tcl_SetChannelError_TCL_DECLARED
/* 563 */
EXTERN void		Tcl_SetChannelError _ANSI_ARGS_((Tcl_Channel chan, 
				Tcl_Obj* msg));
#endif
#ifndef Tcl_GetChannelError_TCL_DECLARED
#define Tcl_GetChannelError_TCL_DECLARED
/* 564 */
EXTERN void		Tcl_GetChannelError _ANSI_ARGS_((Tcl_Channel chan, 
				Tcl_Obj** msg));
#endif

typedef struct TclStubHooks {
    struct TclPlatStubs *tclPlatStubs;
    struct TclIntStubs *tclIntStubs;
    struct TclIntPlatStubs *tclIntPlatStubs;
} TclStubHooks;

................................................................................
    Tcl_DriverThreadActionProc * (*tcl_ChannelThreadActionProc) _ANSI_ARGS_((Tcl_ChannelType * chanTypePtr)); /* 554 */
    Tcl_Obj* (*tcl_NewBignumObj) _ANSI_ARGS_((mp_int* value)); /* 555 */
    Tcl_Obj* (*tcl_DbNewBignumObj) _ANSI_ARGS_((mp_int* value, CONST char* file, int line)); /* 556 */
    void (*tcl_SetBignumObj) _ANSI_ARGS_((Tcl_Obj* obj, mp_int* value)); /* 557 */
    int (*tcl_GetBignumFromObj) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj* obj, mp_int* value)); /* 558 */
    int (*tcl_TruncateChannel) _ANSI_ARGS_((Tcl_Channel chan, Tcl_WideInt length)); /* 559 */
    Tcl_DriverTruncateProc * (*tcl_ChannelTruncateProc) _ANSI_ARGS_((Tcl_ChannelType * chanTypePtr)); /* 560 */
    void (*tcl_SetChannelErrorInterp) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj* msg)); /* 561 */
    void (*tcl_GetChannelErrorInterp) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj** msg)); /* 562 */
    void (*tcl_SetChannelError) _ANSI_ARGS_((Tcl_Channel chan, Tcl_Obj* msg)); /* 563 */
    void (*tcl_GetChannelError) _ANSI_ARGS_((Tcl_Channel chan, Tcl_Obj** msg)); /* 564 */
} TclStubs;

#ifdef __cplusplus
extern "C" {
#endif
extern TclStubs *tclStubsPtr;
#ifdef __cplusplus
................................................................................
#define Tcl_TruncateChannel \
	(tclStubsPtr->tcl_TruncateChannel) /* 559 */
#endif
#ifndef Tcl_ChannelTruncateProc
#define Tcl_ChannelTruncateProc \
	(tclStubsPtr->tcl_ChannelTruncateProc) /* 560 */
#endif
#ifndef Tcl_SetChannelErrorInterp
#define Tcl_SetChannelErrorInterp \
	(tclStubsPtr->tcl_SetChannelErrorInterp) /* 561 */
#endif
#ifndef Tcl_GetChannelErrorInterp
#define Tcl_GetChannelErrorInterp \
	(tclStubsPtr->tcl_GetChannelErrorInterp) /* 562 */
#endif
#ifndef Tcl_SetChannelError
#define Tcl_SetChannelError \
	(tclStubsPtr->tcl_SetChannelError) /* 563 */
#endif
#ifndef Tcl_GetChannelError
#define Tcl_GetChannelError \
	(tclStubsPtr->tcl_GetChannelError) /* 564 */
#endif

#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */

/* !END!: Do not edit above this line. */

#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

#endif /* _TCLDECLS */

Changes to generic/tclEvent.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 2004 by Zoran Vasiljevic.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclEvent.c,v 1.54.2.7 2005/08/15 18:13:58 dgp Exp $
 */

#include "tclInt.h"

/*
 * The data structure below is used to report background errors.  One such
 * structure is allocated for each error; it holds information about the
................................................................................
	 */

	TclFinalizeSynchronization();

#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
	TclFinalizeThreadAlloc();
#endif
	/*
	 * We defer unloading of packages until very late to avoid memory
	 * access issues.  Both exit callbacks and synchronization variables
	 * may be stored in packages.
	 * 
	 * Note that TclFinalizeLoad unloads packages in the reverse of the
	 * order they were loaded in (i.e. last to be loaded is the first to
	 * be unloaded).  This can be important for correct unloading when
	 * dependencies exist.
	 * 
	 * Once load has been finalized, we will have deleted any temporary
	 * copies of shared libraries and can therefore reset the filesystem
	 * to its original state.
	 */

	TclFinalizeLoad();
	TclResetFilesystem();

	/*
	 * We defer unloading of packages until very late to avoid memory
	 * access issues.  Both exit callbacks and synchronization variables
	 * may be stored in packages.
	 * 
	 * Note that TclFinalizeLoad unloads packages in the reverse of the
	 * order they were loaded in (i.e. last to be loaded is the first to







|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
950
951
952
953
954
955
956


















957
958
959
960
961
962
963
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 2004 by Zoran Vasiljevic.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclEvent.c,v 1.54.2.8 2005/08/25 15:46:30 dgp Exp $
 */

#include "tclInt.h"

/*
 * The data structure below is used to report background errors.  One such
 * structure is allocated for each error; it holds information about the
................................................................................
	 */

	TclFinalizeSynchronization();

#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
	TclFinalizeThreadAlloc();
#endif


















	/*
	 * We defer unloading of packages until very late to avoid memory
	 * access issues.  Both exit callbacks and synchronization variables
	 * may be stored in packages.
	 * 
	 * Note that TclFinalizeLoad unloads packages in the reverse of the
	 * order they were loaded in (i.e. last to be loaded is the first to

Changes to generic/tclExecute.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
....
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclExecute.c,v 1.167.2.36 2005/08/24 18:56:32 kennykb Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................
	    goto checkForCatch;
	}
	mp_clear(&big2);
	if (mp_iszero(&big1)) {
	    /* Zero shifted any integral number of bits either way is zero */
	    mp_clear(&big1);
	    TRACE(("0 %s => 0\n", O2S(value2Ptr)));
	    NEXT_INST_F(1, 0, 0);
	}
	result = Tcl_GetIntFromObj(NULL, value2Ptr, &shift);
	if (result != TCL_OK) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "integer value too large to represent", -1));
	    goto checkForCatch;
	}
................................................................................
	case INST_DICT_LAPPEND:
	    /*
	     * More complex because list-append can fail.
	     */
	    if (valPtr == NULL) {
		valPtr = Tcl_NewListObj(1, tosPtr);
	    } else if (Tcl_IsShared(valPtr)) {
		Tcl_Obj *dupPtr = Tcl_DuplicateObj(valPtr);

		result = Tcl_ListObjAppendElement(interp, dupPtr, *tosPtr);
		if (result != TCL_OK) {
		    Tcl_DecrRefCount(dupPtr);
		    if (allocateDict) {
			Tcl_DecrRefCount(dictPtr);
		    }
		    goto checkForCatch;
		}
	    } else {
		result = Tcl_ListObjAppendElement(interp, valPtr, *tosPtr);







|







 







|







 







|
<
|

|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
....
5871
5872
5873
5874
5875
5876
5877
5878

5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclExecute.c,v 1.167.2.37 2005/08/25 15:46:30 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................
	    goto checkForCatch;
	}
	mp_clear(&big2);
	if (mp_iszero(&big1)) {
	    /* Zero shifted any integral number of bits either way is zero */
	    mp_clear(&big1);
	    TRACE(("0 %s => 0\n", O2S(value2Ptr)));
	    NEXT_INST_F(1, 1, 0);
	}
	result = Tcl_GetIntFromObj(NULL, value2Ptr, &shift);
	if (result != TCL_OK) {
	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
		    "integer value too large to represent", -1));
	    goto checkForCatch;
	}
................................................................................
	case INST_DICT_LAPPEND:
	    /*
	     * More complex because list-append can fail.
	     */
	    if (valPtr == NULL) {
		valPtr = Tcl_NewListObj(1, tosPtr);
	    } else if (Tcl_IsShared(valPtr)) {
		valPtr = Tcl_DuplicateObj(valPtr);

		result = Tcl_ListObjAppendElement(interp, valPtr, *tosPtr);
		if (result != TCL_OK) {
		    Tcl_DecrRefCount(valPtr);
		    if (allocateDict) {
			Tcl_DecrRefCount(dictPtr);
		    }
		    goto checkForCatch;
		}
	    } else {
		result = Tcl_ListObjAppendElement(interp, valPtr, *tosPtr);

Changes to generic/tclIO.c.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
132
133
134
135
136
137
138

139
140
141
142
143
144
145
...
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
....
1178
1179
1180
1181
1182
1183
1184




1185
1186
1187
1188
1189
1190
1191
....
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
....
1442
1443
1444
1445
1446
1447
1448







1449
1450
1451

1452
1453
1454
1455
1456
1457
1458
....
1513
1514
1515
1516
1517
1518
1519





1520
1521
1522
1523
1524
1525
1526
1527
1528
1529




1530
1531
1532
1533
1534
1535
1536
....
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
....
2095
2096
2097
2098
2099
2100
2101








2102
2103



2104
2105















2106
2107
2108

2109
2110
2111
2112
2113
2114
2115
2116

2117




2118
2119
2120
2121
2122
2123
2124
....
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
....
2246
2247
2248
2249
2250
2251
2252













2253
2254
2255
2256
2257
2258
2259
2260
2261

2262
2263
2264
2265
2266
2267
2268
....
2289
2290
2291
2292
2293
2294
2295











2296
2297
2298
2299
2300
2301
2302
....
2496
2497
2498
2499
2500
2501
2502

2503
2504
2505
2506
2507
2508
2509
....
2539
2540
2541
2542
2543
2544
2545













2546
2547
2548
2549
2550
2551
2552
....
2584
2585
2586
2587
2588
2589
2590

2591

















2592
2593
2594
2595
2596
2597
2598
....
5827
5828
5829
5830
5831
5832
5833










5834
5835
5836
5837
5838
5839
5840
....
7721
7722
7723
7724
7725
7726
7727

7728
7729
7730
7731
7732
7733
7734
....
7758
7759
7760
7761
7762
7763
7764

7765
7766
7767
7768
7769

7770
7771
7772
7773
7774
7775
7776
7777
....
7790
7791
7792
7793
7794
7795
7796
7797





7798


7799
7800
7801
7802
7803
7804
7805
....
7846
7847
7848
7849
7850
7851
7852
7853





7854


7855
7856
7857
7858
7859
7860
7861
....
8689
8690
8691
8692
8693
8694
8695










8696
8697








8698
8699
8700
8701
8702
8703
8704
....
9368
9369
9370
9371
9372
9373
9374








































































































































































































































































9375
9376
9377
9378
9379
9380
9381
 *
 * 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.81.2.7 2005/08/15 18:13:58 dgp Exp $
 */

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

/*
................................................................................
			    char *dst, CONST char *src,
			    int *dstLenPtr, int *srcLenPtr));
static void		UpdateInterest _ANSI_ARGS_((Channel *chanPtr));
static int		WriteBytes _ANSI_ARGS_((Channel *chanPtr,
			    CONST char *src, int srcLen));
static int		WriteChars _ANSI_ARGS_((Channel *chanPtr,
			    CONST char *src, int srcLen));

 
/*
 *---------------------------------------------------------------------------
 *
 * TclInitIOSubsystem --
 *
 *	Initialize all resources used by this subsystem on a per-process
................................................................................
	Tcl_Panic("Tcl_RegisterChannel: channel without name");
    }
    if (interp != (Tcl_Interp *) NULL) {
	hTblPtr = GetChannelTable(interp);
	hPtr = Tcl_CreateHashEntry(hTblPtr, statePtr->channelName, &new);
	if (new == 0) {
	    if (chan == (Tcl_Channel) Tcl_GetHashValue(hPtr)) {
		return;
	    }

	    Tcl_Panic("Tcl_RegisterChannel: duplicate channel names");
	}
	Tcl_SetHashValue(hPtr, (ClientData) chanPtr);
    }
    statePtr->refCount++;
................................................................................
    statePtr->topChanPtr	= chanPtr;
    statePtr->bottomChanPtr	= chanPtr;
    chanPtr->downChanPtr	= (Channel *) NULL;
    chanPtr->upChanPtr		= (Channel *) NULL;
    chanPtr->inQueueHead	= (ChannelBuffer *) NULL;
    chanPtr->inQueueTail	= (ChannelBuffer *) NULL;





    /*
     * Link the channel into the list of all channels; create an on-exit
     * handler if there is not one already, to close off all the channels in
     * the list on exit.
     *
     * JH: Could call Tcl_SpliceChannel, but need to avoid NULL check.
     *
................................................................................
 *	the reverse to 'Tcl_StackChannel'.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	If TCL_ERROR is returned, the posix error code will be set with
 *	Tcl_SetErrno.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_UnstackChannel(interp, chan)
    Tcl_Interp *interp; /* The interpreter we are working in */
................................................................................
	    CopyState *csPtr;

	    csPtr = statePtr->csPtr;
	    statePtr->csPtr = (CopyState *) NULL;

	    if (Tcl_Flush((Tcl_Channel) chanPtr) != TCL_OK) {
		statePtr->csPtr = csPtr;







		Tcl_AppendResult(interp, "could not flush channel \"",
			Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"",
			(char *) NULL);

		return TCL_ERROR;
	    }

	    statePtr->csPtr = csPtr;
	}

	/*
................................................................................
	 */

	Tcl_EventuallyFree((ClientData) chanPtr, TCL_DYNAMIC);
	UpdateInterest(downChanPtr);

	if (result != 0) {
	    Tcl_SetErrno(result);





	    return TCL_ERROR;
	}
    } else {
	/*
	 * This channel does not cover another one.  Simply do a close, if
	 * necessary.
	 */

	if (statePtr->refCount <= 0) {
	    if (Tcl_Close(interp, chan) != TCL_OK) {




		return TCL_ERROR;
	    }
	}
    }

    return TCL_OK;
}
................................................................................
 *
 *	This function flushes as much of the queued output as is possible
 *	now. If calledFromAsyncFlush is nonzero, it is being called in an
 *	event handler to flush channel output asynchronously.
 *
 * Results:
 *	0 if successful, else the error code that was returned by the channel
 *	type operation.
 *
 * Side effects:
 *	May produce output on a channel. May block indefinitely if the channel
 *	is synchronous. May schedule an async flush on the channel.  May
 *	recycle memory for buffers in the output queue.
 *
 *----------------------------------------------------------------------
................................................................................
	    }

	    /*
	     * Decide whether to report the error upwards or defer it.
	     */

	    if (calledFromAsyncFlush) {








		if (statePtr->unreportedError == 0) {
		    statePtr->unreportedError = errorCode;



		}
	    } else {















		Tcl_SetErrno(errorCode);
		if (interp != NULL) {


		    /*
		     * Casting away CONST here is safe because the
		     * TCL_VOLATILE flag guarantees CONST treatment of the
		     * Posix error string.
		     */

		    Tcl_SetResult(interp,
			    (char *) Tcl_PosixError(interp), TCL_VOLATILE);

		}




	    }

	    /*
	     * When we get an error we throw away all the output currently
	     * queued.
	     */

................................................................................
 *	elements of the NEXT channel into the TOP channel, in essence
 *	unstacking the channel.  The NEXT channel will then be freed.
 *
 *	If the channel was not stacked, then we will free all the bits for the
 *	TOP channel, including the data structure itself.
 *
 * Results:
 *	1 if the channel was stacked, 0 otherwise.
 *
 * Side effects:
 *	May close the actual channel, may free memory, may change the value of
 *	errno.
 *
 *----------------------------------------------------------------------
 */
................................................................................

    if ((statePtr->outEofChar != 0) && (statePtr->flags & TCL_WRITABLE)) {
	int dummy;
	char c = (char) statePtr->outEofChar;

	(chanPtr->typePtr->outputProc) (chanPtr->instanceData, &c, 1, &dummy);
    }














    /*
     * Remove this channel from of the list of all channels.
     */

    Tcl_CutChannel((Tcl_Channel) chanPtr);

    /*
     * Close and free the channel driver state.

     */

    if (chanPtr->typePtr->closeProc != TCL_CLOSE2PROC) {
	result = (chanPtr->typePtr->closeProc)(chanPtr->instanceData, interp);
    } else {
	result = (chanPtr->typePtr->close2Proc)(chanPtr->instanceData,
		interp, 0);
................................................................................
    /*
     * If we are being called synchronously, report either any latent error on
     * the channel or the current error.
     */

    if (statePtr->unreportedError != 0) {
	errorCode = statePtr->unreportedError;











    }
    if (errorCode == 0) {
	errorCode = result;
	if (errorCode != 0) {
	    Tcl_SetErrno(errorCode);
	}
    }
................................................................................
					 * interpreter. */
{
    CloseCallback *cbPtr;		/* Iterate over close callbacks for
					 * this channel. */
    Channel *chanPtr;			/* The real IO channel. */
    ChannelState *statePtr;		/* State of real IO channel. */
    int result;				/* Of calling FlushChannel. */


    if (chan == (Tcl_Channel) NULL) {
	return TCL_OK;
    }

    /*
     * Perform special handling for standard channels being closed. If the
................................................................................
     * iso2022, the terminated escape sequence must write to the buffer.
     */

    if ((statePtr->encoding != NULL) && (statePtr->curOutPtr != NULL)
	    && (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) {
	statePtr->outputEncodingFlags |= TCL_ENCODING_END;
	WriteChars(chanPtr, "", 0);













    }

    Tcl_ClearChannelHandlers(chan);

    /*
     * Invoke the registered close callbacks and delete their records.
     */
................................................................................
    /*
     * The call to FlushChannel will flush any queued output and invoke the
     * close function of the channel driver, or it will set up the channel to
     * be flushed and closed asynchronously.
     */

    statePtr->flags |= CHANNEL_CLOSED;

    if ((FlushChannel(interp, chanPtr, 0) != 0) || (result != 0)) {

















	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................
    /*
     * Check for unreported error.
     */

    if (statePtr->unreportedError != 0) {
	Tcl_SetErrno(statePtr->unreportedError);
	statePtr->unreportedError = 0;










	return -1;
    }

    /*
     * Only the raw read and write operations are allowed during close in
     * order to drain data from stacked channels.
     */
................................................................................
static int
CopyData(csPtr, mask)
    CopyState *csPtr;		/* State of copy operation. */
    int mask;			/* Current channel event flags. */
{
    Tcl_Interp *interp;
    Tcl_Obj *cmdPtr, *errObj = NULL, *bufObj = NULL;

    Tcl_Channel inChan, outChan;
    ChannelState *inStatePtr, *outStatePtr;
    int result = TCL_OK, size, total, sizeb;
    char *buffer;

    int inBinary, outBinary, sameEncoding; /* Encoding control */
    int underflow;		/* input underflow */
................................................................................
    }

    while (csPtr->toRead != 0) {
	/*
	 * Check for unreported background errors.
	 */


	if (inStatePtr->unreportedError != 0) {
	    Tcl_SetErrno(inStatePtr->unreportedError);
	    inStatePtr->unreportedError = 0;
	    goto readError;
	}

	if (outStatePtr->unreportedError != 0) {
	    Tcl_SetErrno(outStatePtr->unreportedError);
	    outStatePtr->unreportedError = 0;
	    goto writeError;
	}

	/*
	 * Read up to bufSize bytes.
................................................................................
	}
	underflow = (size >= 0) && (size < sizeb);	/* input underflow */

	if (size < 0) {
	readError:
	    TclNewObj(errObj);
	    Tcl_AppendStringsToObj(errObj, "error reading \"",
		    Tcl_GetChannelName(inChan), "\": ",





		    Tcl_PosixError(interp), (char *) NULL);


	    break;
	} else if (underflow) {
	    /*
	     * We had an underflow on the read side.  If we are at EOF, then
	     * the copying is done, otherwise set up a channel handler to
	     * detect when the channel becomes readable again.
	     */
................................................................................
	    size = sizeb;
	} /* else : Read counted characters, write counted bytes, i.e. size != sizeb */

	if (sizeb < 0) {
	writeError:
	    TclNewObj(errObj);
	    Tcl_AppendStringsToObj(errObj, "error writing \"",
		    Tcl_GetChannelName(outChan), "\": ",





		    Tcl_PosixError(interp), (char *) NULL);


	    break;
	}

	/*
	 * Update the current byte count. Do it now so the count is valid
	 * before a return or break takes us out of the loop. The invariant at
	 * the top of the loop should be that csPtr->toRead holds the number
................................................................................
{
    ChannelState *statePtr = chanPtr->state;	/* state info for channel */
    int result = 0;

    result = StackSetBlockMode(chanPtr, mode);
    if (result != 0) {
	if (interp != (Tcl_Interp *) NULL) {










	    Tcl_AppendResult(interp, "error setting blocking mode: ",
		    Tcl_PosixError(interp), (char *) NULL);








	}
	return TCL_ERROR;
    }
    if (mode == TCL_MODE_BLOCKING) {
	statePtr->flags &= (~(CHANNEL_NONBLOCKING | BG_FLUSH_SCHEDULED));
    } else {
	statePtr->flags |= CHANNEL_NONBLOCKING;
................................................................................
{
    if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) {
	return chanTypePtr->threadActionProc;
    } else {
	return NULL;
    }
}








































































































































































































































































 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ChannelTruncateProc --
 *
 *	TIP #208 (subsection relating to truncation, based on TIP #206).







|







 







>







 







|







 







>
>
>
>







 







|







 







>
>
>
>
>
>
>
|
|
|
>







 







>
>
>
>
>










>
>
>
>







 







|







 







>
>
>
>
>
>
>
>


>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<
>
|
|
|
|
|

|
|
>
|
>
>
>
>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>









>







 







>
>
>
>
>
>
>
>
>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







 







>







 







>
|




>
|







 







|
>
>
>
>
>
|
>
>







 







|
>
>
>
>
>
|
>
>







 







>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
....
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
....
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
....
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
....
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
....
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
....
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155

2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
....
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
....
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
....
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
....
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
....
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
....
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
....
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
....
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
....
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
....
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
....
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
....
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
....
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
 *
 * 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.81.2.8 2005/08/25 15:46:31 dgp Exp $
 */

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

/*
................................................................................
			    char *dst, CONST char *src,
			    int *dstLenPtr, int *srcLenPtr));
static void		UpdateInterest _ANSI_ARGS_((Channel *chanPtr));
static int		WriteBytes _ANSI_ARGS_((Channel *chanPtr,
			    CONST char *src, int srcLen));
static int		WriteChars _ANSI_ARGS_((Channel *chanPtr,
			    CONST char *src, int srcLen));
static Tcl_Obj*         FixLevelCode _ANSI_ARGS_ ((Tcl_Obj* msg));
 
/*
 *---------------------------------------------------------------------------
 *
 * TclInitIOSubsystem --
 *
 *	Initialize all resources used by this subsystem on a per-process
................................................................................
	Tcl_Panic("Tcl_RegisterChannel: channel without name");
    }
    if (interp != (Tcl_Interp *) NULL) {
	hTblPtr = GetChannelTable(interp);
	hPtr = Tcl_CreateHashEntry(hTblPtr, statePtr->channelName, &new);
	if (new == 0) {
	    if (chan == (Tcl_Channel) Tcl_GetHashValue(hPtr)) {
	        return;
	    }

	    Tcl_Panic("Tcl_RegisterChannel: duplicate channel names");
	}
	Tcl_SetHashValue(hPtr, (ClientData) chanPtr);
    }
    statePtr->refCount++;
................................................................................
    statePtr->topChanPtr	= chanPtr;
    statePtr->bottomChanPtr	= chanPtr;
    chanPtr->downChanPtr	= (Channel *) NULL;
    chanPtr->upChanPtr		= (Channel *) NULL;
    chanPtr->inQueueHead	= (ChannelBuffer *) NULL;
    chanPtr->inQueueTail	= (ChannelBuffer *) NULL;

    /* TIP #219, Tcl Channel Reflection API */
    statePtr->chanMsg           = NULL;
    statePtr->unreportedMsg     = NULL;

    /*
     * Link the channel into the list of all channels; create an on-exit
     * handler if there is not one already, to close off all the channels in
     * the list on exit.
     *
     * JH: Could call Tcl_SpliceChannel, but need to avoid NULL check.
     *
................................................................................
 *	the reverse to 'Tcl_StackChannel'.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	If TCL_ERROR is returned, the posix error code will be set with
 *	Tcl_SetErrno. May leave a message in interp result as well.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_UnstackChannel(interp, chan)
    Tcl_Interp *interp; /* The interpreter we are working in */
................................................................................
	    CopyState *csPtr;

	    csPtr = statePtr->csPtr;
	    statePtr->csPtr = (CopyState *) NULL;

	    if (Tcl_Flush((Tcl_Channel) chanPtr) != TCL_OK) {
		statePtr->csPtr = csPtr;
		/* TIP #219, Tcl Channel Reflection API.
		 * Move error messages put by the driver into the chan/ip
		 * bypass area into the regular interpreter result. Fall back
		 * to the regular message if nothing was found in the
		 * bypasses.
		 */
		if (!TclChanCaughtErrorBypass (interp, chan)) {
		    Tcl_AppendResult(interp, "could not flush channel \"",
				     Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"",
				     (char *) NULL);
		}
		return TCL_ERROR;
	    }

	    statePtr->csPtr = csPtr;
	}

	/*
................................................................................
	 */

	Tcl_EventuallyFree((ClientData) chanPtr, TCL_DYNAMIC);
	UpdateInterest(downChanPtr);

	if (result != 0) {
	    Tcl_SetErrno(result);
	    /* TIP #219, Tcl Channel Reflection API.
	     * Move error messages put by the driver into the chan/ip bypass
	     * area into the regular interpreter result.
	     */
	    TclChanCaughtErrorBypass (interp, chan);
	    return TCL_ERROR;
	}
    } else {
	/*
	 * This channel does not cover another one.  Simply do a close, if
	 * necessary.
	 */

	if (statePtr->refCount <= 0) {
	    if (Tcl_Close(interp, chan) != TCL_OK) {
		/* TIP #219, Tcl Channel Reflection API.
		 * "TclChanCaughtErrorBypass" is not required here, it was
		 * done already by "Tcl_Close".
		 */
		return TCL_ERROR;
	    }
	}
    }

    return TCL_OK;
}
................................................................................
 *
 *	This function flushes as much of the queued output as is possible
 *	now. If calledFromAsyncFlush is nonzero, it is being called in an
 *	event handler to flush channel output asynchronously.
 *
 * Results:
 *	0 if successful, else the error code that was returned by the channel
 *	type operation. May leave a message in the interp result.
 *
 * Side effects:
 *	May produce output on a channel. May block indefinitely if the channel
 *	is synchronous. May schedule an async flush on the channel.  May
 *	recycle memory for buffers in the output queue.
 *
 *----------------------------------------------------------------------
................................................................................
	    }

	    /*
	     * Decide whether to report the error upwards or defer it.
	     */

	    if (calledFromAsyncFlush) {
		/* TIP #219, Tcl Channel Reflection API.
		 * When defering the error copy a message from the bypass into
		 * the unreported area. Or discard it if the new error is to be
		 * ignored in favor of an earlier defered error.
		 */

	        Tcl_Obj* msg = statePtr->chanMsg;

		if (statePtr->unreportedError == 0) {
		    statePtr->unreportedError = errorCode;
		    statePtr->unreportedMsg   = msg;
		    if (msg != NULL) {
		        Tcl_IncrRefCount (msg);
		    }
		} else {
		    /* An old unreported error is kept, and this error
		     * thrown away.
		     */
		    statePtr->chanMsg = NULL;
		    if (msg != NULL) {
		        Tcl_DecrRefCount (msg);
		    }
		}
	    } else {
		/* TIP #219, Tcl Channel Reflection API.
		 * Move error messages put by the driver into the chan bypass
		 * area into the regular interpreter result. Fall back to the
		 * regular message if nothing was found in the bypasses.
		 */

		Tcl_SetErrno(errorCode);
		if (interp != NULL) {

		    if (!TclChanCaughtErrorBypass (interp, (Tcl_Channel) chanPtr)) {
		        /*
			 * Casting away CONST here is safe because the
			 * TCL_VOLATILE flag guarantees CONST treatment
			 * of the Posix error string.
			 */

		        Tcl_SetResult(interp,
				(char *) Tcl_PosixError(interp),
				TCL_VOLATILE);
		    }
		}
		/* An unreportable bypassed message is kept, for the
		 * caller of Tcl_Seek, Tcl_Write, etc.
		 */
	    }

	    /*
	     * When we get an error we throw away all the output currently
	     * queued.
	     */

................................................................................
 *	elements of the NEXT channel into the TOP channel, in essence
 *	unstacking the channel.  The NEXT channel will then be freed.
 *
 *	If the channel was not stacked, then we will free all the bits for the
 *	TOP channel, including the data structure itself.
 *
 * Results:
 *	Error code from an unreported error or the driver close operation.
 *
 * Side effects:
 *	May close the actual channel, may free memory, may change the value of
 *	errno.
 *
 *----------------------------------------------------------------------
 */
................................................................................

    if ((statePtr->outEofChar != 0) && (statePtr->flags & TCL_WRITABLE)) {
	int dummy;
	char c = (char) statePtr->outEofChar;

	(chanPtr->typePtr->outputProc) (chanPtr->instanceData, &c, 1, &dummy);
    }

    /* TIP #219, Tcl Channel Reflection API.
     * Move a leftover error message in the channel bypass into the
     * interpreter bypass. Just clear it if there is no interpreter.
     */

    if (statePtr->chanMsg != NULL) {
	if (interp != NULL) {
	    Tcl_SetChannelErrorInterp (interp,statePtr->chanMsg);
	}
        Tcl_DecrRefCount (statePtr->chanMsg);
	statePtr->chanMsg = NULL;
    }

    /*
     * Remove this channel from of the list of all channels.
     */

    Tcl_CutChannel((Tcl_Channel) chanPtr);

    /*
     * Close and free the channel driver state.
     * This may leave a TIP #219 error message in the interp.
     */

    if (chanPtr->typePtr->closeProc != TCL_CLOSE2PROC) {
	result = (chanPtr->typePtr->closeProc)(chanPtr->instanceData, interp);
    } else {
	result = (chanPtr->typePtr->close2Proc)(chanPtr->instanceData,
		interp, 0);
................................................................................
    /*
     * If we are being called synchronously, report either any latent error on
     * the channel or the current error.
     */

    if (statePtr->unreportedError != 0) {
	errorCode = statePtr->unreportedError;

	/* TIP #219, Tcl Channel Reflection API.
	 * Move an error message found in the unreported area into the regular
	 * bypass (interp). This kills any message in the channel bypass area.
	 */

	if (statePtr->chanMsg != NULL) {
	    Tcl_DecrRefCount (statePtr->chanMsg);
	    statePtr->chanMsg = NULL;
	}
        Tcl_SetChannelErrorInterp (interp,statePtr->unreportedMsg);
    }
    if (errorCode == 0) {
	errorCode = result;
	if (errorCode != 0) {
	    Tcl_SetErrno(errorCode);
	}
    }
................................................................................
					 * interpreter. */
{
    CloseCallback *cbPtr;		/* Iterate over close callbacks for
					 * this channel. */
    Channel *chanPtr;			/* The real IO channel. */
    ChannelState *statePtr;		/* State of real IO channel. */
    int result;				/* Of calling FlushChannel. */
    int flushcode;

    if (chan == (Tcl_Channel) NULL) {
	return TCL_OK;
    }

    /*
     * Perform special handling for standard channels being closed. If the
................................................................................
     * iso2022, the terminated escape sequence must write to the buffer.
     */

    if ((statePtr->encoding != NULL) && (statePtr->curOutPtr != NULL)
	    && (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) {
	statePtr->outputEncodingFlags |= TCL_ENCODING_END;
	WriteChars(chanPtr, "", 0);

	/* TIP #219, Tcl Channel Reflection API.
	 * Move an error message found in the channel bypass into the
	 * interpreter bypass. Just clear it if there is no interpreter.
	 */

	if (statePtr->chanMsg != NULL) {
	    if (interp != NULL) {
		Tcl_SetChannelErrorInterp (interp,statePtr->chanMsg);
	    }
	    Tcl_DecrRefCount (statePtr->chanMsg);
	    statePtr->chanMsg = NULL;
	}
    }

    Tcl_ClearChannelHandlers(chan);

    /*
     * Invoke the registered close callbacks and delete their records.
     */
................................................................................
    /*
     * The call to FlushChannel will flush any queued output and invoke the
     * close function of the channel driver, or it will set up the channel to
     * be flushed and closed asynchronously.
     */

    statePtr->flags |= CHANNEL_CLOSED;

    flushcode = FlushChannel(interp, chanPtr, 0);

    /* TIP #219.
     * Capture error messages put by the driver into the bypass area and put
     * them into the regular interpreter result.
     *
     * Notes: Due to the assertion of CHANNEL_CLOSED in the flags
     * "FlushChannel" has called "CloseChannel" and thus freed all the channel
     * structures. We must not try to access "chan" anymore, hence the NULL
     * argument in the call below. The only place which may still contain a
     * message is the interpreter itself, and "CloseChannel" made sure to lift
     * any channel message it generated into it.
     */
    if (TclChanCaughtErrorBypass (interp, NULL)) {
	result = EINVAL;
    }

    if ((flushcode != 0) || (result != 0)) {
	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................
    /*
     * Check for unreported error.
     */

    if (statePtr->unreportedError != 0) {
	Tcl_SetErrno(statePtr->unreportedError);
	statePtr->unreportedError = 0;

	/* TIP #219, Tcl Channel Reflection API.
	 * Move a defered error message back into the channel bypass.
	 */

	if (statePtr->chanMsg != NULL) {
	    Tcl_DecrRefCount (statePtr->chanMsg);
	}
	statePtr->chanMsg       = statePtr->unreportedMsg;
	statePtr->unreportedMsg = NULL;
	return -1;
    }

    /*
     * Only the raw read and write operations are allowed during close in
     * order to drain data from stacked channels.
     */
................................................................................
static int
CopyData(csPtr, mask)
    CopyState *csPtr;		/* State of copy operation. */
    int mask;			/* Current channel event flags. */
{
    Tcl_Interp *interp;
    Tcl_Obj *cmdPtr, *errObj = NULL, *bufObj = NULL;
    Tcl_Obj* msg = NULL;
    Tcl_Channel inChan, outChan;
    ChannelState *inStatePtr, *outStatePtr;
    int result = TCL_OK, size, total, sizeb;
    char *buffer;

    int inBinary, outBinary, sameEncoding; /* Encoding control */
    int underflow;		/* input underflow */
................................................................................
    }

    while (csPtr->toRead != 0) {
	/*
	 * Check for unreported background errors.
	 */

        Tcl_GetChannelError (inChan, &msg);
	if ((inStatePtr->unreportedError != 0) || (msg != NULL)) {
	    Tcl_SetErrno(inStatePtr->unreportedError);
	    inStatePtr->unreportedError = 0;
	    goto readError;
	}
        Tcl_GetChannelError (outChan, &msg);
	if ((outStatePtr->unreportedError != 0) || (msg != NULL)) {
	    Tcl_SetErrno(outStatePtr->unreportedError);
	    outStatePtr->unreportedError = 0;
	    goto writeError;
	}

	/*
	 * Read up to bufSize bytes.
................................................................................
	}
	underflow = (size >= 0) && (size < sizeb);	/* input underflow */

	if (size < 0) {
	readError:
	    TclNewObj(errObj);
	    Tcl_AppendStringsToObj(errObj, "error reading \"",
				   Tcl_GetChannelName(inChan), "\": ",
				   (char *) NULL);
	    if (msg != NULL) {
	        Tcl_AppendObjToObj(errObj,msg);
	    } else {
	        Tcl_AppendStringsToObj(errObj,
		       Tcl_PosixError(interp),
		       (char *) NULL);
	    }
	    break;
	} else if (underflow) {
	    /*
	     * We had an underflow on the read side.  If we are at EOF, then
	     * the copying is done, otherwise set up a channel handler to
	     * detect when the channel becomes readable again.
	     */
................................................................................
	    size = sizeb;
	} /* else : Read counted characters, write counted bytes, i.e. size != sizeb */

	if (sizeb < 0) {
	writeError:
	    TclNewObj(errObj);
	    Tcl_AppendStringsToObj(errObj, "error writing \"",
				   Tcl_GetChannelName(outChan), "\": ",
				   (char *) NULL);
	    if (msg != NULL) {
	        Tcl_AppendObjToObj(errObj,msg);
	    } else {
	        Tcl_AppendStringsToObj(errObj,
		       Tcl_PosixError(interp),
		       (char *) NULL);
	    }
	    break;
	}

	/*
	 * Update the current byte count. Do it now so the count is valid
	 * before a return or break takes us out of the loop. The invariant at
	 * the top of the loop should be that csPtr->toRead holds the number
................................................................................
{
    ChannelState *statePtr = chanPtr->state;	/* state info for channel */
    int result = 0;

    result = StackSetBlockMode(chanPtr, mode);
    if (result != 0) {
	if (interp != (Tcl_Interp *) NULL) {
	    /* TIP #219.
	     * Move error messages put by the driver into the bypass area and
	     * put them into the regular interpreter result. Fall back to the
	     * regular message if nothing was found in the bypass.
	     *
	     * Note that we cannot have a message in the interpreter bypass
	     * area, StackSetBlockMode is restricted to the channel bypass.
	     * We still need the interp as the destination of the move.
	     */
	    if (!TclChanCaughtErrorBypass (interp, (Tcl_Channel) chanPtr)) {
		Tcl_AppendResult(interp, "error setting blocking mode: ",
				 Tcl_PosixError(interp), (char *) NULL);
	    }
	} else {
	    /* TIP #219.
	     * If we have no interpreter to put a bypass message into we have
	     * to clear it, to prevent its propagation and use in other places
	     * unrelated to the actual occurence of the problem.
	     */
	    Tcl_SetChannelError ((Tcl_Channel) chanPtr, NULL);
	}
	return TCL_ERROR;
    }
    if (mode == TCL_MODE_BLOCKING) {
	statePtr->flags &= (~(CHANNEL_NONBLOCKING | BG_FLUSH_SCHEDULED));
    } else {
	statePtr->flags |= CHANNEL_NONBLOCKING;
................................................................................
{
    if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) {
	return chanTypePtr->threadActionProc;
    } else {
	return NULL;
    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_SetChannelErrorInterp --
 *
 *      TIP #219, Tcl Channel Reflection API.
 *	Store an error message for the I/O system.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Discards a previously stored message.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_SetChannelErrorInterp (interp, msg)
     Tcl_Interp* interp; /* Interp to store the data into. */
     Tcl_Obj*    msg;    /* Error message to store. */
{
    Interp* iPtr = (Interp*) interp;

    if (iPtr->chanMsg != NULL) {
        Tcl_DecrRefCount (iPtr->chanMsg);
	iPtr->chanMsg  = NULL;
    }

    if (msg != NULL) {
        iPtr->chanMsg  = FixLevelCode (msg);
	Tcl_IncrRefCount (iPtr->chanMsg);
    }
    return;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_SetChannelError --
 *
 *      TIP #219, Tcl Channel Reflection API.
 *	Store an error message for the I/O system.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Discards a previously stored message.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_SetChannelError (chan, msg)
     Tcl_Channel chan; /* Channel to store the data into. */
     Tcl_Obj*    msg;  /* Error message to store. */
{
    ChannelState* statePtr = ((Channel*) chan)->state;

    if (statePtr->chanMsg != NULL) {
        Tcl_DecrRefCount (statePtr->chanMsg);
	statePtr->chanMsg  = NULL;
    }

    if (msg != NULL) {
        statePtr->chanMsg  = FixLevelCode (msg);
	Tcl_IncrRefCount (statePtr->chanMsg);
    }
    return;
}
 
/*
 *----------------------------------------------------------------------
 *
 * FixLevelCode --
 *
 *      TIP #219, Tcl Channel Reflection API.
 *	Scans an error message for bad -code / -level
 *	directives. Returns a modified copy with such
 *	directives corrected, and the input if it had
 *	no problems.
 *
 * Results:
 *	A Tcl_Obj*
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static Tcl_Obj*
FixLevelCode (msg)
Tcl_Obj* msg;
{
    int       lc;
    Tcl_Obj** lv;
    int       explicitResult;
    int       numOptions;
    int       lcn;
    Tcl_Obj** lvn;
    int       res, i, j, val, lignore, cignore;
    Tcl_Obj*  newlevel = NULL;
    Tcl_Obj*  newcode  = NULL;

    /* ASSERT msg != NULL */

    /* Process the caught message.
     *
     * Syntax = (option value)... ?message?
     *
     * Bad syntax causes a panic. Because the other side uses
     * Tcl_GetReturnOptions and list construction functions to marshall the
     * information.
     */

    res = Tcl_ListObjGetElements (NULL, msg, &lc, &lv);
    if (res != TCL_OK) {
	Tcl_Panic ("Tcl_SetChannelError(Interp): Bad syntax of message");
    }

    explicitResult = (1 == (lc % 2));
    numOptions     = lc - explicitResult;

    /* No options, nothing to do.
     */

    if (numOptions == 0) {
	return msg;
    }

    /* Check for -code x, x != 1|error, and -level x, x != 0 */

    for (i = 0; i < numOptions; i += 2) {
	if (0 == strcmp (Tcl_GetString (lv [i]), "-code")) {
	    /* !"error", !integer, integer != 1 (numeric code for error) */

	    res = Tcl_GetIntFromObj (NULL, lv [i+1], &val);
	    if (((res == TCL_OK) && (val != 1)) ||
		((res != TCL_OK) && (0 != strcmp (Tcl_GetString (lv [i+1]), "error")))) {
		newcode = Tcl_NewIntObj (1);
	    }
	} else if (0 == strcmp (Tcl_GetString (lv [i]), "-level")) {
	    /* !integer, integer != 0 */
	    res = Tcl_GetIntFromObj (NULL, lv [i+1], &val);
	    if ((res != TCL_OK) || (val != 0)) {
		newlevel = Tcl_NewIntObj (0);
	    }
	}
    }

    /* -code, -level are either not present or ok. Nothing to do.
     */

    if (!newlevel && !newcode) {
	return msg;
    }

    lcn = numOptions;
    if (explicitResult) lcn ++;
    if (newlevel)       lcn += 2;
    if (newcode)        lcn += 2;

    lvn = (Tcl_Obj**) ckalloc (lcn * sizeof (Tcl_Obj*));

    /* New level/code information is spliced into the first occurence of
     * -level, -code, further occurences are ignored. The options cannot be
     * not present, we would not come here. Options which are ok are simply
     * copied over.
     */

    lignore = cignore = 0;
    for (i = 0, j = 0; i < numOptions; i += 2) {
	if (0 == strcmp (Tcl_GetString (lv [i]), "-level")) {
	    if (newlevel) {
		lvn [j] = lv [i];   j++;
		lvn [j] = newlevel; j++;
		newlevel = NULL;
		lignore = 1;
		continue;
	    } else if (lignore) {
		continue;
	    }
	} else if (0 == strcmp (Tcl_GetString (lv [i]), "-code")) {
	    if (newcode) {
		lvn [j] = lv [i];  j++;
		lvn [j] = newcode; j++;
		newcode = NULL;
		cignore = 1;
		continue;
	    } else if (cignore) {
		continue;
	    }
	}
	/* Keep everything else, possibly copied down */
	lvn [j] = lv [i];   j++;
	lvn [j] = lv [i+1]; j++;
    }

    if (explicitResult) {
	lvn [j] = lv [i]; j++;
    }

    msg = Tcl_NewListObj (j, lvn);

    ckfree ((char*) lvn);
    return msg;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_GetChannelErrorInterp --
 *
 *      TIP #219, Tcl Channel Reflection API.
 *	Return the message stored by the channel driver.
 *
 * Results:
 *	Tcl error message object.
 *
 * Side effects:
 *	Resets the stored data to NULL.
 *
 *----------------------------------------------------------------------
 */

void Tcl_GetChannelErrorInterp (interp, msg)
     Tcl_Interp* interp; /* Interp to query. */
     Tcl_Obj**   msg;    /* Place for error message. */
{
    Interp* iPtr = (Interp*) interp;

    *msg = iPtr->chanMsg;
    iPtr->chanMsg  = NULL;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_GetChannelError --
 *
 *      TIP #219, Tcl Channel Reflection API.
 *	Return the message stored by the channel driver.
 *
 * Results:
 *	Tcl error message object.
 *
 * Side effects:
 *	Resets the stored data to NULL.
 *
 *----------------------------------------------------------------------
 */

void Tcl_GetChannelError (chan, msg)
     Tcl_Channel chan; /* Channel to query. */
     Tcl_Obj**   msg;  /* Place for error message. */
{
    ChannelState* statePtr = ((Channel*) chan)->state;

    *msg = statePtr->chanMsg;
    statePtr->chanMsg  = NULL;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_ChannelTruncateProc --
 *
 *	TIP #208 (subsection relating to truncation, based on TIP #206).

Changes to generic/tclIO.h.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
231
232
233
234
235
236
237














238
239
240
241
242
243
244
 *
 * 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.h,v 1.7 2004/07/15 20:46:49 andreas_kupries Exp $
 */

/*
 * Make sure that both EAGAIN and EWOULDBLOCK are defined. This does not
 * compile on systems where neither is defined. We want both defined so
 * that we can test safely for both. In the code we still have to test for
 * both because there may be systems on which both are defined and have
................................................................................
    Channel *bottomChanPtr;	/* Refers to bottommost channel in a stack.
				 * This channel can be relied on to live as
				 * long as the channel state. Never NULL. */
    struct ChannelState *nextCSPtr;
				/* Next in list of channels currently open. */
    Tcl_ThreadId managingThread; /* TIP #10: Id of the thread managing
				  * this stack of channels. */














} ChannelState;
    
/*
 * Values for the flags field in Channel. Any ORed combination of the
 * following flags can be stored in the field. These flags record various
 * options and state bits about the channel. In addition to the flags below,
 * the channel can also have TCL_READABLE (1<<1) and TCL_WRITABLE (1<<2) set.







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
 *
 * 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.h,v 1.7.2.1 2005/08/25 15:46:31 dgp Exp $
 */

/*
 * Make sure that both EAGAIN and EWOULDBLOCK are defined. This does not
 * compile on systems where neither is defined. We want both defined so
 * that we can test safely for both. In the code we still have to test for
 * both because there may be systems on which both are defined and have
................................................................................
    Channel *bottomChanPtr;	/* Refers to bottommost channel in a stack.
				 * This channel can be relied on to live as
				 * long as the channel state. Never NULL. */
    struct ChannelState *nextCSPtr;
				/* Next in list of channels currently open. */
    Tcl_ThreadId managingThread; /* TIP #10: Id of the thread managing
				  * this stack of channels. */

    /* TIP #219 ... Info for the I/O system ...
     * Error message set by channel drivers, for the propagation of
     * arbitrary Tcl errors. This information, if present (chanMsg not
     * NULL), takes precedence over a posix error code returned by a
     * channel operation.
     */

    Tcl_Obj* chanMsg;
    Tcl_Obj* unreportedMsg;     /* Non-NULL if an error report was
                                 * deferred because it happened in the
                                 * background. The value is the
                                 * chanMg, if any. #219's companion to
                                 * 'unreportedError'. */
} ChannelState;
    
/*
 * Values for the flags field in Channel. Any ORed combination of the
 * following flags can be stored in the field. These flags record various
 * options and state bits about the channel. In addition to the flags below,
 * the channel can also have TCL_READABLE (1<<1) and TCL_WRITABLE (1<<2) set.

Changes to generic/tclIOCmd.c.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
137
138
139
140
141
142
143






144
145

146
147
148
149
150
151
152
...
187
188
189
190
191
192
193






194
195

196
197
198
199
200
201
202
...
246
247
248
249
250
251
252







253
254
255

256
257
258
259
260
261
262
...
368
369
370
371
372
373
374






375
376
377
378

379
380
381
382
383
384
385
...
453
454
455
456
457
458
459






460
461


462
463
464
465
466
467
468
...
487
488
489
490
491
492
493

494
495
496
497
498
499
500
...
503
504
505
506
507
508
509











510
511
512
513
514
515
516
517
...
829
830
831
832
833
834
835






836
837
838
839

840
841
842
843
844
845
846
....
1626
1627
1628
1629
1630
1631
1632

 *	Contains the definitions of most of the Tcl commands relating to IO.
 *
 * 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: tclIOCmd.c,v 1.22.2.3 2005/08/02 18:15:32 dgp Exp $
 */

#include "tclInt.h"

/*
 * Callback structure for accept callback in a TCP server.
 */
................................................................................
	if (result < 0) {
	    goto error;
	}
    }
    return TCL_OK;

  error:






    Tcl_AppendResult(interp, "error writing \"", channelId, "\": ",
	    Tcl_PosixError(interp), (char *) NULL);

    return TCL_ERROR;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_FlushObjCmd --
................................................................................
    if ((mode & TCL_WRITABLE) == 0) {
	Tcl_AppendResult(interp, "channel \"", channelId,
		"\" wasn't opened for writing", (char *) NULL);
	return TCL_ERROR;
    }

    if (Tcl_Flush(chan) != TCL_OK) {






	Tcl_AppendResult(interp, "error flushing \"", channelId, "\": ",
		Tcl_PosixError(interp), (char *) NULL);

	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................

    linePtr = Tcl_NewObj();

    lineLen = Tcl_GetsObj(chan, linePtr);
    if (lineLen < 0) {
	if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) {
	    Tcl_DecrRefCount(linePtr);







	    Tcl_ResetResult(interp);
	    Tcl_AppendResult(interp, "error reading \"", name, "\": ",
		    Tcl_PosixError(interp), (char *) NULL);

	    return TCL_ERROR;
	}
	lineLen = -1;
    }
    if (objc == 3) {
	if (Tcl_ObjSetVar2(interp, objv[2], NULL, linePtr,
		TCL_LEAVE_ERR_MSG) == NULL) {
................................................................................
	}
    }

    resultPtr = Tcl_NewObj();
    Tcl_IncrRefCount(resultPtr);
    charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0);
    if (charactersRead < 0) {






	Tcl_ResetResult(interp);
	Tcl_AppendResult(interp, "error reading \"", name, "\": ",
		Tcl_PosixError(interp), (char *) NULL);
	Tcl_DecrRefCount(resultPtr);

	return TCL_ERROR;
    }

    /*
     * If requested, remove the last newline in the channel if at EOF.
     */

................................................................................
	    return TCL_ERROR;
	}
	mode = modeArray[optionIndex];
    }

    result = Tcl_Seek(chan, offset, mode);
    if (result == Tcl_LongAsWide(-1)) {






	Tcl_AppendResult(interp, "error during seek on \"",
		chanName, "\": ", Tcl_PosixError(interp), (char *) NULL);


	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................
    ClientData clientData;		/* Not used. */
    Tcl_Interp *interp;			/* Current interpreter. */
    int objc;				/* Number of arguments. */
    Tcl_Obj *CONST objv[];		/* Argument objects. */
{
    Tcl_Channel chan;			/* The channel to tell on. */
    char *chanName;


    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "channelId");
	return TCL_ERROR;
    }

    /*
................................................................................
     */

    chanName = Tcl_GetString(objv[1]);
    chan = Tcl_GetChannel(interp, chanName, NULL);
    if (chan == (Tcl_Channel) NULL) {
	return TCL_ERROR;
    }











    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tcl_Tell(chan)));
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_CloseObjCmd --
................................................................................
	}
	return TCL_OK;
    }

    resultPtr = Tcl_NewObj();
    if (Tcl_GetChannelHandle(chan, TCL_READABLE, NULL) == TCL_OK) {
	if (Tcl_ReadChars(chan, resultPtr, -1, 0) < 0) {






	    Tcl_ResetResult(interp);
	    Tcl_AppendResult(interp, "error reading output from command: ",
		    Tcl_PosixError(interp), (char *) NULL);
	    Tcl_DecrRefCount(resultPtr);

	    return TCL_ERROR;
	}
    }

    /*
     * If the process produced anything on stderr, it will have been returned
     * in the interpreter result.  It needs to be appended to the result
................................................................................
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */








|







 







>
>
>
>
>
>
|
|
>







 







>
>
>
>
>
>
|
|
>







 







>
>
>
>
>
>
>
|
|
|
>







 







>
>
>
>
>
>
|
|
|
|
>







 







>
>
>
>
>
>
|
|
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
|







 







>
>
>
>
>
>
|
|
|
|
>







 







>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
...
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
...
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
....
1682
1683
1684
1685
1686
1687
1688
1689
 *	Contains the definitions of most of the Tcl commands relating to IO.
 *
 * 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: tclIOCmd.c,v 1.22.2.4 2005/08/25 15:46:31 dgp Exp $
 */

#include "tclInt.h"

/*
 * Callback structure for accept callback in a TCP server.
 */
................................................................................
	if (result < 0) {
	    goto error;
	}
    }
    return TCL_OK;

  error:
    /* TIP #219.
     * Capture error messages put by the driver into the bypass area and put
     * them into the regular interpreter result. Fall back to the regular
     * message if nothing was found in the bypass.
     */
    if (!TclChanCaughtErrorBypass (interp, chan)) {
	Tcl_AppendResult(interp, "error writing \"", channelId, "\": ",
			 Tcl_PosixError(interp), (char *) NULL);
    }
    return TCL_ERROR;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_FlushObjCmd --
................................................................................
    if ((mode & TCL_WRITABLE) == 0) {
	Tcl_AppendResult(interp, "channel \"", channelId,
		"\" wasn't opened for writing", (char *) NULL);
	return TCL_ERROR;
    }

    if (Tcl_Flush(chan) != TCL_OK) {
	/* TIP #219.
	 * Capture error messages put by the driver into the bypass area and
	 * put them into the regular interpreter result. Fall back to the
	 * regular message if nothing was found in the bypass.
	 */
	if (!TclChanCaughtErrorBypass (interp, chan)) {
	    Tcl_AppendResult(interp, "error flushing \"", channelId, "\": ",
			     Tcl_PosixError(interp), (char *) NULL);
	}
	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................

    linePtr = Tcl_NewObj();

    lineLen = Tcl_GetsObj(chan, linePtr);
    if (lineLen < 0) {
	if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) {
	    Tcl_DecrRefCount(linePtr);

	    /* TIP #219.
	     * Capture error messages put by the driver into the bypass area
	     * and put them into the regular interpreter result. Fall back to
	     * the regular message if nothing was found in the bypass.
	     */
	    if (!TclChanCaughtErrorBypass (interp, chan)) {
		Tcl_ResetResult(interp);
		Tcl_AppendResult(interp, "error reading \"", name, "\": ",
				 Tcl_PosixError(interp), (char *) NULL);
	    }
	    return TCL_ERROR;
	}
	lineLen = -1;
    }
    if (objc == 3) {
	if (Tcl_ObjSetVar2(interp, objv[2], NULL, linePtr,
		TCL_LEAVE_ERR_MSG) == NULL) {
................................................................................
	}
    }

    resultPtr = Tcl_NewObj();
    Tcl_IncrRefCount(resultPtr);
    charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0);
    if (charactersRead < 0) {
	/* TIP #219.
	 * Capture error messages put by the driver into the bypass area and
	 * put them into the regular interpreter result. Fall back to the
	 * regular message if nothing was found in the bypass.
	 */
	if (!TclChanCaughtErrorBypass (interp, chan)) {
	    Tcl_ResetResult(interp);
	    Tcl_AppendResult(interp, "error reading \"", name, "\": ",
			     Tcl_PosixError(interp), (char *) NULL);
	    Tcl_DecrRefCount(resultPtr);
	}
	return TCL_ERROR;
    }

    /*
     * If requested, remove the last newline in the channel if at EOF.
     */

................................................................................
	    return TCL_ERROR;
	}
	mode = modeArray[optionIndex];
    }

    result = Tcl_Seek(chan, offset, mode);
    if (result == Tcl_LongAsWide(-1)) {
	/* TIP #219.
	 * Capture error messages put by the driver into the bypass area and
	 * put them into the regular interpreter result. Fall back to the
	 * regular message if nothing was found in the bypass.
	 */
	if (!TclChanCaughtErrorBypass (interp, chan)) {
	    Tcl_AppendResult(interp, "error during seek on \"",
			     chanName, "\": ", Tcl_PosixError(interp),
			     (char *) NULL);
	}
	return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
................................................................................
    ClientData clientData;		/* Not used. */
    Tcl_Interp *interp;			/* Current interpreter. */
    int objc;				/* Number of arguments. */
    Tcl_Obj *CONST objv[];		/* Argument objects. */
{
    Tcl_Channel chan;			/* The channel to tell on. */
    char *chanName;
    Tcl_WideInt newLoc;

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "channelId");
	return TCL_ERROR;
    }

    /*
................................................................................
     */

    chanName = Tcl_GetString(objv[1]);
    chan = Tcl_GetChannel(interp, chanName, NULL);
    if (chan == (Tcl_Channel) NULL) {
	return TCL_ERROR;
    }

    newLoc = Tcl_Tell(chan);

    /* TIP #219.
     * Capture error messages put by the driver into the bypass area and put
     * them into the regular interpreter result.
     */
    if (TclChanCaughtErrorBypass (interp, chan)) {
	return TCL_ERROR;
    }

    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(newLoc));
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
 * Tcl_CloseObjCmd --
................................................................................
	}
	return TCL_OK;
    }

    resultPtr = Tcl_NewObj();
    if (Tcl_GetChannelHandle(chan, TCL_READABLE, NULL) == TCL_OK) {
	if (Tcl_ReadChars(chan, resultPtr, -1, 0) < 0) {
	    /* TIP #219.
	     * Capture error messages put by the driver into the bypass area
	     * and put them into the regular interpreter result. Fall back to
	     * the regular message if nothing was found in the bypass.
	     */
	    if (!TclChanCaughtErrorBypass (interp, chan)) {
		Tcl_ResetResult(interp);
		Tcl_AppendResult(interp, "error reading output from command: ",
				 Tcl_PosixError(interp), (char *) NULL);
		Tcl_DecrRefCount(resultPtr);
	    }
	    return TCL_ERROR;
	}
    }

    /*
     * If the process produced anything on stderr, it will have been returned
     * in the interpreter result.  It needs to be appended to the result
................................................................................
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */

Added generic/tclIORChan.c.

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
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
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
/* 
 * tclIORChan.c --
 *
 *	This file contains the implementation of Tcl's generic
 *	channel reflection code, which allows the implementation
 *	of Tcl channels in Tcl code.
 *
 *	Parts of this file are based on code contributed by 
 *	Jean-Claude Wippler.
 *
 *      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.1.2.2 2005/08/25 15:46:31 dgp Exp $
 */

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

#ifndef EINVAL
#define EINVAL 9
#endif
#ifndef EOK
#define EOK    0
#endif

/*
 * Signatures of all functions used in the C layer of the reflection.
 */

/* Required */
static int	RcClose _ANSI_ARGS_((ClientData clientData,
		   Tcl_Interp *interp));

/* Required, "read" is optional despite this. */
static int	RcInput _ANSI_ARGS_((ClientData clientData,
		    char *buf, int toRead, int *errorCodePtr));

/* Required, "write" is optional despite this. */
static int	RcOutput _ANSI_ARGS_((ClientData clientData,
	            CONST char *buf, int toWrite, int *errorCodePtr));

/* Required */
static void	RcWatch _ANSI_ARGS_((ClientData clientData, int mask));

/* NULL'able - "blocking", is optional */
static int	RcBlock _ANSI_ARGS_((ClientData clientData,
				       int mode));

/* NULL'able - "seek", is optional */
static Tcl_WideInt RcSeekWide _ANSI_ARGS_((ClientData clientData,
		    Tcl_WideInt offset,
		    int mode, int *errorCodePtr));

static int RcSeek _ANSI_ARGS_((ClientData clientData,
		    long offset, int mode, int *errorCodePtr));

/* NULL'able - "cget" / "cgetall", are optional */
static int	RcGetOption _ANSI_ARGS_((ClientData clientData,
				       Tcl_Interp* interp,
				       CONST char *optionName,
				       Tcl_DString *dsPtr));

/* NULL'able - "configure", is optional */
static int	RcSetOption _ANSI_ARGS_((ClientData clientData,
				       Tcl_Interp* interp,
				       CONST char *optionName,
				       CONST char *newValue));


/*
 * The C layer channel type/driver definition used by the reflection.
 * This is a version 3 structure.
 */

static Tcl_ChannelType tclRChannelType = {
  "tclrchannel",  /* Type name.                                    */
  TCL_CHANNEL_VERSION_3,
  RcClose,        /* Close channel, clean instance data            */
  RcInput,        /* Handle read request                           */
  RcOutput,       /* Handle write request                          */
  RcSeek,         /* Move location of access point.    NULL'able   */
  RcSetOption,    /* Set options.                      NULL'able   */
  RcGetOption,    /* Get options.                      NULL'able   */
  RcWatch,        /* Initialize notifier                           */
  NULL,           /* Get OS handle from the channel.   NULL'able   */
  NULL,           /* No close2 support.                NULL'able   */
  RcBlock,        /* Set blocking/nonblocking.         NULL'able   */
  NULL,           /* Flush channel. Not used by core.  NULL'able   */
  NULL,           /* Handle events.                    NULL'able   */
  RcSeekWide      /* Move access point (64 bit).       NULL'able   */
};

/*
 * Instance data for a reflected channel. ===========================
 */

typedef struct {
  Tcl_Channel chan;    /* Back reference to generic channel structure.
		        */
  Tcl_Interp* interp;  /* Reference to the interpreter containing the
		        * Tcl level part of the channel. */
#ifdef TCL_THREADS
  Tcl_ThreadId thread; /* Thread the 'interp' belongs to. */
#endif

  /* See [==] as well.
   * Storage for the command prefix and the additional words required
   * for the invocation of methods in the command handler.
   *
   * argv [0] ... [.] | [argc-2] [argc-1] | [argc]  [argc+2]
   *      cmd ... pfx | method   chan     | detail1 detail2
   *      ~~~~ CT ~~~            ~~ CT ~~
   *
   * CT = Belongs to the 'Command handler Thread'.
   */

  int       argc;       /* Number of preallocated words - 2 */
  Tcl_Obj** argv;       /* Preallocated array for calling the handler.
			 * args [0] is placeholder for cmd word.
			 * Followed by the arguments in the prefix,
			 * plus 4 placeholders for method, channel,
			 * and at most two varying (method specific)
			 * words.
			 */

  int methods;          /* Bitmask of supported methods */

  /* ---------------------------------------- */

  /* NOTE (9): Should we have predefined shared literals
   * NOTE (9): for the method names ?
   */

  /* ---------------------------------------- */

  int mode;             /* Mask of R/W mode */
  int interest;         /* Mask of events the channel is interested in. */

  /* Note regarding the usage of timers.
   *
   * Most channel implementations need a timer in the
   * C level to ensure that data in buffers is flushed
   * out through the generation of fake file events.
   *
   * See 'rechan', 'memchan', etc.
   *
   * Here this is _not_ required. Interest in events is
   * posted to the Tcl level via 'watch'. And posting of
   * events is possible from the Tcl level as well, via
   * 'chan postevent'. This means that the generation of
   * all events, fake or not, timer based or not, is
   * completely in the hands of the Tcl level. Therefore
   * no timer here.
   */

} ReflectingChannel;

/*
 * Event literals. ==================================================
 */

static CONST char *eventOptions[] = {
  "read", "write", (char *) NULL
};
typedef enum {
  EVENT_READ, EVENT_WRITE
} EventOption;

/*
 * Method literals. ==================================================
 */

static CONST char *methodNames[] = {
  "blocking",	/* OPT */
  "cget",	/* OPT \/ Together or none */
  "cgetall",	/* OPT /\ of these two     */
  "configure",	/* OPT */
  "finalize",	/*     */
  "initialize",	/*     */
  "read",	/* OPT */
  "seek",	/* OPT */
  "watch",	/*     */
  "write",	/* OPT */
  (char *) NULL
};
typedef enum {
  METH_BLOCKING,
  METH_CGET,
  METH_CGETALL,
  METH_CONFIGURE,
  METH_FINAL,
  METH_INIT,
  METH_READ,
  METH_SEEK,
  METH_WATCH,
  METH_WRITE,
} MethodName;

#define FLAG(m) (1 << (m))
#define REQUIRED_METHODS (FLAG (METH_INIT) | FLAG (METH_FINAL) | FLAG (METH_WATCH))
#define NULLABLE_METHODS (FLAG (METH_BLOCKING) | FLAG (METH_SEEK) | \
	FLAG (METH_CONFIGURE) | FLAG (METH_CGET) | FLAG (METH_CGETALL))

#define RANDW (TCL_READABLE|TCL_WRITABLE)

#define IMPLIES(a,b) ((!(a)) || (b))
#define NEGIMPL(a,b)
#define HAS(x,f) (x & FLAG(f))

 
#ifdef TCL_THREADS
/*
 * Thread specific types and structures.
 *
 * We are here essentially creating a very specific implementation of
 * 'thread send'.
 */

/*
 * Enumeration of all operations which can be forwarded.
 */

typedef enum {
  RcOpClose,
  RcOpInput,
  RcOpOutput,
  RcOpSeek,
  RcOpWatch,
  RcOpBlock,
  RcOpSetOpt,
  RcOpGetOpt,
  RcOpGetOptAll
} RcOperation;

/*
 * Event used to forward driver invocations to the thread actually
 * managing the channel. We cannot construct the command to execute
 * and forward that. Because then it will contain a mixture of
 * Tcl_Obj's belonging to both the command handler thread (CT), and
 * the thread managing the channel (MT), executed in CT. Tcl_Obj's are
 * not allowed to cross thread boundaries. So we forward an operation
 * code, the argument details ,and reference to results. The command
 * is assembled in the CT and belongs fully to that thread. No sharing
 * problems.
 */

typedef struct RcForwardParamBase {
  int   code; /* O: Ok/Fail of the cmd handler */
  char* msg;  /* O: Error message for handler failure */
  int   vol;  /* O: True - msg is allocated, False - msg is static */
} RcForwardParamBase;

/*
 * Operation specific parameter/result structures.
 */

typedef struct RcForwardParamClose {
  RcForwardParamBase b;
} RcForwardParamClose;

typedef struct RcForwardParamInput {
  RcForwardParamBase b;
  char* buf;    /* O: Where to store the read bytes */
  int   toRead; /* I: #bytes to read,
		 * O: #bytes actually read */
} RcForwardParamInput;

typedef struct RcForwardParamOutput {
  RcForwardParamBase b;
  CONST char* buf;     /* I: Where the bytes to write come from */
  int         toWrite; /* I: #bytes to write,
			* O: #bytes actually written */
} RcForwardParamOutput;

typedef struct RcForwardParamSeek {
  RcForwardParamBase b;
  int         seekMode; /* I: How to seek */
  Tcl_WideInt offset;   /* I: Where to seek,
			 * O: New location */
} RcForwardParamSeek;

typedef struct RcForwardParamWatch {
  RcForwardParamBase b;
  int mask; /* I: What events to watch for */
} RcForwardParamWatch;

typedef struct RcForwardParamBlock {
  RcForwardParamBase b;
  int nonblocking; /* I: What mode to activate */
} RcForwardParamBlock;

typedef struct RcForwardParamSetOpt {
  RcForwardParamBase b;
  CONST char* name;  /* Name of option to set */
  CONST char* value; /* Value to set */
} RcForwardParamSetOpt;

typedef struct RcForwardParamGetOpt {
  RcForwardParamBase b;
  CONST char*  name;  /* Name of option to get, maybe NULL */
  Tcl_DString* value; /* Result */
} RcForwardParamGetOpt;

/*
 * General event structure, with reference to
 * operation specific data.
 */

typedef struct RcForwardingEvent {
  Tcl_Event                  event; /* Basic event data, has to be first item */
  struct RcForwardingResult* resultPtr;

  RcOperation               op;    /* Forwarded driver operation */
  ReflectingChannel*        rcPtr; /* Channel instance */
  CONST RcForwardParamBase* param; /* Arguments, a RcForwardParamXXX pointer */
} RcForwardingEvent;

/*
 * Structure to manage the result of the forwarding.  This is not the
 * result of the operation itself, but about the success of the
 * forward event itself. The event can be successful, even if the
 * operation which was forwarded failed. It is also there to manage
 * the synchronization between the involved threads.
 */

typedef struct RcForwardingResult {

  Tcl_ThreadId  src;    /* Originating thread. */
  Tcl_ThreadId  dst;    /* Thread the op was forwarded to. */
  Tcl_Condition done;   /* Condition variable the forwarder blocks on. */
  int           result; /* TCL_OK or TCL_ERROR */

  struct RcForwardingEvent*  evPtr; /* Event the result belongs to. */

  struct RcForwardingResult* prevPtr; /* Links into the list of pending */
  struct RcForwardingResult* nextPtr; /* forwarded results. */

} RcForwardingResult;

/*
 * List of forwarded operations which have not completed yet, plus the
 * mutex to protect the access to this process global list.
 */

static RcForwardingResult* forwardList = (RcForwardingResult*) NULL;
TCL_DECLARE_MUTEX (rcForwardMutex)

/*
 * Function containing the generic code executing a forward, and
 * wrapper macros for the actual operations we wish to forward.
 */

static void
RcForwardOp _ANSI_ARGS_ ((ReflectingChannel* rcPtr, RcOperation op,
			  Tcl_ThreadId dst, CONST VOID* param));

/*
 * The event function executed by the thread receiving a forwarding
 * event. Executes the appropriate function and collects the result,
 * if any.
 */

static int
RcForwardProc _ANSI_ARGS_ ((Tcl_Event *evPtr, int mask));

/*
 * Helpers which intercept when threads are going away, and clean up
 * after pending forwarding events. Different actions depending on
 * which thread went away, originator (src), or receiver (dst).
 */

static void
RcSrcExitProc _ANSI_ARGS_ ((ClientData clientData));

static void
RcDstExitProc _ANSI_ARGS_ ((ClientData clientData));

#define RcFreeReceivedError(pb) \
	if ((pb).vol) {ckfree ((pb).msg);}

#define RcPassReceivedErrorInterp(i,pb) \
	if ((i)) {Tcl_SetChannelErrorInterp ((i), Tcl_NewStringObj ((pb).msg,-1));} \
	RcFreeReceivedError (pb)

#define RcPassReceivedError(c,pb) \
	Tcl_SetChannelError ((c), Tcl_NewStringObj ((pb).msg,-1)); \
	RcFreeReceivedError (pb)

#define RcForwardSetStaticError(p,emsg) \
       (p)->code = TCL_ERROR; (p)->vol  = 0; (p)->msg  = (char*) (emsg);

#define RcForwardSetDynError(p,emsg) \
       (p)->code = TCL_ERROR; (p)->vol  = 1; (p)->msg  = (char*) (emsg);

static void
RcForwardSetObjError _ANSI_ARGS_ ((RcForwardParamBase* p,
				   Tcl_Obj*            obj));

#endif /* TCL_THREADS */

#define RcSetChannelErrorStr(c,msg) \
	Tcl_SetChannelError ((c), Tcl_NewStringObj ((msg),-1))

static Tcl_Obj* RcErrorMarshall _ANSI_ARGS_ ((Tcl_Interp *interp));
static void     RcErrorReturn   _ANSI_ARGS_ ((Tcl_Interp* interp, Tcl_Obj* msg));

 

/*
 * Static functions for this file:
 */

static int RcEncodeEventMask _ANSI_ARGS_((Tcl_Interp* interp,
		 CONST char* objName, Tcl_Obj* obj,
		 int* mask));

static Tcl_Obj* RcDecodeEventMask _ANSI_ARGS_ ((int mask));

static ReflectingChannel* RcNew _ANSI_ARGS_ ((Tcl_Interp* interp,
	     Tcl_Obj* cmdpfxObj, int mode,
	     Tcl_Obj* id));

static Tcl_Obj* RcNewHandle _ANSI_ARGS_ ((void));

static void RcFree _ANSI_ARGS_ ((ReflectingChannel* rcPtr));

static void
RcInvokeTclMethod _ANSI_ARGS_((ReflectingChannel* rcPtr,
       CONST char* method, Tcl_Obj* argone, Tcl_Obj* argtwo,
       int* result, Tcl_Obj** resultObj, int capture));

#define NO_CAPTURE (0)
#define DO_CAPTURE (1)

/*
 * Global constant strings (messages). ==================
 * These string are used directly as bypass errors, thus they have to be valid
 * Tcl lists where the last element is the message itself. Hence the
 * list-quoting to keep the words of the message together. See also [x].
 */

static CONST char* msg_read_unsup       = "{read not supported by Tcl driver}";
static CONST char* msg_read_toomuch     = "{read delivered more than requested}";
static CONST char* msg_write_unsup      = "{write not supported by Tcl driver}";
static CONST char* msg_write_toomuch    = "{write wrote more than requested}";
static CONST char* msg_seek_beforestart = "{Tried to seek before origin}";

#ifdef TCL_THREADS
static CONST char* msg_send_originlost  = "{Origin thread lost}";
static CONST char* msg_send_dstlost     = "{Destination thread lost}";
#endif /* TCL_THREADS */

/*
 * Main methods to plug into the 'chan' ensemble'. ==================
 */

/*
 *----------------------------------------------------------------------
 *
 * TclChanCreateObjCmd --
 *
 *	This procedure is invoked to process the "chan create" Tcl
 *	command. See the user documentation for details on what it does.
 *
 * Results:
 *	A standard Tcl result.
 *	The handle of the new channel is placed in the interp result.
 *
 * Side effects:
 *	Creates a new channel.
 *
 *----------------------------------------------------------------------
 */

int
TclChanCreateObjCmd (/*ignored*/ clientData, interp, objc, objv)
     ClientData      clientData;
     Tcl_Interp*     interp;
     int             objc;
     Tcl_Obj* CONST* objv;
{
    ReflectingChannel* rcPtr;       /* Instance data of the new channel */
    Tcl_Obj*           rcId;        /* Handle of the new channel */
    int                mode;        /* R/W mode of new channel. Has to
				     * match abilities of handler commands */
    Tcl_Obj*           cmdObj;      /* Command prefix, list of words */
    Tcl_Obj*           cmdNameObj;  /* Command name */
    Tcl_Channel        chan;        /* Token for the new channel */
    Tcl_Obj*           modeObj;     /* mode in obj form for method call */
    int                listc;       /* Result of 'initialize', and of */
    Tcl_Obj**          listv;       /* its sublist in the 2nd element */
    int                methIndex;   /* Encoded method name */
    int                res;         /* Result code for 'initialize' */
    Tcl_Obj*           resObj;      /* Result data for 'initialize' */
    int                methods;     /* Bitmask for supported methods. */
    Channel*           chanPtr;     /* 'chan' resolved to internal struct. */

    /* Syntax:   chan create MODE CMDPREFIX
     *           [0]  [1]    [2]  [3]
     *
     * Actually: rCreate MODE CMDPREFIX
     *           [0]     [1]  [2]
     */

#define MODE (1)
#define CMD  (2)

    /* Number of arguments ... */

    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "mode cmdprefix");
	return TCL_ERROR;
    }

    /* First argument is a list of modes. Allowed entries are "read",
     * "write". Expect at least one list element.  Abbreviations are
     * ok.
     */

    modeObj = objv [MODE];
    if (RcEncodeEventMask (interp, "mode", objv [MODE], &mode) != TCL_OK) {
        return TCL_ERROR;
    }

    /* Second argument is command prefix, i.e. list of words, first
     * word is name of handler command, other words are fixed
     * arguments. Run 'initialize' method to get the list of supported
     * methods. Validate this.
     */

    cmdObj = objv [CMD];

    /* Basic check that the command prefix truly is a list. */

    if (Tcl_ListObjIndex(interp, cmdObj, 0, &cmdNameObj) != TCL_OK) {
        return TCL_ERROR;
    }

    /* Now create the channel.
     */

    rcId  = RcNewHandle ();
    rcPtr = RcNew (interp, cmdObj, mode, rcId);
    chan  = Tcl_CreateChannel (&tclRChannelType,
			       Tcl_GetString (rcId),
			       rcPtr, mode);
    rcPtr->chan = chan;
    chanPtr = (Channel*) chan;

    /* Invoke 'initialize' and validate that the handler
     * is present and ok. Squash the channel if not.
     */

    /* Note: The conversion of 'mode' back into a Tcl_Obj ensures that
     * 'initialize' is invoked with canonical mode names, and no
     * abbreviations. Using modeObj directly could feed abbreviations
     * into the handler, and the handler is not specified to handle
     * such.
     */

    modeObj = RcDecodeEventMask (mode);
    RcInvokeTclMethod (rcPtr, "initialize", modeObj, NULL,
		       &res, &resObj, NO_CAPTURE);
    Tcl_DecrRefCount (modeObj);

    if (res != TCL_OK) {
        Tcl_Obj* err = Tcl_NewStringObj ("Initialize failure: ",-1);

	Tcl_AppendObjToObj(err,resObj);
	Tcl_SetObjResult (interp,err);
	Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	goto error;
    }

    /* Verify the result.
     * - List, of method names. Convert to mask.
     *   Check for non-optionals through the mask.
     *   Compare open mode against optional r/w.
     */

    Tcl_AppendResult (interp, "Initialize failure: ", (char*) NULL);

    if (Tcl_ListObjGetElements (interp, resObj,
			&listc, &listv) != TCL_OK) {
        /* The function above replaces my prefix in case of an error,
	 * so more work for us to get the prefix back into the error
	 * message
	 */

        Tcl_Obj* err = Tcl_NewStringObj ("Initialize failure: ",-1);

	Tcl_AppendObjToObj(err,Tcl_GetObjResult (interp));
	Tcl_SetObjResult (interp,err);
	goto error;
    }

    methods = 0;
    while (listc > 0) {
        if (Tcl_GetIndexFromObj (interp, listv [listc-1],
				 methodNames, "method", TCL_EXACT, &methIndex) != TCL_OK) {
	    Tcl_Obj* err = Tcl_NewStringObj ("Initialize failure: ",-1);

	    Tcl_AppendObjToObj(err,Tcl_GetObjResult (interp));
	    Tcl_SetObjResult (interp,err);
	    goto error;
	}

	methods |= FLAG (methIndex);
	listc --;
    }

    if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) {
        Tcl_AppendResult (interp, "Not all required methods supported",
			  (char*) NULL);
	goto error;
    }

    if ((mode & TCL_READABLE) && !HAS(methods,METH_READ)) {
        Tcl_AppendResult (interp, "Reading not supported, but requested",
			  (char*) NULL);
	goto error;
    }

    if ((mode & TCL_WRITABLE) && !HAS(methods,METH_WRITE)) {
        Tcl_AppendResult (interp, "Writing not supported, but requested",
			  (char*) NULL);
	goto error;
    }

    if (!IMPLIES (HAS(methods,METH_CGET), HAS(methods,METH_CGETALL))) {
        Tcl_AppendResult (interp, "'cgetall' not supported, but should be, as 'cget' is",
			  (char*) NULL);
	goto error;
    }

    if (!IMPLIES (HAS(methods,METH_CGETALL),HAS(methods,METH_CGET))) {
        Tcl_AppendResult (interp, "'cget' not supported, but should be, as 'cgetall' is",
			  (char*) NULL);
	goto error;
    }

    Tcl_ResetResult (interp);

    /* Everything is fine now */

    rcPtr->methods = methods;

    if ((methods & NULLABLE_METHODS) != NULLABLE_METHODS) {
        /* Some of the nullable methods are not supported.  We clone
	 * the channel type, null the associated C functions, and use
	 * the result as the actual channel type.
	 */

        Tcl_ChannelType* clonePtr = (Tcl_ChannelType*) ckalloc (sizeof (Tcl_ChannelType));
	if (clonePtr == (Tcl_ChannelType*) NULL) {
	    Tcl_Panic ("Out of memory in Tcl_RcCreate");
	}

	memcpy (clonePtr, &tclRChannelType, sizeof (Tcl_ChannelType));

	if (!(methods & FLAG (METH_CONFIGURE))) {
	  clonePtr->setOptionProc = NULL;
	}

	if (
	    !(methods & FLAG (METH_CGET)) &&
	    !(methods & FLAG (METH_CGETALL))
	    ) {
	    clonePtr->getOptionProc = NULL;
	}
	if (!(methods & FLAG (METH_BLOCKING))) {
	    clonePtr->blockModeProc = NULL;
	}
	if (!(methods & FLAG (METH_SEEK))) {
	    clonePtr->seekProc     = NULL;
	    clonePtr->wideSeekProc = NULL;
	}

	chanPtr->typePtr = clonePtr;
    }

    Tcl_RegisterChannel (interp, chan);

    /* Return handle as result of command */

    Tcl_SetObjResult (interp, rcId);
    return TCL_OK;

 error:
    /* Signal to RcClose to not call 'finalize' */
    rcPtr->methods = 0;
    Tcl_Close (interp, chan);
    return TCL_ERROR;

#undef MODE
#undef CMD
}
 
/*
 *----------------------------------------------------------------------
 *
 * TclChanPostEventObjCmd --
 *
 *	This procedure is invoked to process the "chan postevent"
 *	Tcl command. See the user documentation for details on what it does.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	Posts events to a reflected channel, invokes event handlers.
 *	The latter implies that arbitrary side effects are possible.
 *
 *----------------------------------------------------------------------
 */

int
TclChanPostEventObjCmd (/*ignored*/ clientData, interp, objc, objv)
     ClientData      clientData;
     Tcl_Interp*     interp;
     int             objc;
     Tcl_Obj* CONST* objv;
{
    /* Syntax:   chan postevent CHANNEL EVENTSPEC
     *           [0]  [1]       [2]     [3]
     *
     * Actually: rPostevent CHANNEL EVENTSPEC
     *           [0]        [1]     [2]
     *
     *         where EVENTSPEC = {read write ...} (Abbreviations allowed as well.
     */

#define CHAN  (1)
#define EVENT (2)

    CONST char*        chanId;      /* Tcl level channel handle */
    Tcl_Channel        chan;        /* Channel associated to the handle */
    Tcl_ChannelType*   chanTypePtr; /* Its associated driver structure */
    ReflectingChannel* rcPtr;       /* Associated instance data */
    int                mode;        /* Dummy, r|w mode of the channel */
    int                events;      /* Mask of events to post */

    /* Number of arguments ... */

    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "channel eventspec");
	return TCL_ERROR;
    }

    /* First argument is a channel, a reflected channel, and the call
     * of this command is done from the interp defining the channel
     * handler cmd.
     */

    chanId = Tcl_GetString (objv [CHAN]);
    chan   = Tcl_GetChannel(interp, chanId, &mode);

    if (chan == (Tcl_Channel) NULL) {
        return TCL_ERROR;
    }

    chanTypePtr = Tcl_GetChannelType (chan);

    /* We use a function referenced by the channel type as our cookie
     * to detect calls to non-reflecting channels. The channel type
     * itself is not suitable, as it might not be the static
     * definition in this file, but a clone thereof. And while we have
     * reserved the name of the type nothing in the core checks
     * against violation, so someone else might have created a channel
     * type using our name, clashing with ourselves.
     */

    if (chanTypePtr->watchProc != &RcWatch) {
        Tcl_AppendResult(interp, "channel \"", chanId,
			 "\" is not a reflected channel",
			 (char *) NULL);
	return TCL_ERROR;
    }

    rcPtr = (ReflectingChannel*) Tcl_GetChannelInstanceData (chan);

    if (rcPtr->interp != interp) {
        Tcl_AppendResult(interp, "postevent for channel \"", chanId,
			 "\" called from outside interpreter",
			 (char *) NULL);
	return TCL_ERROR;
    }

    /* Second argument is a list of events. Allowed entries are
     * "read", "write". Expect at least one list element.
     * Abbreviations are ok.
     */

    if (RcEncodeEventMask (interp, "event", objv [EVENT], &events) != TCL_OK) {
        return TCL_ERROR;
    }
    
    /* Check that the channel is actually interested in the provided
     * events.
     */

    if (events & ~rcPtr->interest) {
        Tcl_AppendResult(interp, "tried to post events channel \"", chanId,
			 "\" is not interested in",
			 (char *) NULL);
	return TCL_ERROR;
    }

    /* We have the channel and the events to post.
     */

    Tcl_NotifyChannel (chan, events);

    /* Squash interp results left by the event script.
     */

    Tcl_ResetResult (interp);
    return TCL_OK;

#undef CHAN
#undef EVENT
}
 

static Tcl_Obj*
RcErrorMarshall (interp)
     Tcl_Interp *interp;
{
    /* Capture the result status of the interpreter into a string.
     * => List of options and values, followed by the error message.
     * The result has refCount 0.
     */
    
    Tcl_Obj* returnOpt = Tcl_GetReturnOptions (interp, TCL_ERROR);

    /* => returnOpt.refCount == 0. We can append directly.
     */

    Tcl_ListObjAppendElement (NULL, returnOpt, Tcl_GetObjResult (interp));
    return returnOpt;
}

static void
RcErrorReturn (interp, msg)
     Tcl_Interp *interp;
     Tcl_Obj    *msg;
{
    int       res;
    int       lc;
    Tcl_Obj** lv;
    int       explicitResult;
    int       numOptions;

    /* Process the caught message.
     *
     * Syntax = (option value)... ?message?
     *
     * Bad syntax causes a panic. Because the other side uses
     * Tcl_GetReturnOptions and list construction functions to marshall the
     * information.
     */

    res = Tcl_ListObjGetElements (interp, msg, &lc, &lv);
    if (res != TCL_OK) {
	Tcl_Panic ("TclChanCaughtErrorBypass: Bad syntax of caught result");
    }

    explicitResult = (1 == (lc % 2));
    numOptions     = lc - explicitResult;

    if (explicitResult) {
	Tcl_SetObjResult (interp, lv [lc-1]);
    }

    (void) Tcl_SetReturnOptions(interp, Tcl_NewListObj (numOptions, lv));
}

int
TclChanCaughtErrorBypass (interp, chan)
     Tcl_Interp *interp;
     Tcl_Channel chan;
{
    Tcl_Obj* msgc = NULL;
    Tcl_Obj* msgi = NULL;
    Tcl_Obj* msg  = NULL;

    /* Get a bypassed error message from channel and/or interpreter, save the
     * reference, then kill the returned objects, if there were any. If there
     * are messages in both the channel has preference.
     */

    if ((chan == NULL) && (interp == NULL)) {
	return 0;
    }

    if (chan != NULL) {
	Tcl_GetChannelError       (chan,   &msgc);
    }
    if (interp != NULL) {
	Tcl_GetChannelErrorInterp (interp, &msgi);
    }

    if (msgc != NULL) {
	msg = msgc;
	Tcl_IncrRefCount (msg);
    } else if (msgi != NULL) {
	msg = msgi;
	Tcl_IncrRefCount (msg);
    }

    if (msgc != NULL) {
	Tcl_DecrRefCount (msgc);
    }
    if (msgi != NULL) {
	Tcl_DecrRefCount (msgi);
    }

    /* No message returned, nothing caught.
     */

    if (msg == NULL) {
	return 0;
    }

    RcErrorReturn (interp, msg);

    Tcl_DecrRefCount (msg);
    return 1;
}
 
/*
 * Driver functions. ================================================
 */

/*
 *----------------------------------------------------------------------
 *
 * RcClose --
 *
 *	This function is invoked when the channel is closed, to delete
 *	the driver specific instance data.
 *
 * Results:
 *	A posix error.
 *
 * Side effects:
 *	Releases memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static int
RcClose (clientData, interp)
     ClientData  clientData;
     Tcl_Interp* interp;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    int                res;         /* Result code for 'close' */
    Tcl_Obj*           resObj;      /* Result data for 'close' */

    if (interp == (Tcl_Interp*) NULL) {
        /* This call comes from TclFinalizeIOSystem. There are no
	 * interpreters, and therefore we cannot call upon the handler
	 * command anymore. Threading is irrelevant as well.  We
	 * simply clean up all our C level data structures and leave
	 * the Tcl level to the other finalization functions.
	 */

      /* THREADED => Forward this to the origin thread */
      /* Note: Have a thread delete handler for the origin
       * thread. Use this to clean up the structure!
       */

#ifdef TCL_THREADS
        /* Are we in the correct thread ?
	 */

        if (rcPtr->thread != Tcl_GetCurrentThread ()) {
	    RcForwardParamClose p;

	    RcForwardOp (rcPtr, RcOpClose, rcPtr->thread, &p);
	    res = p.b.code;

	    /* RcFree is done in the forwarded operation!,
	     * in the other thread. rcPtr here is gone!
	     */

	    if (res != TCL_OK) {
	        RcFreeReceivedError (p.b);
	    }
	} else {
#endif
	    RcFree (rcPtr);
#ifdef TCL_THREADS
	}
#endif
	return EOK;
    }

    /* -------- */

    /* -- No -- ASSERT rcPtr->methods & FLAG (METH_FINAL) */

    /* A cleaned method mask here implies that the channel creation
     * was aborted, and "finalize" must not be called.
     */

    if (rcPtr->methods == 0) {
        RcFree (rcPtr);
        return EOK;
    } else {
#ifdef TCL_THREADS
        /* Are we in the correct thread ?
	 */

        if (rcPtr->thread != Tcl_GetCurrentThread ()) {
	    RcForwardParamClose p;

	    RcForwardOp (rcPtr, RcOpClose, rcPtr->thread, &p);
	    res = p.b.code;

	    /* RcFree is done in the forwarded operation!,
	     * in the other thread. rcPtr here is gone!
	     */

	    if (res != TCL_OK) {
	        RcPassReceivedErrorInterp (interp, p.b);
	    }
	} else {
#endif
	    RcInvokeTclMethod (rcPtr, "finalize", NULL, NULL,
			       &res, &resObj, DO_CAPTURE);

	    if ((res != TCL_OK) && (interp != NULL)) {
	        Tcl_SetChannelErrorInterp (interp, resObj);
	    }

	    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
#ifdef TCL_THREADS
	    RcFree (rcPtr);
	}
#endif
	return (res == TCL_OK) ? EOK : EINVAL;
    }

    Tcl_Panic ("Should not be reached");
    return EINVAL;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcInput --
 *
 *	This function is invoked when more data is requested from the
 *	channel.
 *
 * Results:
 *	The number of bytes read.
 *
 * Side effects:
 *	Allocates memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static int
RcInput (clientData, buf, toRead, errorCodePtr)
     ClientData clientData;
     char* buf;
     int toRead;
     int* errorCodePtr;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*           toReadObj;
    int                bytec;       /* Number of returned bytes */
    unsigned char*     bytev;       /* Array of returned bytes */
    int                res;         /* Result code for 'read' */
    Tcl_Obj*           resObj;      /* Result data for 'read' */

    /* The following check can be done before thread redirection,
     * because we are reading from an item which is readonly, i.e.
     * will never change during the lifetime of the channel.
     */

    if (!(rcPtr->methods & FLAG (METH_READ))) {
        RcSetChannelErrorStr (rcPtr->chan, msg_read_unsup);
	*errorCodePtr = EINVAL;
	return -1;
    }

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        RcForwardParamInput p;

	p.buf    = buf;
	p.toRead = toRead;

	RcForwardOp (rcPtr, RcOpInput, rcPtr->thread, &p);

	if (p.b.code != TCL_OK) {
	    RcPassReceivedError (rcPtr->chan, p.b);
	    *errorCodePtr = EINVAL;
	} else {
	    *errorCodePtr = EOK;
	}

	return p.toRead;
    }
#endif

    /* -------- */

    /* ASSERT: rcPtr->method & FLAG (METH_READ) */
    /* ASSERT: rcPtr->mode & TCL_READABLE */

    toReadObj = Tcl_NewIntObj(toRead);
    if (toReadObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcInput");
    }

    RcInvokeTclMethod (rcPtr, "read", toReadObj, NULL,
		       &res, &resObj, DO_CAPTURE);

    if (res != TCL_OK) {
	Tcl_SetChannelError (rcPtr->chan, resObj);
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	*errorCodePtr = EINVAL;
	return -1;
    }

    bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);

    if (toRead < bytec) {
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	RcSetChannelErrorStr (rcPtr->chan, msg_read_toomuch);
	*errorCodePtr = EINVAL;
	return -1;
    }

    *errorCodePtr = EOK;

    if (bytec > 0) {
        memcpy (buf, bytev, bytec);
    }

    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
    return bytec;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcOutput --
 *
 *	This function is invoked when data is writen to the
 *	channel.
 *
 * Results:
 *	The number of bytes actually written.
 *
 * Side effects:
 *	Allocates memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static int
RcOutput (clientData, buf, toWrite, errorCodePtr)
     ClientData clientData;
     CONST char* buf;
     int toWrite;
     int* errorCodePtr;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*       bufObj;
    int            res;         /* Result code for 'write' */
    Tcl_Obj*       resObj;      /* Result data for 'write' */
    int            written;

    /* The following check can be done before thread redirection,
     * because we are reading from an item which is readonly, i.e.
     * will never change during the lifetime of the channel.
     */

    if (!(rcPtr->methods & FLAG (METH_WRITE))) {
        RcSetChannelErrorStr (rcPtr->chan, msg_write_unsup);
        *errorCodePtr = EINVAL;
	return -1;
    }

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
      RcForwardParamOutput p;

      p.buf     = buf;
      p.toWrite = toWrite;

      RcForwardOp (rcPtr, RcOpOutput, rcPtr->thread, &p);

      if (p.b.code != TCL_OK) {
	  RcPassReceivedError (rcPtr->chan, p.b);
	  *errorCodePtr = EINVAL;
      } else {
	  *errorCodePtr = EOK;
      }

      return p.toWrite;
    }
#endif

    /* -------- */

    /* ASSERT: rcPtr->method & FLAG (METH_WRITE) */
    /* ASSERT: rcPtr->mode & TCL_WRITABLE */
    
    bufObj = Tcl_NewByteArrayObj((unsigned char*) buf, toWrite);
    if (bufObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcOutput");
    }

    RcInvokeTclMethod (rcPtr, "write", bufObj, NULL,
		       &res, &resObj, DO_CAPTURE);

    if (res != TCL_OK) {
	Tcl_SetChannelError (rcPtr->chan, resObj);
	Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	*errorCodePtr = EINVAL;
	return -1;
    }

    res = Tcl_GetIntFromObj (rcPtr->interp, resObj, &written);
    if (res != TCL_OK) {
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	Tcl_SetChannelError (rcPtr->chan, RcErrorMarshall (rcPtr->interp));
	*errorCodePtr = EINVAL;
	return -1;
    }

    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */

    if ((written == 0) || (toWrite < written)) {
        /* The handler claims to have written more than it was given.
	 * That is bad. Note that the I/O core would crash if we were
	 * to return this information, trying to write -nnn bytes in
	 * the next iteration.
	 */

        RcSetChannelErrorStr (rcPtr->chan, msg_write_toomuch);
	*errorCodePtr = EINVAL;
	return -1;
    }

    *errorCodePtr = EOK;
    return written;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcSeekWide / RcSeek --
 *
 *	This function is invoked when the user wishes to seek on
 *	the channel.
 *
 * Results:
 *	The new location of the access point.
 *
 * Side effects:
 *	Allocates memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static Tcl_WideInt
RcSeekWide (clientData, offset, seekMode, errorCodePtr)
     ClientData  clientData;
     Tcl_WideInt offset;
     int         seekMode;
     int*        errorCodePtr;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*       offObj;
    Tcl_Obj*       baseObj;
    int            res;         /* Result code for 'seek' */
    Tcl_Obj*       resObj;      /* Result data for 'seek' */
    Tcl_WideInt    newLoc;

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        RcForwardParamSeek p;

	p.seekMode = seekMode;
	p.offset   = offset;

	RcForwardOp (rcPtr, RcOpSeek, rcPtr->thread, &p);

	if (p.b.code != TCL_OK) {
	    RcPassReceivedError (rcPtr->chan, p.b);
	    *errorCodePtr = EINVAL;
	} else {
	    *errorCodePtr = EOK;
	}

	return p.offset;
    }
#endif

    /* -------- */

    /* ASSERT: rcPtr->method & FLAG (METH_SEEK) */

    offObj = Tcl_NewWideIntObj(offset);
    if (offObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcSeekWide");
    }

    baseObj = Tcl_NewStringObj((seekMode == SEEK_SET) ?
			       "start" :
			       ((seekMode == SEEK_CUR) ?
				"current" :
				"end"), -1);

    if (baseObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcSeekWide");
    }

    RcInvokeTclMethod (rcPtr, "seek", offObj, baseObj,
		       &res, &resObj, DO_CAPTURE);

    if (res != TCL_OK) {
	Tcl_SetChannelError (rcPtr->chan, resObj);
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	*errorCodePtr = EINVAL;
	return -1;
    }

    res = Tcl_GetWideIntFromObj (rcPtr->interp, resObj, &newLoc);
    if (res != TCL_OK) {
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	Tcl_SetChannelError (rcPtr->chan, RcErrorMarshall (rcPtr->interp));
	*errorCodePtr = EINVAL;
	return -1;
    }

    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */

    if (newLoc < Tcl_LongAsWide (0)) {
        RcSetChannelErrorStr (rcPtr->chan, msg_seek_beforestart);
        *errorCodePtr = EINVAL;
	return -1;
    }

    *errorCodePtr = EOK;
    return newLoc;
}

static int
RcSeek (clientData, offset, seekMode, errorCodePtr)
     ClientData  clientData;
     long        offset;
     int         seekMode;
     int*        errorCodePtr;
{
  /* This function can be invoked from a transformation which is based
   * on standard seeking, i.e. non-wide. Because o this we have to
   * implement it, a dummy is not enough. We simply delegate the call
   * to the wide routine.
   */

  return (int) RcSeekWide (clientData, Tcl_LongAsWide (offset),
			   seekMode, errorCodePtr);
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcWatch --
 *
 *	This function is invoked to tell the channel what events
 *	the I/O system is interested in.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Allocates memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static void
RcWatch (clientData, mask)
     ClientData clientData;
     int mask;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj* maskObj;

    /* ASSERT rcPtr->methods & FLAG (METH_WATCH) */

    /* We restrict the interest to what the channel can support
     * IOW there will never be write events for a channel which is
     * not writable. Analoguous for read events.
     */

    mask = mask & rcPtr->mode; 

    if (mask == rcPtr->interest) {
        /* Same old, same old, why should we do something ? */
      return;
    }

    rcPtr->interest = mask;

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        RcForwardParamWatch p;

	p.mask = mask;

	RcForwardOp (rcPtr, RcOpWatch, rcPtr->thread, &p);

	/* Any failure from the forward is ignored. We have no place to
	 * put this.
	 */
	return;
    }
#endif

    /* -------- */

    maskObj = RcDecodeEventMask (mask);
    RcInvokeTclMethod (rcPtr, "watch", maskObj, NULL,
		       NULL, NULL, NO_CAPTURE);
    Tcl_DecrRefCount (maskObj);
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcBlock --
 *
 *	This function is invoked to tell the channel which blocking
 *	behaviour is required of it.
 *
 * Results:
 *	A posix error number.
 *
 * Side effects:
 *	Allocates memory. Arbitrary, as it calls upon a script.
 *
 *----------------------------------------------------------------------
 */

static int
RcBlock (clientData, nonblocking)
     ClientData clientData;
     int nonblocking;
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*           blockObj;
    int                res;         /* Result code for 'blocking' */
    Tcl_Obj*           resObj;      /* Result data for 'blocking' */

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        RcForwardParamBlock p;

	p.nonblocking = nonblocking;

	RcForwardOp (rcPtr, RcOpBlock, rcPtr->thread, &p);

	if (p.b.code != TCL_OK) {
	    RcPassReceivedError (rcPtr->chan, p.b);
	    return EINVAL;
	} else {
	    return EOK;
	}
    }
#endif

    /* -------- */

    blockObj = Tcl_NewBooleanObj(!nonblocking);
    if (blockObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcBlock");
    }

    RcInvokeTclMethod (rcPtr, "blocking", blockObj, NULL,
		       &res, &resObj, DO_CAPTURE);

    if (res != TCL_OK) {
	Tcl_SetChannelError (rcPtr->chan, resObj);
	res = EINVAL;
    } else {
        res = EOK;
    }

    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
    return res;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcSetOption --
 *
 *	This function is invoked to configure a channel option.
 *
 * Results:
 *	A standard Tcl result code.
 *
 * Side effects:
 *	Arbitrary, as it calls upon a Tcl script.
 *
 *----------------------------------------------------------------------
 */

static int
RcSetOption (clientData, interp, optionName, newValue)
     ClientData   clientData;	/* Channel to query */
     Tcl_Interp   *interp;	/* Interpreter to leave error messages in */
     CONST char *optionName;	/* Name of requested option */
     CONST char *newValue;	/* The new value */
{
    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*           optionObj;
    Tcl_Obj*           valueObj;
    int                res;         /* Result code for 'configure' */
    Tcl_Obj*           resObj;      /* Result data for 'configure' */

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        RcForwardParamSetOpt p;

	p.name  = optionName;
	p.value = newValue;

	RcForwardOp (rcPtr, RcOpSetOpt, rcPtr->thread, &p);

	if (p.b.code != TCL_OK) {
	    Tcl_Obj* err = Tcl_NewStringObj (p.b.msg, -1);

	    RcErrorReturn (interp, err);

	    Tcl_DecrRefCount (err);
	    if (p.b.vol) {ckfree (p.b.msg);}
	}

	return p.b.code;
    }
#endif

  /* -------- */

  optionObj = Tcl_NewStringObj(optionName,-1);
  if (optionObj == (Tcl_Obj*) NULL) {
    Tcl_Panic ("Out of memory in RcSetOption");
  }

  valueObj = Tcl_NewStringObj(newValue,-1);
  if (valueObj == (Tcl_Obj*) NULL) {
    Tcl_Panic ("Out of memory in RcSetOption");
  }

  RcInvokeTclMethod (rcPtr, "configure", optionObj, valueObj,
		     &res, &resObj, DO_CAPTURE);

  if (res != TCL_OK) {
    RcErrorReturn (interp, resObj);
  }

  Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
  return res;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcGetOption --
 *
 *	This function is invoked to retrieve all or a channel option.
 *
 * Results:
 *	A standard Tcl result code.
 *
 * Side effects:
 *	Arbitrary, as it calls upon a Tcl script.
 *
 *----------------------------------------------------------------------
 */

static int
RcGetOption (clientData, interp, optionName, dsPtr)
     ClientData   clientData;	/* Channel to query */
     Tcl_Interp*  interp;	/* Interpreter to leave error messages in */
     CONST char* optionName;	/* Name of reuqested option */
     Tcl_DString* dsPtr;	/* String to place the result into */
{
    /* This code is special. It has regular passing of Tcl result, and
     * errors. The bypass functions are not required.
     */

    ReflectingChannel* rcPtr = (ReflectingChannel*) clientData;
    Tcl_Obj*           optionObj;
    int                res;         /* Result code for 'configure' */
    Tcl_Obj*           resObj;      /* Result data for 'configure' */
    int                listc;
    Tcl_Obj**          listv;
    const char*        method;

#ifdef TCL_THREADS
    /* Are we in the correct thread ?
     */

    if (rcPtr->thread != Tcl_GetCurrentThread ()) {
        int opcode;
        RcForwardParamGetOpt p;

	p.name  = optionName;
	p.value = dsPtr;

	if (optionName == (char*) NULL) {
	    opcode = RcOpGetOptAll;
	} else {
	    opcode = RcOpGetOpt;
	}

	RcForwardOp (rcPtr, opcode, rcPtr->thread, &p);

	if (p.b.code != TCL_OK) {
	    Tcl_Obj* err = Tcl_NewStringObj (p.b.msg, -1);

	    RcErrorReturn (interp, err);

	    Tcl_DecrRefCount (err);
	    if (p.b.vol) {ckfree (p.b.msg);}
	}

	return p.b.code;
    }
#endif

    /* -------- */

    if (optionName == (char*) NULL) {
        /* Retrieve all options. */
        method    = "cgetall";
	optionObj = NULL;
    } else {
        /* Retrieve the value of one option */
      
        method    = "cget";
	optionObj = Tcl_NewStringObj(optionName,-1);
	if (optionObj == (Tcl_Obj*) NULL) {
	    Tcl_Panic ("Out of memory in RcGetOption");
	}
    }

    RcInvokeTclMethod (rcPtr, method, optionObj, NULL,
			 &res, &resObj, DO_CAPTURE);

    if (res != TCL_OK) {
        RcErrorReturn (interp, resObj);
	Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	return res;
    }

    /* The result has to go into the 'dsPtr' for propagation to the
     * caller of the driver.
     */

    if (optionObj != NULL) {
        Tcl_DStringAppend (dsPtr, Tcl_GetString (resObj), -1);
	Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	return res;
    }

    /* Extract the list and append each item as element.
     */

    /* NOTE (4): If we extract the string rep we can assume a
     * NOTE (4): properly quoted string. Together with a separating
     * NOTE (4): space this way of simply appending the whole string
     * NOTE (4): rep might be faster. It also doesn't check if the
     * NOTE (4): result is a valid list. Nor that the list has an
     * NOTE (4): even number elements.
     * NOTE (4): ---
     */

    res = Tcl_ListObjGetElements (interp, resObj, &listc, &listv);

    if (res != TCL_OK) {
        Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	return res;
    }

    if ((listc % 2) == 1) {
        /* Odd number of elements is wrong.
	 */

        char buf [20];

	sprintf (buf, "%d", listc);
	Tcl_ResetResult  (interp);
	Tcl_AppendResult (interp,
			  "Expected list with even number of elements, got ",
			  buf, (listc == 1 ? " element" : " elements"),
			  " instead", (char*) NULL);

	Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
	return TCL_ERROR;
    }


    {
        int len;
	char* str = Tcl_GetStringFromObj (resObj, &len);

	if (len) {
	    Tcl_DStringAppend (dsPtr, " ", 1);
	    Tcl_DStringAppend (dsPtr, str, len);
	}
    }
    Tcl_DecrRefCount (resObj); /* Remove reference we held from the invoke */
    return res;
}
 
/*
 * Helpers. =========================================================
 */

/*
 *----------------------------------------------------------------------
 *
 * RcEncodeEventMask --
 *
 *	This function takes a list of event items and constructs the
 *	equivalent internal bitmask. The list has to contain at
 *	least one element. Elements are "read", "write", or any unique
 *	abbreviation thereof. Note that the bitmask is not changed if
 *	problems are encountered.
 *
 * Results:
 *	A standard Tcl error code. A bitmask where TCL_READABLE
 *	and/or TCL_WRITABLE can be set.
 *
 * Side effects:
 *	May shimmer 'obj' to a list representation. May place an
 *	error message into the interp result.
 *
 *----------------------------------------------------------------------
 */

static int
RcEncodeEventMask (interp, objName, obj, mask)
     Tcl_Interp* interp;
     CONST char* objName;
     Tcl_Obj*    obj;
     int*        mask;
{
    int        events;	/* Mask of events to post */
    int        listc;     /* #elements in eventspec list */
    Tcl_Obj**  listv;     /* Elements of eventspec list */
    int        evIndex;   /* Id of event for an element of the
			 * eventspec list */

    if (Tcl_ListObjGetElements (interp, obj,
				&listc, &listv) != TCL_OK) {
        return TCL_ERROR;
    }

    if (listc < 1) {
        Tcl_AppendResult(interp, "bad ", objName, " list: is empty",
			 (char *) NULL);
	return TCL_ERROR;
    }

    events = 0;
    while (listc > 0) {
        if (Tcl_GetIndexFromObj (interp, listv [listc-1],
				 eventOptions, objName, 0, &evIndex) != TCL_OK) {
	    return TCL_ERROR;
	}
	switch (evIndex) {
	    case EVENT_READ:  events |= TCL_READABLE; break;
	    case EVENT_WRITE: events |= TCL_WRITABLE; break;
	}
	listc --;
    }

    *mask = events;
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcDecodeEventMask --
 *
 *	This function takes an internal bitmask of events and
 *	constructs the equivalent list of event items.
 *
 * Results:
 *	A Tcl_Obj reference. The object will have a refCount of
 *	one. The user has to decrement it to release the object.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static Tcl_Obj*
RcDecodeEventMask (mask)
{
    Tcl_Obj* evObj = Tcl_NewStringObj (((mask & RANDW) == RANDW) ?
				       "read write" :
				       ((mask & TCL_READABLE) ?
					"read" :
					((mask & TCL_WRITABLE) ?
					 "write" : "")), -1);
    if (evObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcDecodeEventMask");
    }

    Tcl_IncrRefCount (evObj);
    return evObj;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcNew --
 *
 *	This function is invoked to allocate and initialize the
 *	instance data of a new reflected channel.
 *
 * Results:
 *	A heap-allocated channel instance.
 *
 * Side effects:
 *	Allocates memory.
 *
 *----------------------------------------------------------------------
 */

static ReflectingChannel*
RcNew (interp, cmdpfxObj, mode, id)
       Tcl_Interp* interp;
       Tcl_Obj*    cmdpfxObj;
       int         mode;
       Tcl_Obj*    id;
{
    ReflectingChannel* rcPtr;
    int                listc;
    Tcl_Obj**          listv;
    Tcl_Obj*           word;
    int                i;

    rcPtr = (ReflectingChannel*) ckalloc (sizeof(ReflectingChannel));

    /* rcPtr->chan    : Assigned by caller. Dummy data here. */
    /* rcPtr->methods : Assigned by caller. Dummy data here. */

    rcPtr->chan     = (Tcl_Channel) NULL;
    rcPtr->methods  = 0;
    rcPtr->interp   = interp;
#ifdef TCL_THREADS
    rcPtr->thread   = Tcl_GetCurrentThread ();
#endif
    rcPtr->mode     = mode;
    rcPtr->interest = 0; /* Initially no interest registered */

    /* Method placeholder */

    /* ASSERT: cmdpfxObj is a Tcl List */

    Tcl_ListObjGetElements (interp, cmdpfxObj, &listc, &listv);

    /* See [==] as well.
     * Storage for the command prefix and the additional words required
     * for the invocation of methods in the command handler.
     *
     * listv [0] [listc-1] | [listc]  [listc+1] |
     * argv  [0]   ... [.] | [argc-2] [argc-1]  | [argc]  [argc+2]
     *       cmd   ... pfx | method   chan      | detail1 detail2
     */

    rcPtr->argc = listc + 2;
    rcPtr->argv = (Tcl_Obj**) ckalloc (sizeof (Tcl_Obj*) * (listc+4));

    for (i = 0; i < listc ; i++) {
        word = rcPtr->argv [i] = listv [i];
        Tcl_IncrRefCount (word);
    }

    i++; /* Skip placeholder for method */

    rcPtr->argv [i] = id ; Tcl_IncrRefCount (id);

    /* The next two objects are kept empty, varying arguments */

    /* Initialization complete */
    return rcPtr;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcNewHandle --
 *
 *	This function is invoked to generate a channel handle for
 *	a new reflected channel.
 *
 * Results:
 *	A Tcl_Obj containing the string of the new channel handle.
 *	The refcount of the returned object is -- zero --.
 *
 * Side effects:
 *	May allocate memory. Mutex protected critical section
 *	locks out other threads for a short time.
 *
 *----------------------------------------------------------------------
 */

Tcl_Obj*
RcNewHandle ()
{
    /* Count number of generated reflected channels.  Used for id
     * generation. Ids are never reclaimed and there is no dealing
     * with wrap around. On the other hand, "unsigned long" should be
     * big enough except for absolute longrunners (generate a 100 ids
     * per second => overflow will occur in 1 1/3 years).
     */

#ifdef TCL_THREADS
    TCL_DECLARE_MUTEX (rcCounterMutex)
#endif
    static unsigned long rcCounter = 0;

    char     channelName [50];
    Tcl_Obj* res = Tcl_NewStringObj ("rc", -1);

#ifdef TCL_THREADS
    Tcl_MutexLock (&rcCounterMutex);
#endif

    sprintf (channelName, "%lu", (unsigned long) rcCounter);
    rcCounter ++;

#ifdef TCL_THREADS
    Tcl_MutexUnlock (&rcCounterMutex);
#endif

    Tcl_AppendStringsToObj (res, channelName, (char*) NULL);
    return res;
}
 

static void
RcFree (rcPtr)
     ReflectingChannel* rcPtr;
{
    Channel* chanPtr = (Channel*) rcPtr->chan;
    int      i, n;

    if (chanPtr->typePtr != &tclRChannelType) {
        /* Delete a cloned ChannelType structure. */
        ckfree ((char*) chanPtr->typePtr);
    }

    n = rcPtr->argc - 2;
    for (i = 0; i < n; i++) {
        Tcl_DecrRefCount (rcPtr->argv[i]);
    }

    ckfree ((char*) rcPtr->argv);
    ckfree ((char*) rcPtr);
    return;
}
 
/*
 *----------------------------------------------------------------------
 *
 * RcInvokeTclMethod --
 *
 *	This function is used to invoke the Tcl level of a reflected
 *	channel. It handles all the command assembly, invokation, and
 *	generic state and result mgmt.
 *
 * Results:
 *      Result code and data as returned by the method.
 *
 * Side effects:
 *	Arbitrary, as it calls upo na Tcl script.
 *
 *----------------------------------------------------------------------
 */

static void
RcInvokeTclMethod (rcPtr, method, argone, argtwo, result, resultObj, capture)
     ReflectingChannel* rcPtr;
     CONST char*        method;
     Tcl_Obj*           argone;    /* NULL'able */
     Tcl_Obj*           argtwo;    /* NULL'able */
     int*               result;    /* NULL'able */
     Tcl_Obj**          resultObj; /* NULL'able */
     int                capture;
{
    /* Thread redirection was done by higher layers */
    /* ASSERT: Tcl_GetCurrentThread () == rcPtr->thread */

    int             cmdc;           /* #words in constructed command */
    Tcl_Obj*        methObj = NULL; /* Method name in object form */
    Tcl_InterpState sr;             /* State of handler interp */
    int             res;            /* Result code of method invokation */
    Tcl_Obj*        resObj  = NULL; /* Result of method invokation. */

    /* NOTE (5): Decide impl. issue: Cache objects with method names ?
     * NOTE (5): Requires TSD data as reflections can be created in
     * NOTE (5): many different threads.
     * NOTE (5): ---
     */

    /* Insert method into the pre-allocated area, after the command
     * prefix, before the channel id.
     */

    methObj = Tcl_NewStringObj (method, -1);
    if (methObj == (Tcl_Obj*) NULL) {
        Tcl_Panic ("Out of memory in RcInvokeTclMethod");
    }
    Tcl_IncrRefCount (methObj);
    rcPtr->argv [rcPtr->argc - 2] = methObj;

    /* Append the additional argument containing method specific
     * details behind the channel id. If specified.
     */

    cmdc = rcPtr->argc ;
    if (argone) {
        Tcl_IncrRefCount (argone);
	rcPtr->argv [cmdc] = argone;
	cmdc++;
    }
    if (argtwo) {
        Tcl_IncrRefCount (argtwo);
	rcPtr->argv [cmdc] = argtwo;
	cmdc++;
    }

    /* And run the handler ...  This is done in auch a manner which
     * leaves any existing state intact.
     */

    sr  = Tcl_SaveInterpState (rcPtr->interp, 0 /* Dummy */);
    res = Tcl_EvalObjv        (rcPtr->interp, cmdc, rcPtr->argv, TCL_EVAL_GLOBAL);

    /* We do not try to extract the result information if the caller has no
     * interest in it. I.e. there is no need to put effort into creating
     * something which is discarded immediately after.
     */

    if (resultObj) {
	if ((res == TCL_OK) || !capture) {
	    /* Ok result taken as is, also if the caller requests that there
	     * is no capture.
	     */

	    resObj = Tcl_GetObjResult (rcPtr->interp);
	} else {
	    /* Non-ok ressult is always treated as an error.
	     * We have to capture the full state of the result,
	     * including additional options.
	     */

	    res    = TCL_ERROR;
	    resObj = RcErrorMarshall (rcPtr->interp);
	}
	Tcl_IncrRefCount(resObj);
    }
    Tcl_RestoreInterpState (rcPtr->interp, sr);

    /* ... */

    /* Cleanup of the dynamic parts of the command */

    Tcl_DecrRefCount (methObj);
    if (argone) {Tcl_DecrRefCount (argone);}
    if (argtwo) {Tcl_DecrRefCount (argtwo);}

    /* The resObj has a ref count of 1 at this location.  This means
     * that the caller of RcInvoke has to dispose of it (but only if
     * it was returned to it).
     */

    if (result) {
        *result = res;
    }
    if (resultObj) {
        *resultObj = resObj;
    }
    /* There no need to handle the case where nothing is returned, because for
     * that case resObj was not set anyway.
     */
}
 
#ifdef TCL_THREADS
static void
RcForwardOp (rcPtr, op, dst, param)
  ReflectingChannel* rcPtr; /* Channel instance */
  RcOperation        op;    /* Forwarded driver operation */
  Tcl_ThreadId       dst;   /* Destination thread */
  CONST VOID*        param; /* Arguments */
{
    RcForwardingEvent*  evPtr;
    RcForwardingResult* resultPtr;
    int                 result;

    /* Create and initialize the event and data structures */

    evPtr     = (RcForwardingEvent*)  ckalloc (sizeof (RcForwardingEvent));
    resultPtr = (RcForwardingResult*) ckalloc (sizeof (RcForwardingResult));

    evPtr->event.proc = RcForwardProc;
    evPtr->resultPtr  = resultPtr;
    evPtr->op         = op;
    evPtr->rcPtr      = rcPtr;
    evPtr->param      = param;

    resultPtr->src    = Tcl_GetCurrentThread ();
    resultPtr->dst    = dst;
    resultPtr->done   = (Tcl_Condition) NULL;
    resultPtr->result = -1;
    resultPtr->evPtr  = evPtr;

    /* Now execute the forward */

    Tcl_MutexLock(&rcForwardMutex);
    TclSpliceIn(resultPtr, forwardList);

    /*
     * Ensure cleanup of the event if any of the two involved threads
     * exits while this event is pending or in progress.
     */

    Tcl_CreateThreadExitHandler(RcSrcExitProc, (ClientData) evPtr);
    Tcl_CreateThreadExitHandler(RcDstExitProc, (ClientData) evPtr);

    /*
     * Queue the event and poke the other thread's notifier.
     */

    Tcl_ThreadQueueEvent(dst, (Tcl_Event*)evPtr, TCL_QUEUE_TAIL);
    Tcl_ThreadAlert(dst);

    /*
     * (*) Block until the other thread has either processed the transfer
     * or rejected it.
     */

    while (resultPtr->result < 0) {
        /* NOTE (1): Is it possible that the current thread goes away while waiting here ?
	 * NOTE (1): IOW Is it possible that "RcSrcExitProc" is called while we are here ?
	 * NOTE (1): See complementary note (2) in "RcSrcExitProc"
	 * NOTE (1): ---
	 */

        Tcl_ConditionWait(&resultPtr->done, &rcForwardMutex, NULL);
    }

    /*
     * Unlink result from the forwarder list.
     */

    TclSpliceOut(resultPtr, forwardList);

    resultPtr->nextPtr  = NULL;
    resultPtr->prevPtr  = NULL;

    Tcl_MutexUnlock(&rcForwardMutex);
    Tcl_ConditionFinalize(&resultPtr->done);

    /*
     * Kill the cleanup handlers now, and the result structure as well,
     * before returning the success code.
     *
     * Note: The event structure has already been deleted.
     */

    Tcl_DeleteThreadExitHandler(RcSrcExitProc, (ClientData) evPtr);
    Tcl_DeleteThreadExitHandler(RcDstExitProc, (ClientData) evPtr);
    
    result =  resultPtr->result;
    ckfree ((char*) resultPtr);
}
 
static int
RcForwardProc (evGPtr, mask)
     Tcl_Event *evGPtr; 
     int mask;
{
    /* Notes regarding access to the referenced data.
     *
     * In principle the data belongs to the originating thread (see
     * evPtr->src), however this thread is currently blocked at (*),
     * i.e. quiescent. Because of this we can treat the data as
     * belonging to us, without fear of race conditions. I.e. we can
     * read and write as we like.
     *
     * The only thing we cannot be sure of is the resultPtr. This can be
     * be NULLed if the originating thread went away while the event
     * is handled here now.
     */

    RcForwardingEvent*  evPtr     = (RcForwardingEvent*) evGPtr;
    RcForwardingResult* resultPtr = evPtr->resultPtr;
    ReflectingChannel*  rcPtr     = evPtr->rcPtr;
    Tcl_Interp*         interp    = rcPtr->interp;
    RcForwardParamBase* paramPtr  = (RcForwardParamBase*) evPtr->param;
    int                 res       = TCL_OK; /* Result code   of RcInvokeTclMethod */
    Tcl_Obj*            resObj    = NULL;   /* Interp result of RcInvokeTclMethod */

    /* Ignore the event if no one is waiting for its result anymore.
     */

    if (!resultPtr) {
        return 1;
    }

    paramPtr->code = TCL_OK;
    paramPtr->msg  = NULL;
    paramPtr->vol  = 0;

    switch (evPtr->op) {
      /* The destination thread for the following operations is
       * rcPtr->thread, which contains rcPtr->interp, the interp
       * we have to call upon for the driver.
       */

    case RcOpClose:
      {
	  /* No parameters/results */
	  RcInvokeTclMethod (rcPtr, "finalize", NULL, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	     RcForwardSetObjError (paramPtr, resObj);
	  }

	  /* Freeing is done here, in the origin thread, because the
	   * argv[] objects belong to this thread. Deallocating them
	   * in a different thread is not allowed
	   */

	  RcFree (rcPtr);
      }
      break;

    case RcOpInput:
      {
	  RcForwardParamInput* p = (RcForwardParamInput*) paramPtr;
	  Tcl_Obj*     toReadObj = Tcl_NewIntObj (p->toRead);

	  if (toReadObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcInput");
	  }

	  RcInvokeTclMethod (rcPtr, "read", toReadObj, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	      p->toRead = -1;
	  } else {
	      /* Process a regular result. */

	      int            bytec; /* Number of returned bytes */
	      unsigned char* bytev; /* Array of returned bytes */

	      bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);

	      if (p->toRead < bytec) {
		  RcForwardSetStaticError (paramPtr, msg_read_toomuch);
		  p->toRead   = -1;

	      } else {
	          if (bytec > 0) {
		      memcpy (p->buf, bytev, bytec);
		  }

		  p->toRead = bytec;
	      }
	  }
      }
      break;

    case RcOpOutput:
      {
	  RcForwardParamOutput* p = (RcForwardParamOutput*) paramPtr;
	  Tcl_Obj*         bufObj = Tcl_NewByteArrayObj((unsigned char*) p->buf, p->toWrite);

	  if (bufObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcOutput");
	  }

	  RcInvokeTclMethod (rcPtr, "write", bufObj, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	      p->toWrite = -1;
	  } else {
	      /* Process a regular result. */

	      int written;

	      res = Tcl_GetIntFromObj (interp, resObj, &written);
	      if (res != TCL_OK) {

		  RcForwardSetObjError (paramPtr, RcErrorMarshall (interp));
		  p->toWrite = -1;

	      } else if ((written == 0) || (p->toWrite < written)) {

		  RcForwardSetStaticError (paramPtr, msg_write_toomuch);
		  p->toWrite = -1;

	      } else {
		  p->toWrite = written;
	      }
	  }
      }
      break;

    case RcOpSeek:
      {
	  RcForwardParamSeek* p = (RcForwardParamSeek*) paramPtr;

	  Tcl_Obj*       offObj;
	  Tcl_Obj*       baseObj;

	  offObj = Tcl_NewWideIntObj(p->offset);
	  if (offObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcSeekWide");
	  }

	  baseObj = Tcl_NewStringObj((p->seekMode == SEEK_SET) ?
				     "start" :
				     ((p->seekMode == SEEK_CUR) ?
				      "current" :
				      "end"), -1);

	  if (baseObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcSeekWide");
	  }

	  RcInvokeTclMethod (rcPtr, "seek", offObj, baseObj,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	      p->offset = -1;
	  } else {
	      /* Process a regular result. If the type is wrong this
	       * may change into an error.
	       */

	      Tcl_WideInt newLoc;
	      res = Tcl_GetWideIntFromObj (interp, resObj, &newLoc);

	      if (res == TCL_OK) {
		  if (newLoc < Tcl_LongAsWide (0)) {
		      RcForwardSetStaticError (paramPtr, msg_seek_beforestart);
		      p->offset = -1;
		  } else {
		      p->offset = newLoc;
		  }
	      } else {
		  RcForwardSetObjError (paramPtr, RcErrorMarshall (interp));
		  p->offset = -1;
	      }
	  }
      }
      break;

    case RcOpWatch:
      {
	  RcForwardParamWatch* p = (RcForwardParamWatch*) paramPtr;

	  Tcl_Obj* maskObj = RcDecodeEventMask (p->mask);
	  RcInvokeTclMethod (rcPtr, "watch", maskObj, NULL,
			     NULL, NULL, NO_CAPTURE);
	  Tcl_DecrRefCount (maskObj);
      }
    break;

    case RcOpBlock:
      {
	  RcForwardParamBlock* p = (RcForwardParamBlock*) evPtr->param;
	  Tcl_Obj*      blockObj = Tcl_NewBooleanObj(!p->nonblocking);

	  if (blockObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcBlock");
	  }

	  RcInvokeTclMethod (rcPtr, "blocking", blockObj, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	  }
      }
      break;

    case RcOpSetOpt:
      {
	  RcForwardParamSetOpt* p = (RcForwardParamSetOpt*) paramPtr;
	  Tcl_Obj* optionObj;
	  Tcl_Obj* valueObj;

	  optionObj = Tcl_NewStringObj(p->name,-1);
	  if (optionObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcSetOption");
	  }

	  valueObj = Tcl_NewStringObj(p->value,-1);
	  if (valueObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcSetOption");
	  }

	  RcInvokeTclMethod (rcPtr, "configure", optionObj, valueObj,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	  }
      }
      break;

    case RcOpGetOpt:
      {
	  /* Retrieve the value of one option */

	  RcForwardParamGetOpt* p = (RcForwardParamGetOpt*) paramPtr;
	  Tcl_Obj*           optionObj;

	  optionObj = Tcl_NewStringObj(p->name,-1);
	  if (optionObj == (Tcl_Obj*) NULL) {
	      Tcl_Panic ("Out of memory in RcGetOption");
	  }

	  RcInvokeTclMethod (rcPtr, "cget", optionObj, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	  } else {
	      Tcl_DStringAppend (p->value, Tcl_GetString (resObj), -1);
	  }
      }
      break;

    case RcOpGetOptAll:
      {
	  /* Retrieve all options. */

	  RcForwardParamGetOpt* p = (RcForwardParamGetOpt*) paramPtr;

	  RcInvokeTclMethod (rcPtr, "cgetall", NULL, NULL,
			     &res, &resObj, DO_CAPTURE);

	  if (res != TCL_OK) {
	      RcForwardSetObjError (paramPtr, resObj);
	  } else {
	      /* Extract list, validate that it is a list, and
	       * #elements. See NOTE (4) as well.
	       */

	      int       listc;
	      Tcl_Obj** listv;

	      res = Tcl_ListObjGetElements (interp, resObj, &listc, &listv);
	      if (res != TCL_OK) {
		  RcForwardSetObjError (paramPtr, RcErrorMarshall (interp));

	      } else if ((listc % 2) == 1) {
	          /* Odd number of elements is wrong.
		   * [x].
		   */

	          char* buf = ckalloc (200);
		  sprintf (buf,
			   "{Expected list with even number of elements, got %d %s instead}",
			   listc,
			   (listc == 1 ? "element" : "elements"));
		  
		  RcForwardSetDynError (paramPtr, buf);
	      } else {
		  int len;
		  char* str = Tcl_GetStringFromObj (resObj, &len);

		  if (len) {
		      Tcl_DStringAppend (p->value, " ", 1);
		      Tcl_DStringAppend (p->value, str, len);
		  }
	      }
	  }
      }
      break;

    default:
      /* Bad operation code */
      Tcl_Panic ("Bad operation code in RcForwardProc");
      break;
    }

    /* Remove the reference we held on the result of the invoke, if we had
     * such
     */
    if (resObj != NULL) {
	Tcl_DecrRefCount (resObj);
    }

    if (resultPtr) {
        /*
	 * Report the forwarding result synchronously to the waiting
	 * caller. This unblocks (*) as well. This is wrapped into a
	 * conditional because the caller may have exited in the mean
	 * time.
	 */

        Tcl_MutexLock(&rcForwardMutex);
	resultPtr->result = TCL_OK;
	Tcl_ConditionNotify(&resultPtr->done);
	Tcl_MutexUnlock(&rcForwardMutex);
    }

    return 1;
}
 

static void
RcSrcExitProc (clientData)
     ClientData clientData;
{
  RcForwardingEvent*  evPtr = (RcForwardingEvent*) clientData;
  RcForwardingResult* resultPtr;
  RcForwardParamBase* paramPtr;

  /* NOTE (2): Can this handler be called with the originator blocked ?
   * NOTE (2): ---
   */

  /* The originator for the event exited. It is not sure if this
   * can happen, as the originator should be blocked at (*) while
   * the event is in transit/pending.
   */

  /*
   * We make sure that the event cannot refer to the result anymore,
   * remove it from the list of pending results and free the
   * structure. Locking the access ensures that we cannot get in
   * conflict with "RcForwardProc", should it already execute the
   * event.
   */

  Tcl_MutexLock(&rcForwardMutex);

  resultPtr = evPtr->resultPtr;
  paramPtr  = (RcForwardParamBase*) evPtr->param;

  evPtr->resultPtr  = NULL;
  resultPtr->evPtr  = NULL;
  resultPtr->result = TCL_ERROR;

  RcForwardSetStaticError (paramPtr, msg_send_originlost);

  /* See below: TclSpliceOut(resultPtr, forwardList); */

  Tcl_MutexUnlock(&rcForwardMutex);

  /*
   * This unlocks (*). The structure will be spliced out and freed by
   * "RcForwardProc". Maybe.
   */

  Tcl_ConditionNotify(&resultPtr->done);
}
 

static void
RcDstExitProc (clientData)
     ClientData clientData;
{
  RcForwardingEvent*  evPtr     = (RcForwardingEvent*) clientData;
  RcForwardingResult* resultPtr = evPtr->resultPtr;
  RcForwardParamBase* paramPtr  = (RcForwardParamBase*) evPtr->param;

  /* NOTE (3): It is not clear if the event still exists when this handler is called..
   * NOTE (3): We might have to use 'resultPtr' as our clientData instead.
   * NOTE (3): ---
   */

  /* The receiver for the event exited, before processing the
   * event. We detach the result now, wake the originator up
   * and signal failure.
   */

  evPtr->resultPtr = NULL;
  resultPtr->evPtr  = NULL;
  resultPtr->result = TCL_ERROR;

  RcForwardSetStaticError (paramPtr, msg_send_dstlost);

  Tcl_ConditionNotify(&resultPtr->done);
}
 

static void
RcForwardSetObjError (p,obj)
     RcForwardParamBase* p;
     Tcl_Obj*            obj;
{
    int   len;
    char* msg;

    msg = Tcl_GetStringFromObj (obj, &len);

    p->code = TCL_ERROR;
    p->vol  = 1;
    p->msg  = strcpy(ckalloc (1+len), msg);
}
#endif
 
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */

Changes to generic/tclInt.h.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1526
1527
1528
1529
1530
1531
1532









1533
1534
1535
1536
1537
1538
1539
1540
1541
1542




































1543
1544
1545
1546
1547
1548
1549
....
1965
1966
1967
1968
1969
1970
1971






1972
1973
1974
1975
1976
1977
1978
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 1998-19/99 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclInt.h,v 1.202.2.33 2005/08/24 21:49:22 dgp Exp $
 */

#ifndef _TCLINT
#define _TCLINT

/*
 * Some numerics configuration options
................................................................................
				 * we're not processing an ensemble. */
	int numRemovedObjs;	/* How many arguments have been stripped off
				 * because of ensemble processing. */
	int numInsertedObjs;	/* How many of the current arguments were
				 * inserted by an ensemble. */
    } ensembleRewrite;










    /*
     * Statistical information about the bytecode compiler and interpreter's
     * operation.
     */

#ifdef TCL_COMPILE_STATS
    ByteCodeStats stats;	/* Holds compilation and execution
				 * statistics for this interpreter. */
#endif /* TCL_COMPILE_STATS */	  
} Interp;





































/*
 * EvalFlag bits for Interp structures:
 *
 * TCL_ALLOW_EXCEPTIONS	1 means it's OK for the script to terminate with
 *			a code other than TCL_OK or TCL_ERROR;	0 means
 *			codes other than these should be turned into errors.
................................................................................
			    Tcl_Interp *interp, Tcl_Obj *objPtr));
MODULE_SCOPE int	TclArraySet _ANSI_ARGS_((Tcl_Interp *interp,
			    Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj));
MODULE_SCOPE double     TclBignumToDouble _ANSI_ARGS_((mp_int* bignum));
MODULE_SCOPE double	TclCeil _ANSI_ARGS_((mp_int* a));
MODULE_SCOPE int	TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp,
			    CONST char *value));






MODULE_SCOPE void	TclCleanupLiteralTable _ANSI_ARGS_((
			    Tcl_Interp* interp, LiteralTable* tablePtr));
MODULE_SCOPE int	TclDoubleDigits _ANSI_ARGS_((char* buf,
						     double value,
						     int* signum));
MODULE_SCOPE void	TclExpandTokenArray _ANSI_ARGS_((
			    Tcl_Parse *parsePtr));







|







 







>
>
>
>
>
>
>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
....
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 1998-19/99 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclInt.h,v 1.202.2.34 2005/08/25 15:46:31 dgp Exp $
 */

#ifndef _TCLINT
#define _TCLINT

/*
 * Some numerics configuration options
................................................................................
				 * we're not processing an ensemble. */
	int numRemovedObjs;	/* How many arguments have been stripped off
				 * because of ensemble processing. */
	int numInsertedObjs;	/* How many of the current arguments were
				 * inserted by an ensemble. */
    } ensembleRewrite;

    /* TIP #219 ... Global info for the I/O system ...
     * Error message set by channel drivers, for the propagation of
     * arbitrary Tcl errors. This information, if present (chanMsg not
     * NULL), takes precedence over a posix error code returned by a
     * channel operation.
     */

    Tcl_Obj* chanMsg;

    /*
     * Statistical information about the bytecode compiler and interpreter's
     * operation.
     */

#ifdef TCL_COMPILE_STATS
    ByteCodeStats stats;	/* Holds compilation and execution
				 * statistics for this interpreter. */
#endif /* TCL_COMPILE_STATS */	  
} Interp;

/*
 * General list of interpreters. Doubly linked for easier
 * removal of items deep in the list.
 */

typedef struct InterpList {
   Interp* interpPtr;
   struct InterpList* prevPtr;
   struct InterpList* nextPtr;
} InterpList;

/*
 * Macros for splicing into and out of doubly linked lists.
 * They assume existence of struct items 'prevPtr' and 'nextPtr'.
 *
 * a = element to add or remove.
 * b = list head.
 *
 * TclSpliceIn adds to the head of the list.
 */

#define TclSpliceIn(a,b)                       \
    (a)->nextPtr = (b);                        \
    if ((b) != NULL)                           \
        (b)->prevPtr = (a);                    \
    (a)->prevPtr = NULL, (b) = (a);

#define TclSpliceOut(a,b)                      \
    if ((a)->prevPtr != NULL)                  \
        (a)->prevPtr->nextPtr = (a)->nextPtr;  \
    else                                       \
        (b) = (a)->nextPtr;                    \
    if ((a)->nextPtr != NULL)                  \
        (a)->nextPtr->prevPtr = (a)->prevPtr;


/*
 * EvalFlag bits for Interp structures:
 *
 * TCL_ALLOW_EXCEPTIONS	1 means it's OK for the script to terminate with
 *			a code other than TCL_OK or TCL_ERROR;	0 means
 *			codes other than these should be turned into errors.
................................................................................
			    Tcl_Interp *interp, Tcl_Obj *objPtr));
MODULE_SCOPE int	TclArraySet _ANSI_ARGS_((Tcl_Interp *interp,
			    Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj));
MODULE_SCOPE double     TclBignumToDouble _ANSI_ARGS_((mp_int* bignum));
MODULE_SCOPE double	TclCeil _ANSI_ARGS_((mp_int* a));
MODULE_SCOPE int	TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp,
			    CONST char *value));
MODULE_SCOPE int        TclChanCreateObjCmd _ANSI_ARGS_((ClientData clientData,
			    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
MODULE_SCOPE int        TclChanPostEventObjCmd _ANSI_ARGS_((ClientData clientData,
			    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
MODULE_SCOPE int        TclChanCaughtErrorBypass _ANSI_ARGS_((Tcl_Interp *interp,
			    Tcl_Channel chan));
MODULE_SCOPE void	TclCleanupLiteralTable _ANSI_ARGS_((
			    Tcl_Interp* interp, LiteralTable* tablePtr));
MODULE_SCOPE int	TclDoubleDigits _ANSI_ARGS_((char* buf,
						     double value,
						     int* signum));
MODULE_SCOPE void	TclExpandTokenArray _ANSI_ARGS_((
			    Tcl_Parse *parsePtr));

Changes to generic/tclObj.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 * Copyright (c) 1999 by Scriptics Corporation.
 * Copyright (c) 2001 by ActiveState Corporation.
 * Copyright (c) 2005 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclObj.c,v 1.72.2.30 2005/08/23 18:28:51 kennykb Exp $
 */

#include "tclInt.h"
#include "tommath.h"
#include <float.h>

#define BIGNUM_AUTO_NARROW 1
................................................................................
    (objPtrVar) = (contextPtr)->deletionStack; \
    (contextPtr)->deletionStack = (Tcl_Obj *) (objPtrVar)->bytes

/*
 * Macro to set up the local reference to the deletion context.
 */
#ifndef TCL_THREADS
PendingObjData pendingObjData;
#define ObjInitDeletionContext(contextPtr) \
    PendingObjData *CONST contextPtr = &pendingObjData
#else
Tcl_ThreadDataKey pendingObjDataKey;
#define ObjInitDeletionContext(contextPtr) \
    PendingObjData *CONST contextPtr = (PendingObjData *) \
	    Tcl_GetThreadData(&pendingObjDataKey, sizeof(PendingObjData))







|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 * Copyright (c) 1999 by Scriptics Corporation.
 * Copyright (c) 2001 by ActiveState Corporation.
 * Copyright (c) 2005 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclObj.c,v 1.72.2.31 2005/08/25 15:46:31 dgp Exp $
 */

#include "tclInt.h"
#include "tommath.h"
#include <float.h>

#define BIGNUM_AUTO_NARROW 1
................................................................................
    (objPtrVar) = (contextPtr)->deletionStack; \
    (contextPtr)->deletionStack = (Tcl_Obj *) (objPtrVar)->bytes

/*
 * Macro to set up the local reference to the deletion context.
 */
#ifndef TCL_THREADS
static PendingObjData pendingObjData;
#define ObjInitDeletionContext(contextPtr) \
    PendingObjData *CONST contextPtr = &pendingObjData
#else
Tcl_ThreadDataKey pendingObjDataKey;
#define ObjInitDeletionContext(contextPtr) \
    PendingObjData *CONST contextPtr = (PendingObjData *) \
	    Tcl_GetThreadData(&pendingObjDataKey, sizeof(PendingObjData))

Changes to generic/tclStubInit.c.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
984
985
986
987
988
989
990




991
992
993
 *	This file contains the initializers for the Tcl stub vectors.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
<<<<<<< tclStubInit.c
 * RCS: @(#) $Id: tclStubInit.c,v 1.109.2.15 2005/08/23 06:15:21 dgp Exp $
=======
 * RCS: @(#) $Id: tclStubInit.c,v 1.109.2.15 2005/08/23 06:15:21 dgp Exp $
>>>>>>> 1.121
 */

#include "tclInt.h"

/*
 * Remove macros that will interfere with the definitions below.
 */
................................................................................
    Tcl_ChannelThreadActionProc, /* 554 */
    Tcl_NewBignumObj, /* 555 */
    Tcl_DbNewBignumObj, /* 556 */
    Tcl_SetBignumObj, /* 557 */
    Tcl_GetBignumFromObj, /* 558 */
    Tcl_TruncateChannel, /* 559 */
    Tcl_ChannelTruncateProc, /* 560 */




};

/* !END!: Do not edit above this line. */







<
|
<
<
<







 







>
>
>
>



4
5
6
7
8
9
10

11



12
13
14
15
16
17
18
...
980
981
982
983
984
985
986
987
988
989
990
991
992
993
 *	This file contains the initializers for the Tcl stub vectors.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *

 * RCS: @(#) $Id: tclStubInit.c,v 1.109.2.16 2005/08/25 15:46:31 dgp Exp $



 */

#include "tclInt.h"

/*
 * Remove macros that will interfere with the definitions below.
 */
................................................................................
    Tcl_ChannelThreadActionProc, /* 554 */
    Tcl_NewBignumObj, /* 555 */
    Tcl_DbNewBignumObj, /* 556 */
    Tcl_SetBignumObj, /* 557 */
    Tcl_GetBignumFromObj, /* 558 */
    Tcl_TruncateChannel, /* 559 */
    Tcl_ChannelTruncateProc, /* 560 */
    Tcl_SetChannelErrorInterp, /* 561 */
    Tcl_GetChannelErrorInterp, /* 562 */
    Tcl_SetChannelError, /* 563 */
    Tcl_GetChannelError, /* 564 */
};

/* !END!: Do not edit above this line. */

Changes to generic/tclTest.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
116
117
118
119
120
121
122














123
124
125
126
127
128
129
....
5491
5492
5493
5494
5495
5496
5497






















5498

5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511



































5512


5513
5514
5515
5516
5517




5518








5519
5520
5521
5522
5523
5524
5525
....
5765
5766
5767
5768
5769
5770
5771








5772
5773
5774
5775
5776
5777
5778




5779
5780
5781
5782
5783
5784
5785
....
6811
6812
6813
6814
6815
6816
6817








 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-2000 Ajuba Solutions.
 * Copyright (c) 2003 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclTest.c,v 1.86.2.5 2005/08/17 19:12:10 kennykb Exp $
 */

#define TCL_TEST
#include "tclInt.h"

/*
 * Required for Testregexp*Cmd
................................................................................
 */
typedef struct TestEvent {
    Tcl_Event header;		/* Header common to all events */
    Tcl_Interp* interp;		/* Interpreter that will handle the event */
    Tcl_Obj* command;		/* Command to evaluate when the event occurs */
    Tcl_Obj* tag;		/* Tag for this event used to delete it */
} TestEvent;















/*
 * Forward declarations for procedures defined later in this file:
 */

int			Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
static int		AsyncHandlerProc _ANSI_ARGS_((ClientData clientData,
................................................................................
    }
    cmdName = argv[1];
    len = strlen(cmdName);

    chanPtr = (Channel *) NULL;

    if (argc > 2) {






















        chan = Tcl_GetChannel(interp, argv[2], &mode);

        if (chan == (Tcl_Channel) NULL) {
            return TCL_ERROR;
        }
        chanPtr		= (Channel *) chan;
	statePtr	= chanPtr->state;
        chanPtr		= statePtr->topChanPtr;
	chan		= (Tcl_Channel) chanPtr;
    } else {
	/* lint */
	statePtr	= NULL;
	chan		= NULL;
    }




































    if ((cmdName[0] == 'c') && (strncmp(cmdName, "cut", len) == 0)) {


        if (argc != 3) {
            Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
                    " cut channelName\"", (char *) NULL);
            return TCL_ERROR;
        }




        Tcl_CutChannel(chan);








        return TCL_OK;
    }

    if ((cmdName[0] == 'c') &&
	    (strncmp(cmdName, "clearchannelhandlers", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
................................................................................
        }
        
        TclFormatInt(buf, statePtr->refCount);
        Tcl_AppendResult(interp, buf, (char *) NULL);
        return TCL_OK;
    }









    if ((cmdName[0] == 's') && (strncmp(cmdName, "splice", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "channel name required", (char *) NULL);
            return TCL_ERROR;
        }

        Tcl_SpliceChannel(chan);




        return TCL_OK;
    }

    if ((cmdName[0] == 't') && (strncmp(cmdName, "type", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "channel name required",
                    (char *) NULL);
................................................................................
	    total += val;
	}
	TclFormatInt(buf, total);
	Tcl_SetResult(interp, buf, TCL_VOLATILE);
	return TCL_OK;
    }
}















|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
|
|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>





>
>
>
>

>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







>
>
>
>







 







>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
....
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
....
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
....
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-2000 Ajuba Solutions.
 * Copyright (c) 2003 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclTest.c,v 1.86.2.6 2005/08/25 15:46:31 dgp Exp $
 */

#define TCL_TEST
#include "tclInt.h"

/*
 * Required for Testregexp*Cmd
................................................................................
 */
typedef struct TestEvent {
    Tcl_Event header;		/* Header common to all events */
    Tcl_Interp* interp;		/* Interpreter that will handle the event */
    Tcl_Obj* command;		/* Command to evaluate when the event occurs */
    Tcl_Obj* tag;		/* Tag for this event used to delete it */
} TestEvent;


/*
 * Simple detach/attach facility for testchannel cut|splice.
 * Allow testing of channel transfer in core testsuite.
 */

typedef struct TestChannel {
    Tcl_Channel         chan;    /* Detached channel */
    struct TestChannel* nextPtr; /* Next in pool of detached channels */
} TestChannel;

static TestChannel* firstDetached;


/*
 * Forward declarations for procedures defined later in this file:
 */

int			Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
static int		AsyncHandlerProc _ANSI_ARGS_((ClientData clientData,
................................................................................
    }
    cmdName = argv[1];
    len = strlen(cmdName);

    chanPtr = (Channel *) NULL;

    if (argc > 2) {
        if ((cmdName[0] == 's') && (strncmp(cmdName, "splice", len) == 0)) {
	    /* For splice access the pool of detached channels.
	     * Locate channel, remove from the list.
	     */

	    TestChannel** nextPtrPtr;
	    TestChannel*  curPtr;

	    chan = (Tcl_Channel) NULL;
	    for (nextPtrPtr = &firstDetached, curPtr = firstDetached;
		 curPtr != NULL;
		 nextPtrPtr = &(curPtr->nextPtr), curPtr = curPtr->nextPtr) {

	        if (strcmp (argv[2], Tcl_GetChannelName (curPtr->chan)) == 0) {
		    *nextPtrPtr    = curPtr->nextPtr;
		    curPtr->nextPtr = NULL;
		    chan = curPtr->chan;
		    ckfree ((char*) curPtr);
		    break;
		}
	    }
	} else {
	    chan = Tcl_GetChannel(interp, argv[2], &mode);
	}
	if (chan == (Tcl_Channel) NULL) {
	    return TCL_ERROR;
	}
        chanPtr		= (Channel *) chan;
	statePtr	= chanPtr->state;
        chanPtr		= statePtr->topChanPtr;
	chan		= (Tcl_Channel) chanPtr;
    } else {
	/* lint */
	statePtr	= NULL;
	chan		= NULL;
    }

    if ((cmdName[0] == 's') && (strncmp(cmdName, "setchannelerror", len) == 0)) {

	Tcl_Obj* msg = Tcl_NewStringObj (argv [3],-1);

	Tcl_IncrRefCount (msg);
	Tcl_SetChannelError (chan, msg);
	Tcl_DecrRefCount (msg);

	Tcl_GetChannelError (chan, &msg);
	Tcl_SetObjResult (interp, msg);
	Tcl_DecrRefCount (msg);
	return TCL_OK;
    }
    if ((cmdName[0] == 's') && (strncmp(cmdName, "setchannelerrorinterp", len) == 0)) {

	Tcl_Obj* msg = Tcl_NewStringObj (argv [3],-1);

	Tcl_IncrRefCount (msg);
	Tcl_SetChannelErrorInterp (interp, msg);
	Tcl_DecrRefCount (msg);

	Tcl_GetChannelErrorInterp (interp, &msg);
	Tcl_SetObjResult (interp, msg);
	Tcl_DecrRefCount (msg);
	return TCL_OK;
    }

    /*
     * "cut" is actually more a simplified detach facility as provided
     * by the Thread package. Without the safeguards of a regular
     * command (no checking that the command is truly cut'able, no
     * mutexes for thread-safety). Its complementary command is
     * "splice", see below.
     */

    if ((cmdName[0] == 'c') && (strncmp(cmdName, "cut", len) == 0)) {
        TestChannel* det;

        if (argc != 3) {
            Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
                    " cut channelName\"", (char *) NULL);
            return TCL_ERROR;
        }

	Tcl_RegisterChannel((Tcl_Interp *) NULL, chan); /* prevent closing */
	Tcl_UnregisterChannel(interp, chan);

        Tcl_CutChannel(chan);

	/* Remember the channel in the pool of detached channels */

	det = (TestChannel*) ckalloc (sizeof(TestChannel));
	det->chan     = chan;
	det->nextPtr  = firstDetached;
	firstDetached = det;

        return TCL_OK;
    }

    if ((cmdName[0] == 'c') &&
	    (strncmp(cmdName, "clearchannelhandlers", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
................................................................................
        }
        
        TclFormatInt(buf, statePtr->refCount);
        Tcl_AppendResult(interp, buf, (char *) NULL);
        return TCL_OK;
    }

    /*
     * "splice" is actually more a simplified attach facility as
     * provided by the Thread package. Without the safeguards of a
     * regular command (no checking that the command is truly
     * cut'able, no mutexes for thread-safety). Its complementary
     * command is "cut", see above.
     */

    if ((cmdName[0] == 's') && (strncmp(cmdName, "splice", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "channel name required", (char *) NULL);
            return TCL_ERROR;
        }

        Tcl_SpliceChannel(chan);

	Tcl_RegisterChannel(interp, chan);
	Tcl_UnregisterChannel((Tcl_Interp *)NULL, chan);

        return TCL_OK;
    }

    if ((cmdName[0] == 't') && (strncmp(cmdName, "type", len) == 0)) {
        if (argc != 3) {
            Tcl_AppendResult(interp, "channel name required",
                    (char *) NULL);
................................................................................
	    total += val;
	}
	TclFormatInt(buf, total);
	Tcl_SetResult(interp, buf, TCL_VOLATILE);
	return TCL_OK;
    }
}
 
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */

Changes to generic/tclThreadTest.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
475
476
477
478
479
480
481






482
483
484
485
486
487
488
 *	Conservation Through Innovation, Limited, with their permission.
 *
 * Copyright (c) 1998 by 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: tclThreadTest.c,v 1.17.2.1 2005/04/10 23:14:57 kennykb Exp $
 */

#include "tclInt.h"

#ifdef TCL_THREADS
/*
 * Each thread has an single instance of the following structure.  There
................................................................................
     * Initialize the interpreter.  This should be more general.
     */

    tsdPtr->interp = Tcl_CreateInterp();
    result = Tcl_Init(tsdPtr->interp);
    result = TclThread_Init(tsdPtr->interp);







    /*
     * Update the list of threads.
     */

    Tcl_MutexLock(&threadMutex);
    ListUpdateInner(tsdPtr);
    /*







|







 







>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
 *	Conservation Through Innovation, Limited, with their permission.
 *
 * Copyright (c) 1998 by 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: tclThreadTest.c,v 1.17.2.2 2005/08/25 15:46:31 dgp Exp $
 */

#include "tclInt.h"

#ifdef TCL_THREADS
/*
 * Each thread has an single instance of the following structure.  There
................................................................................
     * Initialize the interpreter.  This should be more general.
     */

    tsdPtr->interp = Tcl_CreateInterp();
    result = Tcl_Init(tsdPtr->interp);
    result = TclThread_Init(tsdPtr->interp);

    /* This is part of the test facility.
     * Initialize _ALL_ test commands for
     * use by the new thread.
     */
    result = Tcltest_Init(tsdPtr->interp);

    /*
     * Update the list of threads.
     */

    Tcl_MutexLock(&threadMutex);
    ListUpdateInner(tsdPtr);
    /*

Changes to library/init.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
..
69
70
71
72
73
74
75
76
77

78
79
80
81
82

83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
# init.tcl --
#
# Default system startup file for Tcl-based applications.  Defines
# "unknown" procedure and auto-load facilities.
#
# RCS: @(#) $Id: init.tcl,v 1.69.2.4 2005/08/02 18:16:14 dgp Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 Scriptics Corporation.
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
................................................................................
    variable Path [unsupported::EncodingDirs]
    set Dir [file join $::tcl_library encoding]
    if {$Dir ni $Path} {
	lappend Path $Dir
	unsupported::EncodingDirs $Path
    }

    # Set up the 'chan' ensemble
    namespace eval chan {

	namespace ensemble create -command ::chan -map {
	    blocked	::fblocked
	    close	::close
	    configure	::fconfigure
	    copy	::fcopy

	    eof		::eof
	    event	::fileevent
	    flush	::flush
	    gets	::gets
	    names	{::file channels}

	    puts	::puts
	    read	::read
	    seek	::seek
	    tell	::tell
	    truncate	::tcl::chan::Truncate
	}
    }
}

# Windows specific end of initialization

if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} {
    namespace eval tcl {





|







 







|

>
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# init.tcl --
#
# Default system startup file for Tcl-based applications.  Defines
# "unknown" procedure and auto-load facilities.
#
# RCS: @(#) $Id: init.tcl,v 1.69.2.5 2005/08/25 15:46:31 dgp Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 Scriptics Corporation.
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
................................................................................
    variable Path [unsupported::EncodingDirs]
    set Dir [file join $::tcl_library encoding]
    if {$Dir ni $Path} {
	lappend Path $Dir
	unsupported::EncodingDirs $Path
    }

    # Set up the 'chan' ensemble (TIP #208).
    namespace eval chan {
        # TIP #219. Added methods: create, postevent.
        namespace ensemble create -command ::chan -map {
            blocked     ::fblocked
            close       ::close
            configure   ::fconfigure
            copy        ::fcopy
            create      ::tcl::chan::rCreate
            eof         ::eof
            event       ::fileevent
            flush       ::flush
            gets        ::gets
            names       {::file channels}
            postevent   ::tcl::chan::rPostevent
            puts        ::puts
            read        ::read
            seek        ::seek
            tell        ::tell
            truncate    ::tcl::chan::Truncate
        }
    }
}

# Windows specific end of initialization

if {(![interp issafe]) && ($tcl_platform(platform) eq "windows")} {
    namespace eval tcl {

Deleted library/msgs/af_ZA.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset af_ZA DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset af_ZA TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset af_ZA DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/af_za.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset af_ZA DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset af_ZA TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset af_ZA DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/ar_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_IN DATE_FORMAT "%A %d %B %Y"
    ::msgcat::mcset ar_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset ar_IN DATE_TIME_FORMAT "%A %d %B %Y %I:%M:%S  %z %z"
}
<
<
<
<
<
<












Deleted library/msgs/ar_JO.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_JO DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_JO MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_JO MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































Deleted library/msgs/ar_LB.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_LB DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_LB MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_LB MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































Deleted library/msgs/ar_SY.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_SY DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_SY MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_SY MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631\u0627\u0646"\
        "\u062d\u0632\u064a\u0631"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































Added library/msgs/ar_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_IN DATE_FORMAT "%A %d %B %Y"
    ::msgcat::mcset ar_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset ar_IN DATE_TIME_FORMAT "%A %d %B %Y %I:%M:%S  %z %z"
}

Added library/msgs/ar_jo.msg.















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_JO DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_JO MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_JO MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}

Added library/msgs/ar_lb.msg.















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_LB DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_LB MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_LB MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}

Added library/msgs/ar_sy.msg.















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ar_SY DAYS_OF_WEEK_ABBREV [list \
        "\u0627\u0644\u0623\u062d\u062f"\
        "\u0627\u0644\u0627\u062b\u0646\u064a\u0646"\
        "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621"\
        "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621"\
        "\u0627\u0644\u062e\u0645\u064a\u0633"\
        "\u0627\u0644\u062c\u0645\u0639\u0629"\
        "\u0627\u0644\u0633\u0628\u062a"]
    ::msgcat::mcset ar_SY MONTHS_ABBREV [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631"\
        "\u062d\u0632\u064a\u0631\u0627\u0646"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
    ::msgcat::mcset ar_SY MONTHS_FULL [list \
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0634\u0628\u0627\u0637"\
        "\u0622\u0630\u0627\u0631"\
        "\u0646\u064a\u0633\u0627\u0646"\
        "\u0646\u0648\u0627\u0631\u0627\u0646"\
        "\u062d\u0632\u064a\u0631"\
        "\u062a\u0645\u0648\u0632"\
        "\u0622\u0628"\
        "\u0623\u064a\u0644\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u0623\u0648\u0644"\
        "\u062a\u0634\u0631\u064a\u0646 \u0627\u0644\u062b\u0627\u0646\u064a"\
        "\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u0623\u0648\u0644"\
        ""]
}

Deleted library/msgs/bn_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset bn_IN DATE_FORMAT "%A %d %b %Y"
    ::msgcat::mcset bn_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset bn_IN DATE_TIME_FORMAT "%A %d %b %Y %I:%M:%S  %z %z"
}
<
<
<
<
<
<












Added library/msgs/bn_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset bn_IN DATE_FORMAT "%A %d %b %Y"
    ::msgcat::mcset bn_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset bn_IN DATE_TIME_FORMAT "%A %d %b %Y %I:%M:%S  %z %z"
}

Deleted library/msgs/de_AT.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset de_AT MONTHS_ABBREV [list \
        "J\u00e4n"\
        "Feb"\
        "M\u00e4r"\
        "Apr"\
        "Mai"\
        "Jun"\
        "Jul"\
        "Aug"\
        "Sep"\
        "Okt"\
        "Nov"\
        "Dez"\
        ""]
    ::msgcat::mcset de_AT MONTHS_FULL [list \
        "J\u00e4nner"\
        "Februar"\
        "M\u00e4rz"\
        "April"\
        "Mai"\
        "Juni"\
        "Juli"\
        "August"\
        "September"\
        "Oktober"\
        "November"\
        "Dezember"\
        ""]
    ::msgcat::mcset de_AT DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset de_AT TIME_FORMAT "%T"
    ::msgcat::mcset de_AT TIME_FORMAT_12 "%T"
    ::msgcat::mcset de_AT DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































Deleted library/msgs/de_BE.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset de_BE DAYS_OF_WEEK_ABBREV [list \
        "Son"\
        "Mon"\
        "Die"\
        "Mit"\
        "Don"\
        "Fre"\
        "Sam"]
    ::msgcat::mcset de_BE DAYS_OF_WEEK_FULL [list \
        "Sonntag"\
        "Montag"\
        "Dienstag"\
        "Mittwoch"\
        "Donnerstag"\
        "Freitag"\
        "Samstag"]
    ::msgcat::mcset de_BE MONTHS_ABBREV [list \
        "Jan"\
        "Feb"\
        "M\u00e4r"\
        "Apr"\
        "Mai"\
        "Jun"\
        "Jul"\
        "Aug"\
        "Sep"\
        "Okt"\
        "Nov"\
        "Dez"\
        ""]
    ::msgcat::mcset de_BE MONTHS_FULL [list \
        "Januar"\
        "Februar"\
        "M\u00e4rz"\
        "April"\
        "Mai"\
        "Juni"\
        "Juli"\
        "August"\
        "September"\
        "Oktober"\
        "November"\
        "Dezember"\
        ""]
    ::msgcat::mcset de_BE AM "vorm"
    ::msgcat::mcset de_BE PM "nachm"
    ::msgcat::mcset de_BE DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset de_BE TIME_FORMAT "%T"
    ::msgcat::mcset de_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset de_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































Added library/msgs/de_at.msg.







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset de_AT MONTHS_ABBREV [list \
        "J\u00e4n"\
        "Feb"\
        "M\u00e4r"\
        "Apr"\
        "Mai"\
        "Jun"\
        "Jul"\
        "Aug"\
        "Sep"\
        "Okt"\
        "Nov"\
        "Dez"\
        ""]
    ::msgcat::mcset de_AT MONTHS_FULL [list \
        "J\u00e4nner"\
        "Februar"\
        "M\u00e4rz"\
        "April"\
        "Mai"\
        "Juni"\
        "Juli"\
        "August"\
        "September"\
        "Oktober"\
        "November"\
        "Dezember"\
        ""]
    ::msgcat::mcset de_AT DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset de_AT TIME_FORMAT "%T"
    ::msgcat::mcset de_AT TIME_FORMAT_12 "%T"
    ::msgcat::mcset de_AT DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Added library/msgs/de_be.msg.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset de_BE DAYS_OF_WEEK_ABBREV [list \
        "Son"\
        "Mon"\
        "Die"\
        "Mit"\
        "Don"\
        "Fre"\
        "Sam"]
    ::msgcat::mcset de_BE DAYS_OF_WEEK_FULL [list \
        "Sonntag"\
        "Montag"\
        "Dienstag"\
        "Mittwoch"\
        "Donnerstag"\
        "Freitag"\
        "Samstag"]
    ::msgcat::mcset de_BE MONTHS_ABBREV [list \
        "Jan"\
        "Feb"\
        "M\u00e4r"\
        "Apr"\
        "Mai"\
        "Jun"\
        "Jul"\
        "Aug"\
        "Sep"\
        "Okt"\
        "Nov"\
        "Dez"\
        ""]
    ::msgcat::mcset de_BE MONTHS_FULL [list \
        "Januar"\
        "Februar"\
        "M\u00e4rz"\
        "April"\
        "Mai"\
        "Juni"\
        "Juli"\
        "August"\
        "September"\
        "Oktober"\
        "November"\
        "Dezember"\
        ""]
    ::msgcat::mcset de_BE AM "vorm"
    ::msgcat::mcset de_BE PM "nachm"
    ::msgcat::mcset de_BE DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset de_BE TIME_FORMAT "%T"
    ::msgcat::mcset de_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset de_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/en_AU.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_AU DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset en_AU TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_AU TIME_FORMAT_12 "%I:%M:%S %P %z"
    ::msgcat::mcset en_AU DATE_TIME_FORMAT "%e/%m/%Y %H:%M:%S %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_BE.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_BE DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset en_BE TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset en_BE TIME_FORMAT_12 "%k h %M min %S s %z"
    ::msgcat::mcset en_BE DATE_TIME_FORMAT "%d %b %Y %k:%M:%S %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_BW.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_BW DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_BW TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_BW DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/en_CA.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_CA DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_CA TIME_FORMAT "%r"
    ::msgcat::mcset en_CA TIME_FORMAT_12 "%I:%M:%S %p"
    ::msgcat::mcset en_CA DATE_TIME_FORMAT "%a %d %b %Y %r %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_GB.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_GB DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_GB TIME_FORMAT "%T"
    ::msgcat::mcset en_GB TIME_FORMAT_12 "%T"
    ::msgcat::mcset en_GB DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_HK.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_HK AM "AM"
    ::msgcat::mcset en_HK PM "PM"
    ::msgcat::mcset en_HK DATE_FORMAT "%B %e, %Y"
    ::msgcat::mcset en_HK TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_HK DATE_TIME_FORMAT "%B %e, %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<
<
<
















Deleted library/msgs/en_IE.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_IE DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_IE TIME_FORMAT "%T"
    ::msgcat::mcset en_IE TIME_FORMAT_12 "%T"
    ::msgcat::mcset en_IE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_IN.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_IN AM "AM"
    ::msgcat::mcset en_IN PM "PM"
    ::msgcat::mcset en_IN DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_IN TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_IN DATE_TIME_FORMAT "%d %B %Y %H:%M:%S %z"
}
<
<
<
<
<
<
<
<
















Deleted library/msgs/en_NZ.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_NZ DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset en_NZ TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_NZ TIME_FORMAT_12 "%I:%M:%S %P %z"
    ::msgcat::mcset en_NZ DATE_TIME_FORMAT "%e/%m/%Y %H:%M:%S %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/en_PH.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_PH AM "AM"
    ::msgcat::mcset en_PH PM "PM"
    ::msgcat::mcset en_PH DATE_FORMAT "%B %e, %Y"
    ::msgcat::mcset en_PH TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_PH DATE_TIME_FORMAT "%B %e, %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<
<
<
















Deleted library/msgs/en_SG.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_SG DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset en_SG TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset en_SG DATE_TIME_FORMAT "%d %b %Y %P %I:%M:%S %z"
}
<
<
<
<
<
<












Deleted library/msgs/en_ZA.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_ZA DATE_FORMAT "%Y/%m/%d"
    ::msgcat::mcset en_ZA TIME_FORMAT_12 "%I:%M:%S"
    ::msgcat::mcset en_ZA DATE_TIME_FORMAT "%Y/%m/%d %I:%M:%S %z"
}
<
<
<
<
<
<












Deleted library/msgs/en_ZW.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_ZW DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_ZW TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_ZW DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/en_au.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_AU DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset en_AU TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_AU TIME_FORMAT_12 "%I:%M:%S %P %z"
    ::msgcat::mcset en_AU DATE_TIME_FORMAT "%e/%m/%Y %H:%M:%S %z"
}

Added library/msgs/en_be.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_BE DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset en_BE TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset en_BE TIME_FORMAT_12 "%k h %M min %S s %z"
    ::msgcat::mcset en_BE DATE_TIME_FORMAT "%d %b %Y %k:%M:%S %z"
}

Added library/msgs/en_bw.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_BW DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_BW TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_BW DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Added library/msgs/en_ca.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_CA DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_CA TIME_FORMAT "%r"
    ::msgcat::mcset en_CA TIME_FORMAT_12 "%I:%M:%S %p"
    ::msgcat::mcset en_CA DATE_TIME_FORMAT "%a %d %b %Y %r %z"
}

Added library/msgs/en_gb.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_GB DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_GB TIME_FORMAT "%T"
    ::msgcat::mcset en_GB TIME_FORMAT_12 "%T"
    ::msgcat::mcset en_GB DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Added library/msgs/en_hk.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_HK AM "AM"
    ::msgcat::mcset en_HK PM "PM"
    ::msgcat::mcset en_HK DATE_FORMAT "%B %e, %Y"
    ::msgcat::mcset en_HK TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_HK DATE_TIME_FORMAT "%B %e, %Y %l:%M:%S %P %z"
}

Added library/msgs/en_ie.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_IE DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset en_IE TIME_FORMAT "%T"
    ::msgcat::mcset en_IE TIME_FORMAT_12 "%T"
    ::msgcat::mcset en_IE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Added library/msgs/en_in.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_IN AM "AM"
    ::msgcat::mcset en_IN PM "PM"
    ::msgcat::mcset en_IN DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_IN TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_IN DATE_TIME_FORMAT "%d %B %Y %H:%M:%S %z"
}

Added library/msgs/en_nz.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_NZ DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset en_NZ TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset en_NZ TIME_FORMAT_12 "%I:%M:%S %P %z"
    ::msgcat::mcset en_NZ DATE_TIME_FORMAT "%e/%m/%Y %H:%M:%S %z"
}

Added library/msgs/en_ph.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_PH AM "AM"
    ::msgcat::mcset en_PH PM "PM"
    ::msgcat::mcset en_PH DATE_FORMAT "%B %e, %Y"
    ::msgcat::mcset en_PH TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_PH DATE_TIME_FORMAT "%B %e, %Y %l:%M:%S %P %z"
}

Added library/msgs/en_sg.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_SG DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset en_SG TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset en_SG DATE_TIME_FORMAT "%d %b %Y %P %I:%M:%S %z"
}

Added library/msgs/en_za.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_ZA DATE_FORMAT "%Y/%m/%d"
    ::msgcat::mcset en_ZA TIME_FORMAT_12 "%I:%M:%S"
    ::msgcat::mcset en_ZA DATE_TIME_FORMAT "%Y/%m/%d %I:%M:%S %z"
}

Added library/msgs/en_zw.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset en_ZW DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset en_ZW TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset en_ZW DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/es_AR.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_AR DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_AR TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset es_AR DATE_TIME_FORMAT "%d/%m/%Y %H:%M:%S %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_BO.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_BO DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset es_BO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_BO DATE_TIME_FORMAT "%d-%m-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_CL.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CL DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset es_CL TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CL DATE_TIME_FORMAT "%d-%m-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_CO.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CO DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_CO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CO DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_CR.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CR DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_CR TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CR DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_DO.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_DO DATE_FORMAT "%m/%d/%Y"
    ::msgcat::mcset es_DO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_DO DATE_TIME_FORMAT "%m/%d/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_EC.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_EC DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_EC TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_EC DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_GT.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_GT DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_GT TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_GT DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_HN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_HN DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_HN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_HN DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_MX.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_MX DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_MX TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_MX DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_NI.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_NI DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_NI TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_NI DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_PA.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PA DATE_FORMAT "%m/%d/%Y"
    ::msgcat::mcset es_PA TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PA DATE_TIME_FORMAT "%m/%d/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_PE.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PE DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_PE TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PE DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_PR.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PR DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_PR TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PR DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_PY.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PY DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_PY TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PY DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_SV.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_SV DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_SV TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_SV DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_UY.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_UY DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_UY TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_UY DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Deleted library/msgs/es_VE.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_VE DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_VE TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_VE DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/es_ar.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_AR DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_AR TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset es_AR DATE_TIME_FORMAT "%d/%m/%Y %H:%M:%S %z"
}

Added library/msgs/es_bo.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_BO DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset es_BO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_BO DATE_TIME_FORMAT "%d-%m-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_cl.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CL DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset es_CL TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CL DATE_TIME_FORMAT "%d-%m-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_co.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CO DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_CO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CO DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_cr.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_CR DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_CR TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_CR DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_do.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_DO DATE_FORMAT "%m/%d/%Y"
    ::msgcat::mcset es_DO TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_DO DATE_TIME_FORMAT "%m/%d/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_ec.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_EC DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_EC TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_EC DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_gt.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_GT DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_GT TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_GT DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_hn.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_HN DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_HN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_HN DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_mx.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_MX DATE_FORMAT "%e/%m/%Y"
    ::msgcat::mcset es_MX TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_MX DATE_TIME_FORMAT "%e/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_ni.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_NI DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_NI TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_NI DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_pa.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PA DATE_FORMAT "%m/%d/%Y"
    ::msgcat::mcset es_PA TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PA DATE_TIME_FORMAT "%m/%d/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_pe.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PE DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_PE TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PE DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_pr.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PR DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_PR TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PR DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_py.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_PY DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_PY TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_PY DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_sv.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_SV DATE_FORMAT "%m-%d-%Y"
    ::msgcat::mcset es_SV TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_SV DATE_TIME_FORMAT "%m-%d-%Y %I:%M:%S %P %z"
}

Added library/msgs/es_uy.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_UY DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_UY TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_UY DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Added library/msgs/es_ve.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset es_VE DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset es_VE TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset es_VE DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Deleted library/msgs/eu_ES.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset eu_ES DATE_FORMAT "%a, %Yeko %bren %da"
    ::msgcat::mcset eu_ES TIME_FORMAT "%T"
    ::msgcat::mcset eu_ES TIME_FORMAT_12 "%T"
    ::msgcat::mcset eu_ES DATE_TIME_FORMAT "%y-%m-%d %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/eu_es.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset eu_ES DATE_FORMAT "%a, %Yeko %bren %da"
    ::msgcat::mcset eu_ES TIME_FORMAT "%T"
    ::msgcat::mcset eu_ES TIME_FORMAT_12 "%T"
    ::msgcat::mcset eu_ES DATE_TIME_FORMAT "%y-%m-%d %T %z"
}

Deleted library/msgs/fa_IN.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fa_IN DAYS_OF_WEEK_ABBREV [list \
        "\u06cc\u2214"\
        "\u062f\u2214"\
        "\u0633\u2214"\
        "\u0686\u2214"\
        "\u067e\u2214"\
        "\u062c\u2214"\
        "\u0634\u2214"]
    ::msgcat::mcset fa_IN DAYS_OF_WEEK_FULL [list \
        "\u06cc\u06cc\u200c\u0634\u0646\u0628\u0647"\
        "\u062f\u0648\u0634\u0646\u0628\u0647"\
        "\u0633\u0647\u200c\u0634\u0646\u0628\u0647"\
        "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647"\
        "\u067e\u0646\u062c\u200c\u0634\u0646\u0628\u0647"\
        "\u062c\u0645\u0639\u0647"\
        "\u0634\u0646\u0628\u0647"]
    ::msgcat::mcset fa_IN MONTHS_ABBREV [list \
        "\u0698\u0627\u0646"\
        "\u0641\u0648\u0631"\
        "\u0645\u0627\u0631"\
        "\u0622\u0648\u0631"\
        "\u0645\u0640\u0647"\
        "\u0698\u0648\u0646"\
        "\u0698\u0648\u06cc"\
        "\u0627\u0648\u062a"\
        "\u0633\u067e\u062a"\
        "\u0627\u0643\u062a"\
        "\u0646\u0648\u0627"\
        "\u062f\u0633\u0627"\
        ""]
    ::msgcat::mcset fa_IN MONTHS_FULL [list \
        "\u0698\u0627\u0646\u0648\u06cc\u0647"\
        "\u0641\u0648\u0631\u0648\u06cc\u0647"\
        "\u0645\u0627\u0631\u0633"\
        "\u0622\u0648\u0631\u06cc\u0644"\
        "\u0645\u0647"\
        "\u0698\u0648\u0626\u0646"\
        "\u0698\u0648\u0626\u06cc\u0647"\
        "\u0627\u0648\u062a"\
        "\u0633\u067e\u062a\u0627\u0645\u0628\u0631"\
        "\u0627\u0643\u062a\u0628\u0631"\
        "\u0646\u0648\u0627\u0645\u0628\u0631"\
        "\u062f\u0633\u0627\u0645\u0628\u0631"\
        ""]
    ::msgcat::mcset fa_IN AM "\u0635\u0628\u062d"
    ::msgcat::mcset fa_IN PM "\u0639\u0635\u0631"
    ::msgcat::mcset fa_IN DATE_FORMAT "%A %d %B %Y"
    ::msgcat::mcset fa_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset fa_IN DATE_TIME_FORMAT "%A %d %B %Y %I:%M:%S  %z %z"
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































Deleted library/msgs/fa_IR.msg.

1
2
3
4
5
6
7
8
9
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fa_IR AM "\u0635\u0628\u062d"
    ::msgcat::mcset fa_IR PM "\u0639\u0635\u0631"
    ::msgcat::mcset fa_IR DATE_FORMAT "%d\u2044%m\u2044%Y"
    ::msgcat::mcset fa_IR TIME_FORMAT "%S:%M:%H"
    ::msgcat::mcset fa_IR TIME_FORMAT_12 "%S:%M:%l %P"
    ::msgcat::mcset fa_IR DATE_TIME_FORMAT "%d\u2044%m\u2044%Y %S:%M:%H %z"
}
<
<
<
<
<
<
<
<
<


















Added library/msgs/fa_in.msg.









































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fa_IN DAYS_OF_WEEK_ABBREV [list \
        "\u06cc\u2214"\
        "\u062f\u2214"\
        "\u0633\u2214"\
        "\u0686\u2214"\
        "\u067e\u2214"\
        "\u062c\u2214"\
        "\u0634\u2214"]
    ::msgcat::mcset fa_IN DAYS_OF_WEEK_FULL [list \
        "\u06cc\u06cc\u200c\u0634\u0646\u0628\u0647"\
        "\u062f\u0648\u0634\u0646\u0628\u0647"\
        "\u0633\u0647\u200c\u0634\u0646\u0628\u0647"\
        "\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647"\
        "\u067e\u0646\u062c\u200c\u0634\u0646\u0628\u0647"\
        "\u062c\u0645\u0639\u0647"\
        "\u0634\u0646\u0628\u0647"]
    ::msgcat::mcset fa_IN MONTHS_ABBREV [list \
        "\u0698\u0627\u0646"\
        "\u0641\u0648\u0631"\
        "\u0645\u0627\u0631"\
        "\u0622\u0648\u0631"\
        "\u0645\u0640\u0647"\
        "\u0698\u0648\u0646"\
        "\u0698\u0648\u06cc"\
        "\u0627\u0648\u062a"\
        "\u0633\u067e\u062a"\
        "\u0627\u0643\u062a"\
        "\u0646\u0648\u0627"\
        "\u062f\u0633\u0627"\
        ""]
    ::msgcat::mcset fa_IN MONTHS_FULL [list \
        "\u0698\u0627\u0646\u0648\u06cc\u0647"\
        "\u0641\u0648\u0631\u0648\u06cc\u0647"\
        "\u0645\u0627\u0631\u0633"\
        "\u0622\u0648\u0631\u06cc\u0644"\
        "\u0645\u0647"\
        "\u0698\u0648\u0626\u0646"\
        "\u0698\u0648\u0626\u06cc\u0647"\
        "\u0627\u0648\u062a"\
        "\u0633\u067e\u062a\u0627\u0645\u0628\u0631"\
        "\u0627\u0643\u062a\u0628\u0631"\
        "\u0646\u0648\u0627\u0645\u0628\u0631"\
        "\u062f\u0633\u0627\u0645\u0628\u0631"\
        ""]
    ::msgcat::mcset fa_IN AM "\u0635\u0628\u062d"
    ::msgcat::mcset fa_IN PM "\u0639\u0635\u0631"
    ::msgcat::mcset fa_IN DATE_FORMAT "%A %d %B %Y"
    ::msgcat::mcset fa_IN TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset fa_IN DATE_TIME_FORMAT "%A %d %B %Y %I:%M:%S  %z %z"
}

Added library/msgs/fa_ir.msg.



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fa_IR AM "\u0635\u0628\u062d"
    ::msgcat::mcset fa_IR PM "\u0639\u0635\u0631"
    ::msgcat::mcset fa_IR DATE_FORMAT "%d\u2044%m\u2044%Y"
    ::msgcat::mcset fa_IR TIME_FORMAT "%S:%M:%H"
    ::msgcat::mcset fa_IR TIME_FORMAT_12 "%S:%M:%l %P"
    ::msgcat::mcset fa_IR DATE_TIME_FORMAT "%d\u2044%m\u2044%Y %S:%M:%H %z"
}

Deleted library/msgs/fo_FO.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fo_FO DATE_FORMAT "%d/%m-%Y"
    ::msgcat::mcset fo_FO TIME_FORMAT "%T"
    ::msgcat::mcset fo_FO TIME_FORMAT_12 "%T"
    ::msgcat::mcset fo_FO DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/fo_fo.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fo_FO DATE_FORMAT "%d/%m-%Y"
    ::msgcat::mcset fo_FO TIME_FORMAT "%T"
    ::msgcat::mcset fo_FO TIME_FORMAT_12 "%T"
    ::msgcat::mcset fo_FO DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/fr_BE.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_BE DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset fr_BE TIME_FORMAT "%T"
    ::msgcat::mcset fr_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/fr_CA.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_CA DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset fr_CA TIME_FORMAT "%T"
    ::msgcat::mcset fr_CA TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_CA DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/fr_CH.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_CH DATE_FORMAT "%d. %m. %y"
    ::msgcat::mcset fr_CH TIME_FORMAT "%T"
    ::msgcat::mcset fr_CH TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_CH DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/fr_be.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_BE DATE_FORMAT "%d/%m/%y"
    ::msgcat::mcset fr_BE TIME_FORMAT "%T"
    ::msgcat::mcset fr_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Added library/msgs/fr_ca.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_CA DATE_FORMAT "%Y-%m-%d"
    ::msgcat::mcset fr_CA TIME_FORMAT "%T"
    ::msgcat::mcset fr_CA TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_CA DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Added library/msgs/fr_ch.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset fr_CH DATE_FORMAT "%d. %m. %y"
    ::msgcat::mcset fr_CH TIME_FORMAT "%T"
    ::msgcat::mcset fr_CH TIME_FORMAT_12 "%T"
    ::msgcat::mcset fr_CH DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/ga_IE.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ga_IE DATE_FORMAT "%d.%m.%y"
    ::msgcat::mcset ga_IE TIME_FORMAT "%T"
    ::msgcat::mcset ga_IE TIME_FORMAT_12 "%T"
    ::msgcat::mcset ga_IE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/ga_ie.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ga_IE DATE_FORMAT "%d.%m.%y"
    ::msgcat::mcset ga_IE TIME_FORMAT "%T"
    ::msgcat::mcset ga_IE TIME_FORMAT_12 "%T"
    ::msgcat::mcset ga_IE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/gl_ES.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset gl_ES DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset gl_ES TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset gl_ES DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/gl_es.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset gl_ES DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset gl_ES TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset gl_ES DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/gv_GB.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset gv_GB DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset gv_GB TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset gv_GB DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/gv_gb.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset gv_GB DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset gv_GB TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset gv_GB DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/hi_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset hi_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset hi_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset hi_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/hi_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset hi_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset hi_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset hi_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}

Deleted library/msgs/id_ID.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset id_ID DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset id_ID TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset id_ID DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/id_id.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset id_ID DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset id_ID TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset id_ID DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/it_CH.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset it_CH DATE_FORMAT "%e. %B %Y"
    ::msgcat::mcset it_CH TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset it_CH DATE_TIME_FORMAT "%e. %B %Y %H:%M:%S %z"
}
<
<
<
<
<
<












Added library/msgs/it_ch.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset it_CH DATE_FORMAT "%e. %B %Y"
    ::msgcat::mcset it_CH TIME_FORMAT "%H:%M:%S"
    ::msgcat::mcset it_CH DATE_TIME_FORMAT "%e. %B %Y %H:%M:%S %z"
}

Deleted library/msgs/kl_GL.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kl_GL DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset kl_GL TIME_FORMAT "%T"
    ::msgcat::mcset kl_GL TIME_FORMAT_12 "%T"
    ::msgcat::mcset kl_GL DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/kl_gl.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kl_GL DATE_FORMAT "%d %b %Y"
    ::msgcat::mcset kl_GL TIME_FORMAT "%T"
    ::msgcat::mcset kl_GL TIME_FORMAT_12 "%T"
    ::msgcat::mcset kl_GL DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/ko_KR.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ko_KR BCE "\uae30\uc6d0\uc804"
    ::msgcat::mcset ko_KR CE "\uc11c\uae30"
    ::msgcat::mcset ko_KR DATE_FORMAT "%Y.%m.%d"
    ::msgcat::mcset ko_KR TIME_FORMAT_12 "%P %l:%M:%S"
    ::msgcat::mcset ko_KR DATE_TIME_FORMAT "%Y.%m.%d %P %l:%M:%S %z"
}
<
<
<
<
<
<
<
<
















Added library/msgs/ko_kr.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ko_KR BCE "\uae30\uc6d0\uc804"
    ::msgcat::mcset ko_KR CE "\uc11c\uae30"
    ::msgcat::mcset ko_KR DATE_FORMAT "%Y.%m.%d"
    ::msgcat::mcset ko_KR TIME_FORMAT_12 "%P %l:%M:%S"
    ::msgcat::mcset ko_KR DATE_TIME_FORMAT "%Y.%m.%d %P %l:%M:%S %z"
}

Deleted library/msgs/kok_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kok_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset kok_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset kok_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/kok_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kok_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset kok_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset kok_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}

Deleted library/msgs/kw_GB.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kw_GB DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset kw_GB TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset kw_GB DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/kw_gb.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset kw_GB DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset kw_GB TIME_FORMAT_12 "%l:%M:%S %P"
    ::msgcat::mcset kw_GB DATE_TIME_FORMAT "%d %B %Y %l:%M:%S %P %z"
}

Deleted library/msgs/mr_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset mr_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset mr_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset mr_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/mr_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset mr_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset mr_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset mr_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}

Deleted library/msgs/ms_MY.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ms_MY DATE_FORMAT "%A %d %b %Y"
    ::msgcat::mcset ms_MY TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset ms_MY DATE_TIME_FORMAT "%A %d %b %Y %I:%M:%S  %z %z"
}
<
<
<
<
<
<












Added library/msgs/ms_my.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ms_MY DATE_FORMAT "%A %d %b %Y"
    ::msgcat::mcset ms_MY TIME_FORMAT_12 "%I:%M:%S  %z"
    ::msgcat::mcset ms_MY DATE_TIME_FORMAT "%A %d %b %Y %I:%M:%S  %z %z"
}

Deleted library/msgs/nl_BE.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset nl_BE DATE_FORMAT "%d-%m-%y"
    ::msgcat::mcset nl_BE TIME_FORMAT "%T"
    ::msgcat::mcset nl_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset nl_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/nl_be.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset nl_BE DATE_FORMAT "%d-%m-%y"
    ::msgcat::mcset nl_BE TIME_FORMAT "%T"
    ::msgcat::mcset nl_BE TIME_FORMAT_12 "%T"
    ::msgcat::mcset nl_BE DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/pt_BR.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset pt_BR DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset pt_BR TIME_FORMAT "%T"
    ::msgcat::mcset pt_BR TIME_FORMAT_12 "%T"
    ::msgcat::mcset pt_BR DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}
<
<
<
<
<
<
<














Added library/msgs/pt_br.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset pt_BR DATE_FORMAT "%d-%m-%Y"
    ::msgcat::mcset pt_BR TIME_FORMAT "%T"
    ::msgcat::mcset pt_BR TIME_FORMAT_12 "%T"
    ::msgcat::mcset pt_BR DATE_TIME_FORMAT "%a %d %b %Y %T %z"
}

Deleted library/msgs/ru_UA.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ru_UA DATE_FORMAT "%d.%m.%Y"
    ::msgcat::mcset ru_UA TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset ru_UA DATE_TIME_FORMAT "%d.%m.%Y %k:%M:%S %z"
}
<
<
<
<
<
<












Added library/msgs/ru_ua.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ru_UA DATE_FORMAT "%d.%m.%Y"
    ::msgcat::mcset ru_UA TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset ru_UA DATE_TIME_FORMAT "%d.%m.%Y %k:%M:%S %z"
}

Deleted library/msgs/ta_IN.msg.

1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ta_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset ta_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset ta_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}
<
<
<
<
<
<












Added library/msgs/ta_in.msg.













>
>
>
>
>
>
1
2
3
4
5
6
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset ta_IN DATE_FORMAT "%d %M %Y"
    ::msgcat::mcset ta_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset ta_IN DATE_TIME_FORMAT "%d %M %Y %I:%M:%S %P %z"
}

Deleted library/msgs/te_IN.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset te_IN AM "\u0c2a\u0c42\u0c30\u0c4d\u0c35\u0c3e\u0c39\u0c4d\u0c28"
    ::msgcat::mcset te_IN PM "\u0c05\u0c2a\u0c30\u0c3e\u0c39\u0c4d\u0c28"
    ::msgcat::mcset te_IN DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset te_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset te_IN DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}
<
<
<
<
<
<
<
<
















Added library/msgs/te_in.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset te_IN AM "\u0c2a\u0c42\u0c30\u0c4d\u0c35\u0c3e\u0c39\u0c4d\u0c28"
    ::msgcat::mcset te_IN PM "\u0c05\u0c2a\u0c30\u0c3e\u0c39\u0c4d\u0c28"
    ::msgcat::mcset te_IN DATE_FORMAT "%d/%m/%Y"
    ::msgcat::mcset te_IN TIME_FORMAT_12 "%I:%M:%S %P"
    ::msgcat::mcset te_IN DATE_TIME_FORMAT "%d/%m/%Y %I:%M:%S %P %z"
}

Deleted library/msgs/zh_CN.msg.

1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_CN DATE_FORMAT "%Y-%m-%e"
    ::msgcat::mcset zh_CN TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset zh_CN TIME_FORMAT_12 "%P%I\u65f6%M\u5206%S\u79d2"
    ::msgcat::mcset zh_CN DATE_TIME_FORMAT "%Y-%m-%e %k:%M:%S %z"
}
<
<
<
<
<
<
<














Deleted library/msgs/zh_HK.msg.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_HK DAYS_OF_WEEK_ABBREV [list \
        "\u65e5"\
        "\u4e00"\
        "\u4e8c"\
        "\u4e09"\
        "\u56db"\
        "\u4e94"\
        "\u516d"]
    ::msgcat::mcset zh_HK MONTHS_ABBREV [list \
        "1\u6708"\
        "2\u6708"\
        "3\u6708"\
        "4\u6708"\
        "5\u6708"\
        "6\u6708"\
        "7\u6708"\
        "8\u6708"\
        "9\u6708"\
        "10\u6708"\
        "11\u6708"\
        "12\u6708"\
        ""]
    ::msgcat::mcset zh_HK DATE_FORMAT "%Y\u5e74%m\u6708%e\u65e5"
    ::msgcat::mcset zh_HK TIME_FORMAT_12 "%P%I:%M:%S"
    ::msgcat::mcset zh_HK DATE_TIME_FORMAT "%Y\u5e74%m\u6708%e\u65e5 %P%I:%M:%S %z"
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































Deleted library/msgs/zh_SG.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_SG AM "\u4e0a\u5348"
    ::msgcat::mcset zh_SG PM "\u4e2d\u5348"
    ::msgcat::mcset zh_SG DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset zh_SG TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset zh_SG DATE_TIME_FORMAT "%d %B %Y %P %I:%M:%S %z"
}
<
<
<
<
<
<
<
<
















Deleted library/msgs/zh_TW.msg.

1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_TW BCE "\u6c11\u570b\u524d"
    ::msgcat::mcset zh_TW CE "\u6c11\u570b"
    ::msgcat::mcset zh_TW DATE_FORMAT "%Y/%m/%e"
    ::msgcat::mcset zh_TW TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset zh_TW DATE_TIME_FORMAT "%Y/%m/%e %P %I:%M:%S %z"
}
<
<
<
<
<
<
<
<
















Added library/msgs/zh_cn.msg.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_CN DATE_FORMAT "%Y-%m-%e"
    ::msgcat::mcset zh_CN TIME_FORMAT "%k:%M:%S"
    ::msgcat::mcset zh_CN TIME_FORMAT_12 "%P%I\u65f6%M\u5206%S\u79d2"
    ::msgcat::mcset zh_CN DATE_TIME_FORMAT "%Y-%m-%e %k:%M:%S %z"
}

Added library/msgs/zh_hk.msg.

























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_HK DAYS_OF_WEEK_ABBREV [list \
        "\u65e5"\
        "\u4e00"\
        "\u4e8c"\
        "\u4e09"\
        "\u56db"\
        "\u4e94"\
        "\u516d"]
    ::msgcat::mcset zh_HK MONTHS_ABBREV [list \
        "1\u6708"\
        "2\u6708"\
        "3\u6708"\
        "4\u6708"\
        "5\u6708"\
        "6\u6708"\
        "7\u6708"\
        "8\u6708"\
        "9\u6708"\
        "10\u6708"\
        "11\u6708"\
        "12\u6708"\
        ""]
    ::msgcat::mcset zh_HK DATE_FORMAT "%Y\u5e74%m\u6708%e\u65e5"
    ::msgcat::mcset zh_HK TIME_FORMAT_12 "%P%I:%M:%S"
    ::msgcat::mcset zh_HK DATE_TIME_FORMAT "%Y\u5e74%m\u6708%e\u65e5 %P%I:%M:%S %z"
}

Added library/msgs/zh_sg.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_SG AM "\u4e0a\u5348"
    ::msgcat::mcset zh_SG PM "\u4e2d\u5348"
    ::msgcat::mcset zh_SG DATE_FORMAT "%d %B %Y"
    ::msgcat::mcset zh_SG TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset zh_SG DATE_TIME_FORMAT "%d %B %Y %P %I:%M:%S %z"
}

Added library/msgs/zh_tw.msg.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
# created by tools/loadICU.tcl -- do not edit
namespace eval ::tcl::clock {
    ::msgcat::mcset zh_TW BCE "\u6c11\u570b\u524d"
    ::msgcat::mcset zh_TW CE "\u6c11\u570b"
    ::msgcat::mcset zh_TW DATE_FORMAT "%Y/%m/%e"
    ::msgcat::mcset zh_TW TIME_FORMAT_12 "%P %I:%M:%S"
    ::msgcat::mcset zh_TW DATE_TIME_FORMAT "%Y/%m/%e %P %I:%M:%S %z"
}

Changes to tests/binary.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: binary.test,v 1.18.2.8 2005/08/24 18:56:32 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}
::tcltest::testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}]
::tcltest::testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}]







|







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: binary.test,v 1.18.2.9 2005/08/25 15:46:53 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}
::tcltest::testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}]
::tcltest::testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}]

Changes to tests/chan.test.

3
4
5
6
7
8
9
10
11
12
13
14
15





16
17
18
19
20
21
22
23
24
25
26
27
28
29
# output for errors. No output means no errors were found.
#
# Copyright (c) 2005 Donal K. Fellows
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: chan.test,v 1.4.6.2 2005/07/12 20:37:06 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}






test chan-1.1 {chan command general syntax} -body {
    chan
} -returnCodes error -result "wrong # args: should be \"chan subcommand ?argument ...?\""
test chan-1.2 {chan command general syntax} -body {
    chan FOOBAR
} -returnCodes error -result "unknown or ambiguous subcommand \"FOOBAR\": must be blocked, close, configure, copy, eof, event, flush, gets, names, puts, read, seek, tell, or truncate"

test chan-2.1 {chan command: blocked subcommand} -body {
    chan blocked foo bar
} -returnCodes error -result "wrong # args: should be \"chan blocked channelId\""

test chan-3.1 {chan command: close subcommand} -body {
    chan close foo bar







|





>
>
>
>
>






|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# output for errors. No output means no errors were found.
#
# Copyright (c) 2005 Donal K. Fellows
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: chan.test,v 1.4.6.3 2005/08/25 15:46:53 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

#
# Note: The tests for the chan methods "create" and "postevent"
# currently reside in the file "ioCmd.test".
#

test chan-1.1 {chan command general syntax} -body {
    chan
} -returnCodes error -result "wrong # args: should be \"chan subcommand ?argument ...?\""
test chan-1.2 {chan command general syntax} -body {
    chan FOOBAR
} -returnCodes error -result "unknown or ambiguous subcommand \"FOOBAR\": must be blocked, close, configure, copy, create, eof, event, flush, gets, names, postevent, puts, read, seek, tell, or truncate"

test chan-2.1 {chan command: blocked subcommand} -body {
    chan blocked foo bar
} -returnCodes error -result "wrong # args: should be \"chan blocked channelId\""

test chan-3.1 {chan command: close subcommand} -body {
    chan close foo bar

Changes to tests/clock.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.....
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
.....
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479












35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.test,v 1.52.2.4 2005/08/15 18:14:00 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if { $::tcl_platform(platform) eq {windows} } {
................................................................................
	    unset oldTZ
	} else {
	    unset env(TZ)
	}
    } \
    -result {-0500}

test clock-43.1 {regression test - mktime returning -1} \
    -setup {
	if { [info exists env(TZ)] } {
	    set oldTZ $env(TZ)
	}
	set env(TZ) UTC0
    } \
    -body {
	clock scan 1969-12-31T23:59:59 -format %Y-%m-%dT%T -timezone :localtime
    } \
    -cleanup {
	if { [info exists oldTZ] } {
	    set env(TZ) $oldTZ
	    unset oldTZ
	} else {
	    unset env(TZ)
	}
    } \
    -result {-1}
    
test clock-44.1 {regression test - time zone name containing hyphen } \
    -setup {
	if { [info exists env(TZ)] } {
	    set oldTZ $env(TZ)
	}
	set env(TZ) US/East-Indiana
    } \
................................................................................

test clock-50.1 {format / scan -1 as a local time} {
    if {[catch {
	clock scan \
	    [clock format -1 -format %Y%m%d%H%M%S -timezone :localtime] \
	    -format %Y%m%d%H%M%S -timezone :localtime
    } result]} {
	if { [regexp "clock value too" $result] } {
	    set result -1
	}
    }
    set result
} -1













# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







|







 







|
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|





>
>
>
>
>
>
>
>
>
>
>
>











7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.....
35325
35326
35327
35328
35329
35330
35331
35332



35333















35334
35335
35336
35337
35338
35339
35340
.....
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.test,v 1.52.2.5 2005/08/25 15:46:53 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if { $::tcl_platform(platform) eq {windows} } {
................................................................................
	    unset oldTZ
	} else {
	    unset env(TZ)
	}
    } \
    -result {-0500}

# 43.1 was a bad test - mktime returning -1 is an error according to posix.



















test clock-44.1 {regression test - time zone name containing hyphen } \
    -setup {
	if { [info exists env(TZ)] } {
	    set oldTZ $env(TZ)
	}
	set env(TZ) US/East-Indiana
    } \
................................................................................

test clock-50.1 {format / scan -1 as a local time} {
    if {[catch {
	clock scan \
	    [clock format -1 -format %Y%m%d%H%M%S -timezone :localtime] \
	    -format %Y%m%d%H%M%S -timezone :localtime
    } result]} {
	if { [regexp " too large" $result] } {
	    set result -1
	}
    }
    set result
} -1
test clock-50.2 {format / scan -2 as a local time} {
    if {[catch {
	clock scan \
	    [clock format -2 -format %Y%m%d%H%M%S -timezone :localtime] \
	    -format %Y%m%d%H%M%S -timezone :localtime
    } result]} {
	if { [regexp " too large" $result] } {
	    set result -2
	}
    }
    set result
} -2

# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:

Changes to tests/expr.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
....
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
....
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
....
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
....
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
....
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
....
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
....
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
....
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
....
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
....
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
....
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
....
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
#
# Copyright (c) 1996-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: expr.test,v 1.30.2.22 2005/08/24 18:56:32 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2.1
    namespace import -force ::tcltest::*
}

testConstraint testmathfunctions [expr {
................................................................................
    list [catch {expr {1ea}} err] $err
} {1 {syntax error in expression "1ea": extra tokens at end of expression}}

test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8

test expr-9.5a {CompileRelationalExpr: shift expr producing LONG_MIN} longIs64bit {
    expr {1<<63}
} -9223372036854775808

test expr-9.5b {CompileRelationalExpr: shift expr producing LONG_MIN} longIs32bit {
    expr {1<<31}
} -2147483648

test expr-9.6 {CompileRelationalExpr: error in shift expr} -body {
    catch {expr x>>3} msg
    set msg
} -match glob -result {syntax error in expression "x>>3": * preceding $*}
test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {
................................................................................
test expr-23.30 {INST_EXPON: special cases} {expr {wide(-1)**wide(2)}} 1
test expr-23.31 {INST_EXPON: special cases} {expr {wide(-1)**wide(-1)}} -1
test expr-23.32 {INST_EXPON: special cases} {expr {wide(1)**wide(1234567)}} 1
test expr-23.33 {INST_EXPON: special cases} {expr {wide(2)**wide(-2)}} 0
test expr-23.34 {INST_EXPON: special cases} {expr {2**0}} 1
test expr-23.35 {INST_EXPON: special cases} {expr {wide(2)**0}} 1


# Some compilers get this wrong; ensure that we work around it correctly
test expr-24.1 {expr edge cases; shifting} {expr int(5)>>32} 0
test expr-24.2 {expr edge cases; shifting} {expr int(5)>>63} 0
test expr-24.3 {expr edge cases; shifting} {expr wide(5)>>32} 0
test expr-24.4 {expr edge cases; shifting} {expr wide(5)>>63} 0
test expr-24.5 {expr edge cases; shifting} longIs32bit {expr int(5)<<32} 0
test expr-24.6 {expr edge cases; shifting} longIs32bit {expr int(5)<<63} 0
................................................................................
test expr-26.4 {'ni' operator} {expr {"a" ni ""}} 1
test expr-26.5 {'ni' operator} {expr {"" ni {a b c ""}}} 0
test expr-26.6 {'ni' operator} {expr {"" ni "a b c"}} 1
test expr-26.7 {'ni' operator} {expr {"" ni ""}} 1

foreach op {< <= == != > >=} {
    proc test$op {a b} [list expr "\$a $op \$b"]

}

test expr-27.1 {expr - correct ordering - not compiled} ieeeFloatingPoint {
    set problems {}
    # Ordering should be: -Infinity < -Normal < Subnormal < -0
    #                     < +0 < +Subnormal < +Normal < +Infinity
    # with equality within each class.
................................................................................
			":result is " $is ", should be $shouldBe" \n
		}
	    }
	}
    }
    set problems
} {}

test expr-27.2 {expr - correct ordering - compiled} ieeeFloatingPoint {
    set problems {}
    # Ordering should be: -Infinity < -Normal < Subnormal < -0
    #                     < +0 < +Subnormal < +Normal < +Infinity
    # with equality within each class.
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity
................................................................................
			":result is " $is ", should be $shouldBe" \n
		}
	    }
	}
    }
    set problems
} {}

test expr-27.3 {expr - NaN is unordered - not compiled} {
    set problems {}
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity NaN
    }
    foreach name1 $names {
	foreach op {< <= == != >= >} sb {0 0 0 1 0 0} {
................................................................................
		append problems NaN { } $op { } $name1 \
		    ": result is 1, should be $sb" \n
	    }
	}
    }
    set problems
} {}

test expr-27.4 {expr - NaN is unordered - compiled} {
    set problems {}
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity NaN
    }
    foreach name1 $names {
	foreach op {< <= == != >= >} sb {0 0 0 1 0 0} {
................................................................................
test expr-31.12 {boolean conversion} {expr bool(5)} 1
test expr-31.13 {boolean conversion} {expr bool(0x5)} 1
test expr-31.14 {boolean conversion} {expr bool(wide(5))} 1
test expr-31.15 {boolean conversion} -body {
    expr bool("fred")
} -returnCodes error -match glob -result *


test expr-32.1 {expr mod basics} {
    set mod_nums [list \
        {-3 1} {-3 2} {-3 3} {-3 4} {-3 5} \
        {-3 -1} {-3 -2} {-3 -3} {-3 -4} {-3 -5} \
        {-2 1} {-2 2} {-2 3} {-2 4} {-2 5} \
        {-2 -1} {-2 -2} {-2 -3} {-2 -4} {-2 -5} \
        {-1 1} {-1 2} {-1 3} {-1 4} {-1 5} \
................................................................................
        [expr {$max_long_str + 0}] \
        [expr {$max_long + 0}] \
        [expr {2147483647 + 0}] \
        [expr {$max_long == $max_long_hex}] \
        [expr {(2147483647 + 1) < 0}] \

} {2147483647 2147483647 2147483647 2147483647 1 1}

test expr-33.2 {parse smallest long value} {longIs32bit} {
    set min_long_str -2147483648
    set min_long_hex "-0x80000000 "

    set min_long -2147483648
    # This will convert to integer (not wide) internal rep
    string is integer $min_long
................................................................................
        [expr {$min_long_str + 0}] \
        [expr {$min_long + 0}] \
        [expr {-2147483648 + 0}] \
        [expr {$min_long == $min_long_hex}] \
        [expr {(-2147483648 - 1) == 0x7FFFFFFF}] \

} {-2147483648 -2147483648 -2147483648 -2147483648 1 1}

test expr-33.3 {parse largest wide value} {wideIs64bit} {
    set max_wide_str 9223372036854775807
    set max_wide_hex "0x7FFFFFFFFFFFFFFF "

    # Convert to wide integer
    set max_wide 9223372036854775807
    string is integer $max_wide
................................................................................
        [expr {$max_wide_str + 0}] \
        [expr {$max_wide + 0}] \
        [expr {9223372036854775807 + 0}] \
        [expr {$max_wide == $max_wide_hex}] \
        [expr {(9223372036854775807 + 1) < 0}] \

} {9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807 1 1}

test expr-33.4 {parse smallest wide value} {wideIs64bit} {
    set min_wide_str -9223372036854775808
    set min_wide_hex "-0x8000000000000000 "

    set min_wide -9223372036854775808
    # Convert to wide integer
    string is integer $min_wide
................................................................................
        [expr {$min_wide + 0}] \
        [expr {-9223372036854775808 + 0}] \
        [expr {$min_wide == $min_wide_hex}] \
        [expr {(-9223372036854775808 - 1) == 0x7FFFFFFFFFFFFFFF}] \

} {-9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 1 1}


set min -2147483648
set max 2147483647

test expr-34.1 {expr edge cases} {longIs32bit} {
    expr {$min / $min}
} {1}

test expr-34.2 {expr edge cases} {longIs32bit} {
    expr {$min % $min}
} {0}

test expr-34.3 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 1)}
} {1}

test expr-34.4 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 1)}
} {-1}

test expr-34.5 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 2)}
} {1}

test expr-34.6 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 2)}
} {-2}

test expr-34.7 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 3)}
} {1}

test expr-34.8 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 3)}
} {-3}

test expr-34.9 {expr edge cases} {longIs32bit} {
    expr {$min / -3}
} {715827882}

test expr-34.10 {expr edge cases} {longIs32bit} {
    expr {$min % -3}
} {-2}

test expr-34.11 {expr edge cases} {longIs32bit} {
    expr {$min / -2}
} {1073741824}

test expr-34.12 {expr edge cases} {longIs32bit} {
    expr {$min % -2}
} {0}

test expr-34.13 {expr edge cases} {longIs32bit} {
    expr {$min / -1}
} {-2147483648}

test expr-34.14 {expr edge cases} {longIs32bit} {
    expr {$min % -1}
} {0}

test expr-34.15 {expr edge cases} {longIs32bit} {
    expr {$min * -1}
} $min

test expr-34.16 {expr edge cases} {longIs32bit} {
    expr {-$min}
} $min

test expr-34.17 {expr edge cases} {longIs32bit} {
    expr {$min / 1}
} $min

test expr-34.18 {expr edge cases} {longIs32bit} {
    expr {$min % 1}
} {0}

test expr-34.19 {expr edge cases} {longIs32bit} {
    expr {$min / 2}
} {-1073741824}

test expr-34.20 {expr edge cases} {longIs32bit} {
    expr {$min % 2}
} {0}

test expr-34.21 {expr edge cases} {longIs32bit} {
    expr {$min / 3}
} {-715827883}

test expr-34.22 {expr edge cases} {longIs32bit} {
    expr {$min % 3}
} {1}

test expr-34.23 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 3)}
} {-2}

test expr-34.24 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 3)}
} {2147483640}

test expr-34.25 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 2)}
} {-2}

test expr-34.26 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 2)}
} {2147483642}

test expr-34.27 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 1)}
} {-2}

test expr-34.28 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 1)}
} {2147483644}

test expr-34.29 {expr edge cases} {longIs32bit} {
    expr {$min / $max}
} {-2}

test expr-34.30 {expr edge cases} {longIs32bit} {
    expr {$min % $max}
} {2147483646}

test expr-34.31 {expr edge cases} {longIs32bit} {
    expr {$max / $max}
} {1}

test expr-34.32 {expr edge cases} {longIs32bit} {
    expr {$max % $max}
} {0}

test expr-34.33 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 1)}
} {1}

test expr-34.34 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 1)}
} {1}

test expr-34.35 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 2)}
} {1}

test expr-34.36 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 2)}
} {2}

test expr-34.37 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 3)}
} {1}

test expr-34.38 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 3)}
} {3}

test expr-34.39 {expr edge cases} {longIs32bit} {
    expr {$max / 3}
} {715827882}

test expr-34.40 {expr edge cases} {longIs32bit} {
    expr {$max % 3}
} {1}

test expr-34.41 {expr edge cases} {longIs32bit} {
    expr {$max / 2}
} {1073741823}

test expr-34.42 {expr edge cases} {longIs32bit} {
    expr {$max % 2}
} {1}

test expr-34.43 {expr edge cases} {longIs32bit} {
    expr {$max / 1}
} $max

test expr-34.44 {expr edge cases} {longIs32bit} {
    expr {$max % 1}
} {0}

test expr-34.45 {expr edge cases} {longIs32bit} {
    expr {$max / -1}
} "-$max"

test expr-34.46 {expr edge cases} {longIs32bit} {
    expr {$max % -1}
} {0}

test expr-34.47 {expr edge cases} {longIs32bit} {
    expr {$max / -2}
} {-1073741824}

test expr-34.48 {expr edge cases} {longIs32bit} {
    expr {$max % -2}
} {-1}

test expr-34.49 {expr edge cases} {longIs32bit} {
    expr {$max / -3}
} {-715827883}

test expr-34.50 {expr edge cases} {longIs32bit} {
    expr {$max % -3}
} {-2}

test expr-34.51 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 3)}
} {-2}

test expr-34.52 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 3)}
} {-2147483643}

test expr-34.53 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 2)}
} {-2}

test expr-34.54 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 2)}
} {-2147483645}

test expr-34.55 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 1)}
} {-1}

test expr-34.56 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 1)}
} {0}

test expr-34.57 {expr edge cases} {longIs32bit} {
    expr {$max / $min}
} {-1}

test expr-34.58 {expr edge cases} {longIs32bit} {
    expr {$max % $min}
} {-1}

test expr-34.59 {expr edge cases} {longIs32bit} {
    expr {($min + 1) / ($max - 1)}
} {-2}

test expr-34.60 {expr edge cases} {longIs32bit} {
    expr {($min + 1) % ($max - 1)}
} {2147483645}

test expr-34.61 {expr edge cases} {longIs32bit} {
    expr {($max - 1) / ($min + 1)}
} {-1}

test expr-34.62 {expr edge cases} {longIs32bit} {
    expr {($max - 1) % ($min + 1)}
} {-1}

test expr-34.63 {expr edge cases} {longIs32bit} {
    expr {($max - 1) / $min}
} {-1}

test expr-34.64 {expr edge cases} {longIs32bit} {
    expr {($max - 1) % $min}
} {-2}

test expr-34.65 {expr edge cases} {longIs32bit} {
    expr {($max - 2) / $min}
} {-1}

test expr-34.66 {expr edge cases} {longIs32bit} {
    expr {($max - 2) % $min}
} {-3}

test expr-34.67 {expr edge cases} {longIs32bit} {
    expr {($max - 3) / $min}
} {-1}

test expr-34.68 {expr edge cases} {longIs32bit} {
    expr {($max - 3) % $min}
} {-4}

test expr-34.69 {expr edge cases} {longIs32bit} {
    expr {-3 / $min}
} {0}

test expr-34.70 {expr edge cases} {longIs32bit} {
    expr {-3 % $min}
} {-3}

test expr-34.71 {expr edge cases} {longIs32bit} {
    expr {-2 / $min}
} {0}

test expr-34.72 {expr edge cases} {longIs32bit} {
    expr {-2 % $min}
} {-2}

test expr-34.73 {expr edge cases} {longIs32bit} {
    expr {-1 / $min}
} {0}

test expr-34.74 {expr edge cases} {longIs32bit} {
    expr {-1 % $min}
} {-1}

test expr-34.75 {expr edge cases} {longIs32bit} {
    expr {0 / $min}
} {0}

test expr-34.76 {expr edge cases} {longIs32bit} {
    expr {0 % $min}
} {0}

test expr-34.77 {expr edge cases} {longIs32bit} {
    expr {0 / ($min + 1)}
} {0}

test expr-34.78 {expr edge cases} {longIs32bit} {
    expr {0 % ($min + 1)}
} {0}

test expr-34.79 {expr edge cases} {longIs32bit} {
    expr {1 / $min}
} {-1}

test expr-34.80 {expr edge cases} {longIs32bit} {
    expr {1 % $min}
} {-2147483647}

test expr-34.81 {expr edge cases} {longIs32bit} {
    expr {1 / ($min + 1)}
} {-1}

test expr-34.82 {expr edge cases} {longIs32bit} {
    expr {1 % ($min + 1)}
} {-2147483646}

test expr-34.83 {expr edge cases} {longIs32bit} {
    expr {2 / $min}
} {-1}

test expr-34.84 {expr edge cases} {longIs32bit} {
    expr {2 % $min}
} {-2147483646}

test expr-34.85 {expr edge cases} {longIs32bit} {
    expr {2 / ($min + 1)}
} {-1}

test expr-34.86 {expr edge cases} {longIs32bit} {
    expr {2 % ($min + 1)}
} {-2147483645}

test expr-34.87 {expr edge cases} {longIs32bit} {
    expr {3 / $min}
} {-1}

test expr-34.88 {expr edge cases} {longIs32bit} {
    expr {3 % $min}
} {-2147483645}

test expr-34.89 {expr edge cases} {longIs32bit} {
    expr {3 / ($min + 1)}
} {-1}

test expr-34.90 {expr edge cases} {longIs32bit} {
    expr {3 % ($min + 1)}
} {-2147483644}

# Euclidean property:
# quotient * divisor + remainder = dividend

................................................................................
test expr-35.1 {expr edge cases} {longIs32bit} {
    set dividend $max
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($divisor * $q) + $r}]
} {1073741823 * 2 + 1 = 2147483647}

test expr-35.2 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1073741823 * 2 + 0 = 2147483646}

test expr-35.3 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1073741822 * 2 + 1 = 2147483645}

test expr-35.4 {expr edge cases} {longIs32bit} {
    set dividend $max
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * 3 + 1 = 2147483647}

test expr-35.5 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 1}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * 3 + 0 = 2147483646}

test expr-35.6 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 2}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827881 * 3 + 2 = 2147483645}

test expr-35.7 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741824 * 2 + 0 = -2147483648}

test expr-35.8 {expr edge cases} {longIs32bit} {
    set dividend [expr {$min + 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741824 * 2 + 1 = -2147483647}

test expr-35.9 {expr edge cases} {longIs32bit} {
    set dividend [expr {$min + 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741823 * 2 + 0 = -2147483646}

test expr-35.10 {expr edge cases} {longIs32bit} {
    # Two things could happen here. The multiplication
    # could overflow a 32 bit type, so that when
    # 1 is added it overflows again back to min.
    # The multiplication could also use a wide type
    # to hold ($min - 1) until 1 is added and
    # the number becomes $min again.
    set dividend $min
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-715827883 * 3 + 1 = -2147483648}

test expr-35.11 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor -3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * -3 + -2 = -2147483648}

test expr-35.12 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor $min
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483648 + 0 = -2147483648}

test expr-35.13 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor [expr {$min + 1}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483647 + -1 = -2147483648}

test expr-35.14 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor [expr {$min + 2}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483646 + -2 = -2147483648}
................................................................................

set min -9223372036854775808
set max 9223372036854775807

test expr-36.1 {expr edge cases} {wideIs64bit} {
    expr {$min / $min}
} {1}

test expr-36.2 {expr edge cases} {wideIs64bit} {
    expr {$min % $min}
} {0}

test expr-36.3 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 1)}
} {1}

test expr-36.4 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 1)}
} {-1}

test expr-36.5 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 2)}
} {1}

test expr-36.6 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 2)}
} {-2}

test expr-36.7 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 3)}
} {1}

test expr-36.8 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 3)}
} {-3}

test expr-36.9 {expr edge cases} {wideIs64bit} {
    expr {$min / -3}
} {3074457345618258602}

test expr-36.10 {expr edge cases} {wideIs64bit} {
    expr {$min % -3}
} {-2}

test expr-36.11 {expr edge cases} {wideIs64bit} {
    expr {$min / -2}
} {4611686018427387904}

test expr-36.12 {expr edge cases} {wideIs64bit} {
    expr {$min % -2}
} {0}

test expr-36.13 {expr edge cases} {wideIs64bit} {
    expr {$min / -1}
} $min

test expr-36.14 {expr edge cases} {wideIs64bit} {
    expr {$min % -1}
} {0}

test expr-36.15 {expr edge cases} {wideIs64bit} {
    expr {$min * -1}
} $min

test expr-36.16 {expr edge cases} {wideIs64bit} {
    expr {-$min}
} $min

test expr-36.17 {expr edge cases} {wideIs64bit} {
    expr {$min / 1}
} $min

test expr-36.18 {expr edge cases} {wideIs64bit} {
    expr {$min % 1}
} {0}

test expr-36.19 {expr edge cases} {wideIs64bit} {
    expr {$min / 2}
} {-4611686018427387904}

test expr-36.20 {expr edge cases} {wideIs64bit} {
    expr {$min % 2}
} {0}

test expr-36.21 {expr edge cases} {wideIs64bit} {
    expr {$min / 3}
} {-3074457345618258603}

test expr-36.22 {expr edge cases} {wideIs64bit} {
    expr {$min % 3}
} {1}

test expr-36.23 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 3)}
} {-2}

test expr-36.24 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 3)}
} {9223372036854775800}

test expr-36.25 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 2)}
} {-2}

test expr-36.26 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 2)}
} {9223372036854775802}

test expr-36.27 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 1)}
} {-2}

test expr-36.28 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 1)}
} {9223372036854775804}

test expr-36.29 {expr edge cases} {wideIs64bit} {
    expr {$min / $max}
} {-2}

test expr-36.30 {expr edge cases} {wideIs64bit} {
    expr {$min % $max}
} {9223372036854775806}

test expr-36.31 {expr edge cases} {wideIs64bit} {
    expr {$max / $max}
} {1}

test expr-36.32 {expr edge cases} {wideIs64bit} {
    expr {$max % $max}
} {0}

test expr-36.33 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 1)}
} {1}

test expr-36.34 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 1)}
} {1}

test expr-36.35 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 2)}
} {1}

test expr-36.36 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 2)}
} {2}

test expr-36.37 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 3)}
} {1}

test expr-36.38 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 3)}
} {3}

test expr-36.39 {expr edge cases} {wideIs64bit} {
    expr {$max / 3}
} {3074457345618258602}

test expr-36.40 {expr edge cases} {wideIs64bit} {
    expr {$max % 3}
} {1}

test expr-36.41 {expr edge cases} {wideIs64bit} {
    expr {$max / 2}
} {4611686018427387903}

test expr-36.42 {expr edge cases} {wideIs64bit} {
    expr {$max % 2}
} {1}

test expr-36.43 {expr edge cases} {wideIs64bit} {
    expr {$max / 1}
} $max

test expr-36.44 {expr edge cases} {wideIs64bit} {
    expr {$max % 1}
} {0}

test expr-36.45 {expr edge cases} {wideIs64bit} {
    expr {$max / -1}
} "-$max"

test expr-36.46 {expr edge cases} {wideIs64bit} {
    expr {$max % -1}
} {0}

test expr-36.47 {expr edge cases} {wideIs64bit} {
    expr {$max / -2}
} {-4611686018427387904}

test expr-36.48 {expr edge cases} {wideIs64bit} {
    expr {$max % -2}
} {-1}

test expr-36.49 {expr edge cases} {wideIs64bit} {
    expr {$max / -3}
} {-3074457345618258603}

test expr-36.50 {expr edge cases} {wideIs64bit} {
    expr {$max % -3}
} {-2}

test expr-36.51 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 3)}
} {-2}

test expr-36.52 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 3)}
} {-9223372036854775803}

test expr-36.53 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 2)}
} {-2}

test expr-36.54 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 2)}
} {-9223372036854775805}

test expr-36.55 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 1)}
} {-1}

test expr-36.56 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 1)}
} {0}

test expr-36.57 {expr edge cases} {wideIs64bit} {
    expr {$max / $min}
} {-1}

test expr-36.58 {expr edge cases} {wideIs64bit} {
    expr {$max % $min}
} {-1}

test expr-36.59 {expr edge cases} {wideIs64bit} {
    expr {($min + 1) / ($max - 1)}
} {-2}

test expr-36.60 {expr edge cases} {wideIs64bit} {
    expr {($min + 1) % ($max - 1)}
} {9223372036854775805}

test expr-36.61 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) / ($min + 1)}
} {-1}

test expr-36.62 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) % ($min + 1)}
} {-1}

test expr-36.63 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) / $min}
} {-1}

test expr-36.64 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) % $min}
} {-2}

test expr-36.65 {expr edge cases} {wideIs64bit} {
    expr {($max - 2) / $min}
} {-1}

test expr-36.66 {expr edge cases} {wideIs64bit} {
    expr {($max - 2) % $min}
} {-3}

test expr-36.67 {expr edge cases} {wideIs64bit} {
    expr {($max - 3) / $min}
} {-1}

test expr-36.68 {expr edge cases} {wideIs64bit} {
    expr {($max - 3) % $min}
} {-4}

test expr-36.69 {expr edge cases} {wideIs64bit} {
    expr {-3 / $min}
} {0}

test expr-36.70 {expr edge cases} {wideIs64bit} {
    expr {-3 % $min}
} {-3}

test expr-36.71 {expr edge cases} {wideIs64bit} {
    expr {-2 / $min}
} {0}

test expr-36.72 {expr edge cases} {wideIs64bit} {
    expr {-2 % $min}
} {-2}

test expr-36.73 {expr edge cases} {wideIs64bit} {
    expr {-1 / $min}
} {0}

test expr-36.74 {expr edge cases} {wideIs64bit} {
    expr {-1 % $min}
} {-1}

test expr-36.75 {expr edge cases} {wideIs64bit} {
    expr {0 / $min}
} {0}

test expr-36.76 {expr edge cases} {wideIs64bit} {
    expr {0 % $min}
} {0}

test expr-36.77 {expr edge cases} {wideIs64bit} {
    expr {0 / ($min + 1)}
} {0}

test expr-36.78 {expr edge cases} {wideIs64bit} {
    expr {0 % ($min + 1)}
} {0}

test expr-36.79 {expr edge cases} {wideIs64bit} {
    expr {1 / $min}
} {-1}

test expr-36.80 {expr edge cases} {wideIs64bit} {
    expr {1 % $min}
} {-9223372036854775807}

test expr-36.81 {expr edge cases} {wideIs64bit} {
    expr {1 / ($min + 1)}
} {-1}

test expr-36.82 {expr edge cases} {wideIs64bit} {
    expr {1 % ($min + 1)}
} {-9223372036854775806}

test expr-36.83 {expr edge cases} {wideIs64bit} {
    expr {2 / $min}
} {-1}

test expr-36.84 {expr edge cases} {wideIs64bit} {
    expr {2 % $min}
} {-9223372036854775806}

test expr-36.85 {expr edge cases} {wideIs64bit} {
    expr {2 / ($min + 1)}
} {-1}

test expr-36.86 {expr edge cases} {wideIs64bit} {
    expr {2 % ($min + 1)}
} {-9223372036854775805}

test expr-36.87 {expr edge cases} {wideIs64bit} {
    expr {3 / $min}
} {-1}

test expr-36.88 {expr edge cases} {wideIs64bit} {
    expr {3 % $min}
} {-9223372036854775805}

test expr-36.89 {expr edge cases} {wideIs64bit} {
    expr {3 / ($min + 1)}
} {-1}

test expr-36.90 {expr edge cases} {wideIs64bit} {
    expr {3 % ($min + 1)}
} {-9223372036854775804}


test expr-37.1 {expr edge cases} {wideIs64bit} {
    set dividend $max
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($divisor * $q) + $r}]
} {4611686018427387903 * 2 + 1 = 9223372036854775807}

test expr-37.2 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {4611686018427387903 * 2 + 0 = 9223372036854775806}

test expr-37.3 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {4611686018427387902 * 2 + 1 = 9223372036854775805}

test expr-37.4 {expr edge cases} {wideIs64bit} {
    set dividend $max
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * 3 + 1 = 9223372036854775807}

test expr-37.5 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 1}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * 3 + 0 = 9223372036854775806}

test expr-37.6 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 2}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258601 * 3 + 2 = 9223372036854775805}

test expr-37.7 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387904 * 2 + 0 = -9223372036854775808}

test expr-37.8 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$min + 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387904 * 2 + 1 = -9223372036854775807}

test expr-37.9 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$min + 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387903 * 2 + 0 = -9223372036854775806}

test expr-37.10 {expr edge cases} {wideIs64bit} {
    # Multiplication overflows 64 bit type here,
    # so when the 1 is added it overflows
    # again and we end up back at min.
    set dividend $min
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-3074457345618258603 * 3 + 1 = -9223372036854775808}

test expr-37.11 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor -3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * -3 + -2 = -9223372036854775808}

test expr-37.12 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor $min
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775808 + 0 = -9223372036854775808}

test expr-37.13 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor [expr {$min + 1}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775807 + -1 = -9223372036854775808}

test expr-37.14 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor [expr {$min + 2}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775806 + -2 = -9223372036854775808}


test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} {wideIs64bit} {
    expr {abs(-2147483648)}
} 2147483648

testConstraint testexprlongobj   [llength [info commands testexprlongobj]]
testConstraint testexprdoubleobj [llength [info commands testexprdoubleobj]]







|







 







<



<



<







 







<







 







<







 







<







 







<







 







<







 







<







 







<







 







<







 







<







 







<






<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<







 







<







<







<







<







<







<







<







<







<













<







<







<







<







 







<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<



<








<







<







<







<







<







<







<







<







<










<







<







<







<







<







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
441
442
443
444
445
446
447

448
449
450

451
452
453

454
455
456
457
458
459
460
....
1016
1017
1018
1019
1020
1021
1022

1023
1024
1025
1026
1027
1028
1029
....
1046
1047
1048
1049
1050
1051
1052

1053
1054
1055
1056
1057
1058
1059
....
1073
1074
1075
1076
1077
1078
1079

1080
1081
1082
1083
1084
1085
1086
....
1098
1099
1100
1101
1102
1103
1104

1105
1106
1107
1108
1109
1110
1111
....
1117
1118
1119
1120
1121
1122
1123

1124
1125
1126
1127
1128
1129
1130
....
5323
5324
5325
5326
5327
5328
5329

5330
5331
5332
5333
5334
5335
5336
....
5418
5419
5420
5421
5422
5423
5424

5425
5426
5427
5428
5429
5430
5431
....
5438
5439
5440
5441
5442
5443
5444

5445
5446
5447
5448
5449
5450
5451
....
5455
5456
5457
5458
5459
5460
5461

5462
5463
5464
5465
5466
5467
5468
....
5476
5477
5478
5479
5480
5481
5482

5483
5484
5485
5486
5487
5488

5489
5490
5491

5492
5493
5494

5495
5496
5497

5498
5499
5500

5501
5502
5503

5504
5505
5506

5507
5508
5509

5510
5511
5512

5513
5514
5515

5516
5517
5518

5519
5520
5521

5522
5523
5524

5525
5526
5527

5528
5529
5530

5531
5532
5533

5534
5535
5536

5537
5538
5539

5540
5541
5542

5543
5544
5545

5546
5547
5548

5549
5550
5551

5552
5553
5554

5555
5556
5557

5558
5559
5560

5561
5562
5563

5564
5565
5566

5567
5568
5569

5570
5571
5572

5573
5574
5575

5576
5577
5578

5579
5580
5581

5582
5583
5584

5585
5586
5587

5588
5589
5590

5591
5592
5593

5594
5595
5596

5597
5598
5599

5600
5601
5602

5603
5604
5605

5606
5607
5608

5609
5610
5611

5612
5613
5614

5615
5616
5617

5618
5619
5620

5621
5622
5623

5624
5625
5626

5627
5628
5629

5630
5631
5632

5633
5634
5635

5636
5637
5638

5639
5640
5641

5642
5643
5644

5645
5646
5647

5648
5649
5650

5651
5652
5653

5654
5655
5656

5657
5658
5659

5660
5661
5662

5663
5664
5665

5666
5667
5668

5669
5670
5671

5672
5673
5674

5675
5676
5677

5678
5679
5680

5681
5682
5683

5684
5685
5686

5687
5688
5689

5690
5691
5692

5693
5694
5695

5696
5697
5698

5699
5700
5701

5702
5703
5704

5705
5706
5707

5708
5709
5710

5711
5712
5713

5714
5715
5716

5717
5718
5719

5720
5721
5722

5723
5724
5725

5726
5727
5728

5729
5730
5731

5732
5733
5734

5735
5736
5737

5738
5739
5740

5741
5742
5743

5744
5745
5746

5747
5748
5749

5750
5751
5752

5753
5754
5755
5756
5757
5758
5759
....
5760
5761
5762
5763
5764
5765
5766

5767
5768
5769
5770
5771
5772
5773

5774
5775
5776
5777
5778
5779
5780

5781
5782
5783
5784
5785
5786
5787

5788
5789
5790
5791
5792
5793
5794

5795
5796
5797
5798
5799
5800
5801

5802
5803
5804
5805
5806
5807
5808

5809
5810
5811
5812
5813
5814
5815

5816
5817
5818
5819
5820
5821
5822

5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835

5836
5837
5838
5839
5840
5841
5842

5843
5844
5845
5846
5847
5848
5849

5850
5851
5852
5853
5854
5855
5856

5857
5858
5859
5860
5861
5862
5863
....
5866
5867
5868
5869
5870
5871
5872

5873
5874
5875

5876
5877
5878

5879
5880
5881

5882
5883
5884

5885
5886
5887

5888
5889
5890

5891
5892
5893

5894
5895
5896

5897
5898
5899

5900
5901
5902

5903
5904
5905

5906
5907
5908

5909
5910
5911

5912
5913
5914

5915
5916
5917

5918
5919
5920

5921
5922
5923

5924
5925
5926

5927
5928
5929

5930
5931
5932

5933
5934
5935

5936
5937
5938

5939
5940
5941

5942
5943
5944

5945
5946
5947

5948
5949
5950

5951
5952
5953

5954
5955
5956

5957
5958
5959

5960
5961
5962

5963
5964
5965

5966
5967
5968

5969
5970
5971

5972
5973
5974

5975
5976
5977

5978
5979
5980

5981
5982
5983

5984
5985
5986

5987
5988
5989

5990
5991
5992

5993
5994
5995

5996
5997
5998

5999
6000
6001

6002
6003
6004

6005
6006
6007

6008
6009
6010

6011
6012
6013

6014
6015
6016

6017
6018
6019

6020
6021
6022

6023
6024
6025

6026
6027
6028

6029
6030
6031

6032
6033
6034

6035
6036
6037

6038
6039
6040

6041
6042
6043

6044
6045
6046

6047
6048
6049

6050
6051
6052

6053
6054
6055

6056
6057
6058

6059
6060
6061

6062
6063
6064

6065
6066
6067

6068
6069
6070

6071
6072
6073

6074
6075
6076

6077
6078
6079

6080
6081
6082

6083
6084
6085

6086
6087
6088

6089
6090
6091

6092
6093
6094

6095
6096
6097

6098
6099
6100

6101
6102
6103

6104
6105
6106

6107
6108
6109

6110
6111
6112

6113
6114
6115

6116
6117
6118

6119
6120
6121

6122
6123
6124

6125
6126
6127

6128
6129
6130

6131
6132
6133

6134
6135
6136

6137
6138
6139

6140
6141
6142
6143
6144
6145
6146
6147

6148
6149
6150
6151
6152
6153
6154

6155
6156
6157
6158
6159
6160
6161

6162
6163
6164
6165
6166
6167
6168

6169
6170
6171
6172
6173
6174
6175

6176
6177
6178
6179
6180
6181
6182

6183
6184
6185
6186
6187
6188
6189

6190
6191
6192
6193
6194
6195
6196

6197
6198
6199
6200
6201
6202
6203

6204
6205
6206
6207
6208
6209
6210
6211
6212
6213

6214
6215
6216
6217
6218
6219
6220

6221
6222
6223
6224
6225
6226
6227

6228
6229
6230
6231
6232
6233
6234

6235
6236
6237
6238
6239
6240
6241

6242
6243
6244
6245
6246
6247
6248
#
# Copyright (c) 1996-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: expr.test,v 1.30.2.23 2005/08/25 15:46:53 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2.1
    namespace import -force ::tcltest::*
}

testConstraint testmathfunctions [expr {
................................................................................
    list [catch {expr {1ea}} err] $err
} {1 {syntax error in expression "1ea": extra tokens at end of expression}}

test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8

test expr-9.5a {CompileRelationalExpr: shift expr producing LONG_MIN} longIs64bit {
    expr {1<<63}
} -9223372036854775808

test expr-9.5b {CompileRelationalExpr: shift expr producing LONG_MIN} longIs32bit {
    expr {1<<31}
} -2147483648

test expr-9.6 {CompileRelationalExpr: error in shift expr} -body {
    catch {expr x>>3} msg
    set msg
} -match glob -result {syntax error in expression "x>>3": * preceding $*}
test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {
................................................................................
test expr-23.30 {INST_EXPON: special cases} {expr {wide(-1)**wide(2)}} 1
test expr-23.31 {INST_EXPON: special cases} {expr {wide(-1)**wide(-1)}} -1
test expr-23.32 {INST_EXPON: special cases} {expr {wide(1)**wide(1234567)}} 1
test expr-23.33 {INST_EXPON: special cases} {expr {wide(2)**wide(-2)}} 0
test expr-23.34 {INST_EXPON: special cases} {expr {2**0}} 1
test expr-23.35 {INST_EXPON: special cases} {expr {wide(2)**0}} 1


# Some compilers get this wrong; ensure that we work around it correctly
test expr-24.1 {expr edge cases; shifting} {expr int(5)>>32} 0
test expr-24.2 {expr edge cases; shifting} {expr int(5)>>63} 0
test expr-24.3 {expr edge cases; shifting} {expr wide(5)>>32} 0
test expr-24.4 {expr edge cases; shifting} {expr wide(5)>>63} 0
test expr-24.5 {expr edge cases; shifting} longIs32bit {expr int(5)<<32} 0
test expr-24.6 {expr edge cases; shifting} longIs32bit {expr int(5)<<63} 0
................................................................................
test expr-26.4 {'ni' operator} {expr {"a" ni ""}} 1
test expr-26.5 {'ni' operator} {expr {"" ni {a b c ""}}} 0
test expr-26.6 {'ni' operator} {expr {"" ni "a b c"}} 1
test expr-26.7 {'ni' operator} {expr {"" ni ""}} 1

foreach op {< <= == != > >=} {
    proc test$op {a b} [list expr "\$a $op \$b"]

}

test expr-27.1 {expr - correct ordering - not compiled} ieeeFloatingPoint {
    set problems {}
    # Ordering should be: -Infinity < -Normal < Subnormal < -0
    #                     < +0 < +Subnormal < +Normal < +Infinity
    # with equality within each class.
................................................................................
			":result is " $is ", should be $shouldBe" \n
		}
	    }
	}
    }
    set problems
} {}

test expr-27.2 {expr - correct ordering - compiled} ieeeFloatingPoint {
    set problems {}
    # Ordering should be: -Infinity < -Normal < Subnormal < -0
    #                     < +0 < +Subnormal < +Normal < +Infinity
    # with equality within each class.
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity
................................................................................
			":result is " $is ", should be $shouldBe" \n
		}
	    }
	}
    }
    set problems
} {}

test expr-27.3 {expr - NaN is unordered - not compiled} {
    set problems {}
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity NaN
    }
    foreach name1 $names {
	foreach op {< <= == != >= >} sb {0 0 0 1 0 0} {
................................................................................
		append problems NaN { } $op { } $name1 \
		    ": result is 1, should be $sb" \n
	    }
	}
    }
    set problems
} {}

test expr-27.4 {expr - NaN is unordered - compiled} {
    set problems {}
    set names {
	-Infinity -Normal -Subnormal -0 +0 +Subnormal +Normal +Infinity NaN
    }
    foreach name1 $names {
	foreach op {< <= == != >= >} sb {0 0 0 1 0 0} {
................................................................................
test expr-31.12 {boolean conversion} {expr bool(5)} 1
test expr-31.13 {boolean conversion} {expr bool(0x5)} 1
test expr-31.14 {boolean conversion} {expr bool(wide(5))} 1
test expr-31.15 {boolean conversion} -body {
    expr bool("fred")
} -returnCodes error -match glob -result *


test expr-32.1 {expr mod basics} {
    set mod_nums [list \
        {-3 1} {-3 2} {-3 3} {-3 4} {-3 5} \
        {-3 -1} {-3 -2} {-3 -3} {-3 -4} {-3 -5} \
        {-2 1} {-2 2} {-2 3} {-2 4} {-2 5} \
        {-2 -1} {-2 -2} {-2 -3} {-2 -4} {-2 -5} \
        {-1 1} {-1 2} {-1 3} {-1 4} {-1 5} \
................................................................................
        [expr {$max_long_str + 0}] \
        [expr {$max_long + 0}] \
        [expr {2147483647 + 0}] \
        [expr {$max_long == $max_long_hex}] \
        [expr {(2147483647 + 1) < 0}] \

} {2147483647 2147483647 2147483647 2147483647 1 1}

test expr-33.2 {parse smallest long value} {longIs32bit} {
    set min_long_str -2147483648
    set min_long_hex "-0x80000000 "

    set min_long -2147483648
    # This will convert to integer (not wide) internal rep
    string is integer $min_long
................................................................................
        [expr {$min_long_str + 0}] \
        [expr {$min_long + 0}] \
        [expr {-2147483648 + 0}] \
        [expr {$min_long == $min_long_hex}] \
        [expr {(-2147483648 - 1) == 0x7FFFFFFF}] \

} {-2147483648 -2147483648 -2147483648 -2147483648 1 1}

test expr-33.3 {parse largest wide value} {wideIs64bit} {
    set max_wide_str 9223372036854775807
    set max_wide_hex "0x7FFFFFFFFFFFFFFF "

    # Convert to wide integer
    set max_wide 9223372036854775807
    string is integer $max_wide
................................................................................
        [expr {$max_wide_str + 0}] \
        [expr {$max_wide + 0}] \
        [expr {9223372036854775807 + 0}] \
        [expr {$max_wide == $max_wide_hex}] \
        [expr {(9223372036854775807 + 1) < 0}] \

} {9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807 1 1}

test expr-33.4 {parse smallest wide value} {wideIs64bit} {
    set min_wide_str -9223372036854775808
    set min_wide_hex "-0x8000000000000000 "

    set min_wide -9223372036854775808
    # Convert to wide integer
    string is integer $min_wide
................................................................................
        [expr {$min_wide + 0}] \
        [expr {-9223372036854775808 + 0}] \
        [expr {$min_wide == $min_wide_hex}] \
        [expr {(-9223372036854775808 - 1) == 0x7FFFFFFFFFFFFFFF}] \

} {-9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 1 1}


set min -2147483648
set max 2147483647

test expr-34.1 {expr edge cases} {longIs32bit} {
    expr {$min / $min}
} {1}

test expr-34.2 {expr edge cases} {longIs32bit} {
    expr {$min % $min}
} {0}

test expr-34.3 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 1)}
} {1}

test expr-34.4 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 1)}
} {-1}

test expr-34.5 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 2)}
} {1}

test expr-34.6 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 2)}
} {-2}

test expr-34.7 {expr edge cases} {longIs32bit} {
    expr {$min / ($min + 3)}
} {1}

test expr-34.8 {expr edge cases} {longIs32bit} {
    expr {$min % ($min + 3)}
} {-3}

test expr-34.9 {expr edge cases} {longIs32bit} {
    expr {$min / -3}
} {715827882}

test expr-34.10 {expr edge cases} {longIs32bit} {
    expr {$min % -3}
} {-2}

test expr-34.11 {expr edge cases} {longIs32bit} {
    expr {$min / -2}
} {1073741824}

test expr-34.12 {expr edge cases} {longIs32bit} {
    expr {$min % -2}
} {0}

test expr-34.13 {expr edge cases} {longIs32bit} {
    expr {$min / -1}
} {-2147483648}

test expr-34.14 {expr edge cases} {longIs32bit} {
    expr {$min % -1}
} {0}

test expr-34.15 {expr edge cases} {longIs32bit} {
    expr {$min * -1}
} $min

test expr-34.16 {expr edge cases} {longIs32bit} {
    expr {-$min}
} $min

test expr-34.17 {expr edge cases} {longIs32bit} {
    expr {$min / 1}
} $min

test expr-34.18 {expr edge cases} {longIs32bit} {
    expr {$min % 1}
} {0}

test expr-34.19 {expr edge cases} {longIs32bit} {
    expr {$min / 2}
} {-1073741824}

test expr-34.20 {expr edge cases} {longIs32bit} {
    expr {$min % 2}
} {0}

test expr-34.21 {expr edge cases} {longIs32bit} {
    expr {$min / 3}
} {-715827883}

test expr-34.22 {expr edge cases} {longIs32bit} {
    expr {$min % 3}
} {1}

test expr-34.23 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 3)}
} {-2}

test expr-34.24 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 3)}
} {2147483640}

test expr-34.25 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 2)}
} {-2}

test expr-34.26 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 2)}
} {2147483642}

test expr-34.27 {expr edge cases} {longIs32bit} {
    expr {$min / ($max - 1)}
} {-2}

test expr-34.28 {expr edge cases} {longIs32bit} {
    expr {$min % ($max - 1)}
} {2147483644}

test expr-34.29 {expr edge cases} {longIs32bit} {
    expr {$min / $max}
} {-2}

test expr-34.30 {expr edge cases} {longIs32bit} {
    expr {$min % $max}
} {2147483646}

test expr-34.31 {expr edge cases} {longIs32bit} {
    expr {$max / $max}
} {1}

test expr-34.32 {expr edge cases} {longIs32bit} {
    expr {$max % $max}
} {0}

test expr-34.33 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 1)}
} {1}

test expr-34.34 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 1)}
} {1}

test expr-34.35 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 2)}
} {1}

test expr-34.36 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 2)}
} {2}

test expr-34.37 {expr edge cases} {longIs32bit} {
    expr {$max / ($max - 3)}
} {1}

test expr-34.38 {expr edge cases} {longIs32bit} {
    expr {$max % ($max - 3)}
} {3}

test expr-34.39 {expr edge cases} {longIs32bit} {
    expr {$max / 3}
} {715827882}

test expr-34.40 {expr edge cases} {longIs32bit} {
    expr {$max % 3}
} {1}

test expr-34.41 {expr edge cases} {longIs32bit} {
    expr {$max / 2}
} {1073741823}

test expr-34.42 {expr edge cases} {longIs32bit} {
    expr {$max % 2}
} {1}

test expr-34.43 {expr edge cases} {longIs32bit} {
    expr {$max / 1}
} $max

test expr-34.44 {expr edge cases} {longIs32bit} {
    expr {$max % 1}
} {0}

test expr-34.45 {expr edge cases} {longIs32bit} {
    expr {$max / -1}
} "-$max"

test expr-34.46 {expr edge cases} {longIs32bit} {
    expr {$max % -1}
} {0}

test expr-34.47 {expr edge cases} {longIs32bit} {
    expr {$max / -2}
} {-1073741824}

test expr-34.48 {expr edge cases} {longIs32bit} {
    expr {$max % -2}
} {-1}

test expr-34.49 {expr edge cases} {longIs32bit} {
    expr {$max / -3}
} {-715827883}

test expr-34.50 {expr edge cases} {longIs32bit} {
    expr {$max % -3}
} {-2}

test expr-34.51 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 3)}
} {-2}

test expr-34.52 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 3)}
} {-2147483643}

test expr-34.53 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 2)}
} {-2}

test expr-34.54 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 2)}
} {-2147483645}

test expr-34.55 {expr edge cases} {longIs32bit} {
    expr {$max / ($min + 1)}
} {-1}

test expr-34.56 {expr edge cases} {longIs32bit} {
    expr {$max % ($min + 1)}
} {0}

test expr-34.57 {expr edge cases} {longIs32bit} {
    expr {$max / $min}
} {-1}

test expr-34.58 {expr edge cases} {longIs32bit} {
    expr {$max % $min}
} {-1}

test expr-34.59 {expr edge cases} {longIs32bit} {
    expr {($min + 1) / ($max - 1)}
} {-2}

test expr-34.60 {expr edge cases} {longIs32bit} {
    expr {($min + 1) % ($max - 1)}
} {2147483645}

test expr-34.61 {expr edge cases} {longIs32bit} {
    expr {($max - 1) / ($min + 1)}
} {-1}

test expr-34.62 {expr edge cases} {longIs32bit} {
    expr {($max - 1) % ($min + 1)}
} {-1}

test expr-34.63 {expr edge cases} {longIs32bit} {
    expr {($max - 1) / $min}
} {-1}

test expr-34.64 {expr edge cases} {longIs32bit} {
    expr {($max - 1) % $min}
} {-2}

test expr-34.65 {expr edge cases} {longIs32bit} {
    expr {($max - 2) / $min}
} {-1}

test expr-34.66 {expr edge cases} {longIs32bit} {
    expr {($max - 2) % $min}
} {-3}

test expr-34.67 {expr edge cases} {longIs32bit} {
    expr {($max - 3) / $min}
} {-1}

test expr-34.68 {expr edge cases} {longIs32bit} {
    expr {($max - 3) % $min}
} {-4}

test expr-34.69 {expr edge cases} {longIs32bit} {
    expr {-3 / $min}
} {0}

test expr-34.70 {expr edge cases} {longIs32bit} {
    expr {-3 % $min}
} {-3}

test expr-34.71 {expr edge cases} {longIs32bit} {
    expr {-2 / $min}
} {0}

test expr-34.72 {expr edge cases} {longIs32bit} {
    expr {-2 % $min}
} {-2}

test expr-34.73 {expr edge cases} {longIs32bit} {
    expr {-1 / $min}
} {0}

test expr-34.74 {expr edge cases} {longIs32bit} {
    expr {-1 % $min}
} {-1}

test expr-34.75 {expr edge cases} {longIs32bit} {
    expr {0 / $min}
} {0}

test expr-34.76 {expr edge cases} {longIs32bit} {
    expr {0 % $min}
} {0}

test expr-34.77 {expr edge cases} {longIs32bit} {
    expr {0 / ($min + 1)}
} {0}

test expr-34.78 {expr edge cases} {longIs32bit} {
    expr {0 % ($min + 1)}
} {0}

test expr-34.79 {expr edge cases} {longIs32bit} {
    expr {1 / $min}
} {-1}

test expr-34.80 {expr edge cases} {longIs32bit} {
    expr {1 % $min}
} {-2147483647}

test expr-34.81 {expr edge cases} {longIs32bit} {
    expr {1 / ($min + 1)}
} {-1}

test expr-34.82 {expr edge cases} {longIs32bit} {
    expr {1 % ($min + 1)}
} {-2147483646}

test expr-34.83 {expr edge cases} {longIs32bit} {
    expr {2 / $min}
} {-1}

test expr-34.84 {expr edge cases} {longIs32bit} {
    expr {2 % $min}
} {-2147483646}

test expr-34.85 {expr edge cases} {longIs32bit} {
    expr {2 / ($min + 1)}
} {-1}

test expr-34.86 {expr edge cases} {longIs32bit} {
    expr {2 % ($min + 1)}
} {-2147483645}

test expr-34.87 {expr edge cases} {longIs32bit} {
    expr {3 / $min}
} {-1}

test expr-34.88 {expr edge cases} {longIs32bit} {
    expr {3 % $min}
} {-2147483645}

test expr-34.89 {expr edge cases} {longIs32bit} {
    expr {3 / ($min + 1)}
} {-1}

test expr-34.90 {expr edge cases} {longIs32bit} {
    expr {3 % ($min + 1)}
} {-2147483644}

# Euclidean property:
# quotient * divisor + remainder = dividend

................................................................................
test expr-35.1 {expr edge cases} {longIs32bit} {
    set dividend $max
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($divisor * $q) + $r}]
} {1073741823 * 2 + 1 = 2147483647}

test expr-35.2 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1073741823 * 2 + 0 = 2147483646}

test expr-35.3 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1073741822 * 2 + 1 = 2147483645}

test expr-35.4 {expr edge cases} {longIs32bit} {
    set dividend $max
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * 3 + 1 = 2147483647}

test expr-35.5 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 1}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * 3 + 0 = 2147483646}

test expr-35.6 {expr edge cases} {longIs32bit} {
    set dividend [expr {$max - 2}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827881 * 3 + 2 = 2147483645}

test expr-35.7 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741824 * 2 + 0 = -2147483648}

test expr-35.8 {expr edge cases} {longIs32bit} {
    set dividend [expr {$min + 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741824 * 2 + 1 = -2147483647}

test expr-35.9 {expr edge cases} {longIs32bit} {
    set dividend [expr {$min + 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-1073741823 * 2 + 0 = -2147483646}

test expr-35.10 {expr edge cases} {longIs32bit} {
    # Two things could happen here. The multiplication
    # could overflow a 32 bit type, so that when
    # 1 is added it overflows again back to min.
    # The multiplication could also use a wide type
    # to hold ($min - 1) until 1 is added and
    # the number becomes $min again.
    set dividend $min
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-715827883 * 3 + 1 = -2147483648}

test expr-35.11 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor -3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {715827882 * -3 + -2 = -2147483648}

test expr-35.12 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor $min
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483648 + 0 = -2147483648}

test expr-35.13 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor [expr {$min + 1}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483647 + -1 = -2147483648}

test expr-35.14 {expr edge cases} {longIs32bit} {
    set dividend $min
    set divisor [expr {$min + 2}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -2147483646 + -2 = -2147483648}
................................................................................

set min -9223372036854775808
set max 9223372036854775807

test expr-36.1 {expr edge cases} {wideIs64bit} {
    expr {$min / $min}
} {1}

test expr-36.2 {expr edge cases} {wideIs64bit} {
    expr {$min % $min}
} {0}

test expr-36.3 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 1)}
} {1}

test expr-36.4 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 1)}
} {-1}

test expr-36.5 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 2)}
} {1}

test expr-36.6 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 2)}
} {-2}

test expr-36.7 {expr edge cases} {wideIs64bit} {
    expr {$min / ($min + 3)}
} {1}

test expr-36.8 {expr edge cases} {wideIs64bit} {
    expr {$min % ($min + 3)}
} {-3}

test expr-36.9 {expr edge cases} {wideIs64bit} {
    expr {$min / -3}
} {3074457345618258602}

test expr-36.10 {expr edge cases} {wideIs64bit} {
    expr {$min % -3}
} {-2}

test expr-36.11 {expr edge cases} {wideIs64bit} {
    expr {$min / -2}
} {4611686018427387904}

test expr-36.12 {expr edge cases} {wideIs64bit} {
    expr {$min % -2}
} {0}

test expr-36.13 {expr edge cases} {wideIs64bit} {
    expr {$min / -1}
} $min

test expr-36.14 {expr edge cases} {wideIs64bit} {
    expr {$min % -1}
} {0}

test expr-36.15 {expr edge cases} {wideIs64bit} {
    expr {$min * -1}
} $min

test expr-36.16 {expr edge cases} {wideIs64bit} {
    expr {-$min}
} $min

test expr-36.17 {expr edge cases} {wideIs64bit} {
    expr {$min / 1}
} $min

test expr-36.18 {expr edge cases} {wideIs64bit} {
    expr {$min % 1}
} {0}

test expr-36.19 {expr edge cases} {wideIs64bit} {
    expr {$min / 2}
} {-4611686018427387904}

test expr-36.20 {expr edge cases} {wideIs64bit} {
    expr {$min % 2}
} {0}

test expr-36.21 {expr edge cases} {wideIs64bit} {
    expr {$min / 3}
} {-3074457345618258603}

test expr-36.22 {expr edge cases} {wideIs64bit} {
    expr {$min % 3}
} {1}

test expr-36.23 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 3)}
} {-2}

test expr-36.24 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 3)}
} {9223372036854775800}

test expr-36.25 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 2)}
} {-2}

test expr-36.26 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 2)}
} {9223372036854775802}

test expr-36.27 {expr edge cases} {wideIs64bit} {
    expr {$min / ($max - 1)}
} {-2}

test expr-36.28 {expr edge cases} {wideIs64bit} {
    expr {$min % ($max - 1)}
} {9223372036854775804}

test expr-36.29 {expr edge cases} {wideIs64bit} {
    expr {$min / $max}
} {-2}

test expr-36.30 {expr edge cases} {wideIs64bit} {
    expr {$min % $max}
} {9223372036854775806}

test expr-36.31 {expr edge cases} {wideIs64bit} {
    expr {$max / $max}
} {1}

test expr-36.32 {expr edge cases} {wideIs64bit} {
    expr {$max % $max}
} {0}

test expr-36.33 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 1)}
} {1}

test expr-36.34 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 1)}
} {1}

test expr-36.35 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 2)}
} {1}

test expr-36.36 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 2)}
} {2}

test expr-36.37 {expr edge cases} {wideIs64bit} {
    expr {$max / ($max - 3)}
} {1}

test expr-36.38 {expr edge cases} {wideIs64bit} {
    expr {$max % ($max - 3)}
} {3}

test expr-36.39 {expr edge cases} {wideIs64bit} {
    expr {$max / 3}
} {3074457345618258602}

test expr-36.40 {expr edge cases} {wideIs64bit} {
    expr {$max % 3}
} {1}

test expr-36.41 {expr edge cases} {wideIs64bit} {
    expr {$max / 2}
} {4611686018427387903}

test expr-36.42 {expr edge cases} {wideIs64bit} {
    expr {$max % 2}
} {1}

test expr-36.43 {expr edge cases} {wideIs64bit} {
    expr {$max / 1}
} $max

test expr-36.44 {expr edge cases} {wideIs64bit} {
    expr {$max % 1}
} {0}

test expr-36.45 {expr edge cases} {wideIs64bit} {
    expr {$max / -1}
} "-$max"

test expr-36.46 {expr edge cases} {wideIs64bit} {
    expr {$max % -1}
} {0}

test expr-36.47 {expr edge cases} {wideIs64bit} {
    expr {$max / -2}
} {-4611686018427387904}

test expr-36.48 {expr edge cases} {wideIs64bit} {
    expr {$max % -2}
} {-1}

test expr-36.49 {expr edge cases} {wideIs64bit} {
    expr {$max / -3}
} {-3074457345618258603}

test expr-36.50 {expr edge cases} {wideIs64bit} {
    expr {$max % -3}
} {-2}

test expr-36.51 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 3)}
} {-2}

test expr-36.52 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 3)}
} {-9223372036854775803}

test expr-36.53 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 2)}
} {-2}

test expr-36.54 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 2)}
} {-9223372036854775805}

test expr-36.55 {expr edge cases} {wideIs64bit} {
    expr {$max / ($min + 1)}
} {-1}

test expr-36.56 {expr edge cases} {wideIs64bit} {
    expr {$max % ($min + 1)}
} {0}

test expr-36.57 {expr edge cases} {wideIs64bit} {
    expr {$max / $min}
} {-1}

test expr-36.58 {expr edge cases} {wideIs64bit} {
    expr {$max % $min}
} {-1}

test expr-36.59 {expr edge cases} {wideIs64bit} {
    expr {($min + 1) / ($max - 1)}
} {-2}

test expr-36.60 {expr edge cases} {wideIs64bit} {
    expr {($min + 1) % ($max - 1)}
} {9223372036854775805}

test expr-36.61 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) / ($min + 1)}
} {-1}

test expr-36.62 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) % ($min + 1)}
} {-1}

test expr-36.63 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) / $min}
} {-1}

test expr-36.64 {expr edge cases} {wideIs64bit} {
    expr {($max - 1) % $min}
} {-2}

test expr-36.65 {expr edge cases} {wideIs64bit} {
    expr {($max - 2) / $min}
} {-1}

test expr-36.66 {expr edge cases} {wideIs64bit} {
    expr {($max - 2) % $min}
} {-3}

test expr-36.67 {expr edge cases} {wideIs64bit} {
    expr {($max - 3) / $min}
} {-1}

test expr-36.68 {expr edge cases} {wideIs64bit} {
    expr {($max - 3) % $min}
} {-4}

test expr-36.69 {expr edge cases} {wideIs64bit} {
    expr {-3 / $min}
} {0}

test expr-36.70 {expr edge cases} {wideIs64bit} {
    expr {-3 % $min}
} {-3}

test expr-36.71 {expr edge cases} {wideIs64bit} {
    expr {-2 / $min}
} {0}

test expr-36.72 {expr edge cases} {wideIs64bit} {
    expr {-2 % $min}
} {-2}

test expr-36.73 {expr edge cases} {wideIs64bit} {
    expr {-1 / $min}
} {0}

test expr-36.74 {expr edge cases} {wideIs64bit} {
    expr {-1 % $min}
} {-1}

test expr-36.75 {expr edge cases} {wideIs64bit} {
    expr {0 / $min}
} {0}

test expr-36.76 {expr edge cases} {wideIs64bit} {
    expr {0 % $min}
} {0}

test expr-36.77 {expr edge cases} {wideIs64bit} {
    expr {0 / ($min + 1)}
} {0}

test expr-36.78 {expr edge cases} {wideIs64bit} {
    expr {0 % ($min + 1)}
} {0}

test expr-36.79 {expr edge cases} {wideIs64bit} {
    expr {1 / $min}
} {-1}

test expr-36.80 {expr edge cases} {wideIs64bit} {
    expr {1 % $min}
} {-9223372036854775807}

test expr-36.81 {expr edge cases} {wideIs64bit} {
    expr {1 / ($min + 1)}
} {-1}

test expr-36.82 {expr edge cases} {wideIs64bit} {
    expr {1 % ($min + 1)}
} {-9223372036854775806}

test expr-36.83 {expr edge cases} {wideIs64bit} {
    expr {2 / $min}
} {-1}

test expr-36.84 {expr edge cases} {wideIs64bit} {
    expr {2 % $min}
} {-9223372036854775806}

test expr-36.85 {expr edge cases} {wideIs64bit} {
    expr {2 / ($min + 1)}
} {-1}

test expr-36.86 {expr edge cases} {wideIs64bit} {
    expr {2 % ($min + 1)}
} {-9223372036854775805}

test expr-36.87 {expr edge cases} {wideIs64bit} {
    expr {3 / $min}
} {-1}

test expr-36.88 {expr edge cases} {wideIs64bit} {
    expr {3 % $min}
} {-9223372036854775805}

test expr-36.89 {expr edge cases} {wideIs64bit} {
    expr {3 / ($min + 1)}
} {-1}

test expr-36.90 {expr edge cases} {wideIs64bit} {
    expr {3 % ($min + 1)}
} {-9223372036854775804}


test expr-37.1 {expr edge cases} {wideIs64bit} {
    set dividend $max
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($divisor * $q) + $r}]
} {4611686018427387903 * 2 + 1 = 9223372036854775807}

test expr-37.2 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {4611686018427387903 * 2 + 0 = 9223372036854775806}

test expr-37.3 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {4611686018427387902 * 2 + 1 = 9223372036854775805}

test expr-37.4 {expr edge cases} {wideIs64bit} {
    set dividend $max
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * 3 + 1 = 9223372036854775807}

test expr-37.5 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 1}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * 3 + 0 = 9223372036854775806}

test expr-37.6 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$max - 2}]
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258601 * 3 + 2 = 9223372036854775805}

test expr-37.7 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387904 * 2 + 0 = -9223372036854775808}

test expr-37.8 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$min + 1}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387904 * 2 + 1 = -9223372036854775807}

test expr-37.9 {expr edge cases} {wideIs64bit} {
    set dividend [expr {$min + 2}]
    set divisor 2
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-4611686018427387903 * 2 + 0 = -9223372036854775806}

test expr-37.10 {expr edge cases} {wideIs64bit} {
    # Multiplication overflows 64 bit type here,
    # so when the 1 is added it overflows
    # again and we end up back at min.
    set dividend $min
    set divisor 3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {-3074457345618258603 * 3 + 1 = -9223372036854775808}

test expr-37.11 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor -3
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {3074457345618258602 * -3 + -2 = -9223372036854775808}

test expr-37.12 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor $min
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775808 + 0 = -9223372036854775808}

test expr-37.13 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor [expr {$min + 1}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775807 + -1 = -9223372036854775808}

test expr-37.14 {expr edge cases} {wideIs64bit} {
    set dividend $min
    set divisor [expr {$min + 2}]
    set q [expr {$dividend / $divisor}]
    set r [expr {$dividend % $divisor}]
    list $q * $divisor + $r = [expr {($q * $divisor) + $r}]
} {1 * -9223372036854775806 + -2 = -9223372036854775808}


test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} {wideIs64bit} {
    expr {abs(-2147483648)}
} 2147483648

testConstraint testexprlongobj   [llength [info commands testexprlongobj]]
testConstraint testexprdoubleobj [llength [info commands testexprdoubleobj]]

Changes to tests/io.test.


1
2
3
4
5
6
7
.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
....
7107
7108
7109
7110
7111
7112
7113




































































































































































































































































7114
7115
7116
7117
7118
7119
7120
7121
7122

# Functionality covered: operation of all IO commands, and all procedures
# defined in generic/tclIO.c.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
................................................................................
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: io.test,v 1.65.2.2 2005/04/25 21:37:28 kennykb Exp $

if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
namespace eval ::tcl::test::io {

................................................................................
    namespace import ::tcltest::interpreter
    namespace import ::tcltest::makeFile
    namespace import ::tcltest::removeFile
    namespace import ::tcltest::test
    namespace import ::tcltest::testConstraint
    namespace import ::tcltest::viewFile

testConstraint testchannel [llength [info commands testchannel]]
testConstraint exec [llength [info commands exec]]
testConstraint openpipe 1
testConstraint fileevent [llength [info commands fileevent]]
testConstraint fcopy [llength [info commands fcopy]]
testConstraint testfevent [llength [info commands testfevent]]
testConstraint testchannelevent [llength [info commands testchannelevent]]
testConstraint testmainthread [llength [info commands testmainthread]]

# You need a *very* special environment to do some tests.  In
# particular, many file systems do not support large-files...
testConstraint largefileSupport 0

# some tests can only be run is umask is 2
# if "umask" cannot be run, the tests will be skipped.
................................................................................
    #lappend res [read $f; tell $f]
    close $f
    set res
} -cleanup {
    removeFile eofchar
} -result {77 = 23431}





































































































































































































































































# cleanup
foreach file [list fooBar longfile script output test1 pipe my_script foo \
	bar test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
    removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return
>







 







|







 







|
|
|
|
|
|

|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









1
2
3
4
5
6
7
8
.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
....
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
# -*- tcl -*-
# Functionality covered: operation of all IO commands, and all procedures
# defined in generic/tclIO.c.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
................................................................................
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: io.test,v 1.65.2.3 2005/08/25 15:46:53 dgp Exp $

if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
namespace eval ::tcl::test::io {

................................................................................
    namespace import ::tcltest::interpreter
    namespace import ::tcltest::makeFile
    namespace import ::tcltest::removeFile
    namespace import ::tcltest::test
    namespace import ::tcltest::testConstraint
    namespace import ::tcltest::viewFile

testConstraint testchannel      [llength [info commands testchannel]]
testConstraint exec             [llength [info commands exec]]
testConstraint openpipe         1
testConstraint fileevent        [llength [info commands fileevent]]
testConstraint fcopy            [llength [info commands fcopy]]
testConstraint testfevent       [llength [info commands testfevent]]
testConstraint testchannelevent [llength [info commands testchannelevent]]
testConstraint testmainthread   [llength [info commands testmainthread]]

# You need a *very* special environment to do some tests.  In
# particular, many file systems do not support large-files...
testConstraint largefileSupport 0

# some tests can only be run is umask is 2
# if "umask" cannot be run, the tests will be skipped.
................................................................................
    #lappend res [read $f; tell $f]
    close $f
    set res
} -cleanup {
    removeFile eofchar
} -result {77 = 23431}


# Test the cutting and splicing of channels, this is incidentially the
# attach/detach facility of package Thread, but __without any
# safeguards__. It can also be used to emulate transfer of channels
# between threads, and is used for that here.

test io-70.0 {Cutting & Splicing channels} {testchannel} {
    set f [makeFile {... dummy ...} cutsplice]
    set c [open $f r]

    set     res {}
    lappend res [catch {seek $c 0 start}]
    testchannel cut $c

    lappend res [catch {seek $c 0 start}]
    testchannel splice $c

    lappend res [catch {seek $c 0 start}]
    close $c

    removeFile cutsplice

    set res
} {0 1 0}


# Duplicate of code in "thread.test". Find a better way of doing this
# without duplication. Maybe placement into a proc which transforms to
# nop after the first call, and placement of its defintion in a
# central location.

testConstraint testthread [expr {[info commands testthread] != {}}]

if {[testConstraint testthread]} {
    testthread errorproc ThreadError

    proc ThreadError {id info} {
	global threadError
	set threadError $info
    }

    proc ThreadNullError {id info} {
	# ignore
    }
}

test io-70.1 {Transfer channel} {testchannel testthread} {
    set f [makeFile {... dummy ...} cutsplice]
    set c [open $f r]

    set     res {}
    lappend res [catch {seek $c 0 start}]
    testchannel cut $c
    lappend res [catch {seek $c 0 start}]

    set tid [testthread create]
    testthread send $tid [list set c $c]
    lappend res [testthread send $tid {
	testchannel splice $c
	set res [catch {seek $c 0 start}]
	close $c
	set res
    }]

    tcltest::threadReap
    removeFile cutsplice

    set res
} {0 1 0}

# ### ### ### ######### ######### #########

foreach {n msg expected} {
     0 {}                                 {}
     1 {{message only}}                   {{message only}}
     2 {-options x}                       {-options x}
     3 {-options {x y} {the message}}     {-options {x y} {the message}}

     4 {-code 1     -level 0 -f ba snarf} {-code 1     -level 0 -f ba snarf}
     5 {-code 0     -level 0 -f ba snarf} {-code 1     -level 0 -f ba snarf}
     6 {-code 1     -level 5 -f ba snarf} {-code 1     -level 0 -f ba snarf}
     7 {-code 0     -level 5 -f ba snarf} {-code 1     -level 0 -f ba snarf}
     8 {-code error -level 0 -f ba snarf} {-code error -level 0 -f ba snarf}
     9 {-code ok    -level 0 -f ba snarf} {-code 1     -level 0 -f ba snarf}
    10 {-code error -level 5 -f ba snarf} {-code error -level 0 -f ba snarf}
    11 {-code ok    -level 5 -f ba snarf} {-code 1     -level 0 -f ba snarf}
    12 {-code boss  -level 0 -f ba snarf} {-code 1     -level 0 -f ba snarf}
    13 {-code boss  -level 5 -f ba snarf} {-code 1     -level 0 -f ba snarf}
    14 {-code 1     -level 0 -f ba}       {-code 1     -level 0 -f ba}
    15 {-code 0     -level 0 -f ba}       {-code 1     -level 0 -f ba}
    16 {-code 1     -level 5 -f ba}       {-code 1     -level 0 -f ba}
    17 {-code 0     -level 5 -f ba}       {-code 1     -level 0 -f ba}
    18 {-code error -level 0 -f ba}       {-code error -level 0 -f ba}
    19 {-code ok    -level 0 -f ba}       {-code 1     -level 0 -f ba}
    20 {-code error -level 5 -f ba}       {-code error -level 0 -f ba}
    21 {-code ok    -level 5 -f ba}       {-code 1     -level 0 -f ba}
    22 {-code boss  -level 0 -f ba}       {-code 1     -level 0 -f ba}
    23 {-code boss  -level 5 -f ba}       {-code 1     -level 0 -f ba}
    24 {-code 1     -level X -f ba snarf} {-code 1     -level 0 -f ba snarf}
    25 {-code 0     -level X -f ba snarf} {-code 1     -level 0 -f ba snarf}
    26 {-code error -level X -f ba snarf} {-code error -level 0 -f ba snarf}
    27 {-code ok    -level X -f ba snarf} {-code 1     -level 0 -f ba snarf}
    28 {-code boss  -level X -f ba snarf} {-code 1     -level 0 -f ba snarf}
    29 {-code 1     -level X -f ba}       {-code 1     -level 0 -f ba}
    30 {-code 0     -level X -f ba}       {-code 1     -level 0 -f ba}
    31 {-code error -level X -f ba}       {-code error -level 0 -f ba}
    32 {-code ok    -level X -f ba}       {-code 1     -level 0 -f ba}
    33 {-code boss  -level X -f ba}       {-code 1     -level 0 -f ba}

    34 {-code 1 -code 1     -level 0 -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    35 {-code 1 -code 0     -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    36 {-code 1 -code 1     -level 5 -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    37 {-code 1 -code 0     -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    38 {-code 1 -code error -level 0 -f ba snarf} {-code 1 -code error -level 0 -f ba snarf}
    39 {-code 1 -code ok    -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    40 {-code 1 -code error -level 5 -f ba snarf} {-code 1 -code error -level 0 -f ba snarf}
    41 {-code 1 -code ok    -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    42 {-code 1 -code boss  -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    43 {-code 1 -code boss  -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    44 {-code 1 -code 1     -level 0 -f ba}       {-code 1 -code 1     -level 0 -f ba}
    45 {-code 1 -code 0     -level 0 -f ba}       {-code 1             -level 0 -f ba}
    46 {-code 1 -code 1     -level 5 -f ba}       {-code 1 -code 1     -level 0 -f ba}
    47 {-code 1 -code 0     -level 5 -f ba}       {-code 1             -level 0 -f ba}
    48 {-code 1 -code error -level 0 -f ba}       {-code 1 -code error -level 0 -f ba}
    49 {-code 1 -code ok    -level 0 -f ba}       {-code 1             -level 0 -f ba}
    50 {-code 1 -code error -level 5 -f ba}       {-code 1 -code error -level 0 -f ba}
    51 {-code 1 -code ok    -level 5 -f ba}       {-code 1             -level 0 -f ba}
    52 {-code 1 -code boss  -level 0 -f ba}       {-code 1             -level 0 -f ba}
    53 {-code 1 -code boss  -level 5 -f ba}       {-code 1             -level 0 -f ba}
    54 {-code 1 -code 1     -level X -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    55 {-code 1 -code 0     -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    56 {-code 1 -code error -level X -f ba snarf} {-code 1 -code error -level 0 -f ba snarf}
    57 {-code 1 -code ok    -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    58 {-code 1 -code boss  -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    59 {-code 1 -code 1     -level X -f ba}       {-code 1 -code 1     -level 0 -f ba}
    60 {-code 1 -code 0     -level X -f ba}       {-code 1             -level 0 -f ba}
    61 {-code 1 -code error -level X -f ba}       {-code 1 -code error -level 0 -f ba}
    62 {-code 1 -code ok    -level X -f ba}       {-code 1             -level 0 -f ba}
    63 {-code 1 -code boss  -level X -f ba}       {-code 1             -level 0 -f ba}

    64 {-code 0 -code 1     -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    65 {-code 0 -code 0     -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    66 {-code 0 -code 1     -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    67 {-code 0 -code 0     -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    68 {-code 0 -code error -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    69 {-code 0 -code ok    -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    70 {-code 0 -code error -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    71 {-code 0 -code ok    -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    72 {-code 0 -code boss  -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    73 {-code 0 -code boss  -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    74 {-code 0 -code 1     -level 0 -f ba}       {-code 1 -level 0 -f ba}
    75 {-code 0 -code 0     -level 0 -f ba}       {-code 1 -level 0 -f ba}
    76 {-code 0 -code 1     -level 5 -f ba}       {-code 1 -level 0 -f ba}
    77 {-code 0 -code 0     -level 5 -f ba}       {-code 1 -level 0 -f ba}
    78 {-code 0 -code error -level 0 -f ba}       {-code 1 -level 0 -f ba}
    79 {-code 0 -code ok    -level 0 -f ba}       {-code 1 -level 0 -f ba}
    80 {-code 0 -code error -level 5 -f ba}       {-code 1 -level 0 -f ba}
    81 {-code 0 -code ok    -level 5 -f ba}       {-code 1 -level 0 -f ba}
    82 {-code 0 -code boss  -level 0 -f ba}       {-code 1 -level 0 -f ba}
    83 {-code 0 -code boss  -level 5 -f ba}       {-code 1 -level 0 -f ba}
    84 {-code 0 -code 1     -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    85 {-code 0 -code 0     -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    86 {-code 0 -code error -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    87 {-code 0 -code ok    -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    88 {-code 0 -code boss  -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    89 {-code 0 -code 1     -level X -f ba}       {-code 1 -level 0 -f ba}
    90 {-code 0 -code 0     -level X -f ba}       {-code 1 -level 0 -f ba}
    91 {-code 0 -code error -level X -f ba}       {-code 1 -level 0 -f ba}
    92 {-code 0 -code ok    -level X -f ba}       {-code 1 -level 0 -f ba}
    93 {-code 0 -code boss  -level X -f ba}       {-code 1 -level 0 -f ba}

    94 {-code 1     -code 1 -level 0 -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    95 {-code 0     -code 1 -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    96 {-code 1     -code 1 -level 5 -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    97 {-code 0     -code 1 -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    98 {-code error -code 1 -level 0 -f ba snarf} {-code error -code 1 -level 0 -f ba snarf}
    99 {-code ok    -code 1 -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    a0 {-code error -code 1 -level 5 -f ba snarf} {-code error -code 1 -level 0 -f ba snarf}
    a1 {-code ok    -code 1 -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    a2 {-code boss  -code 1 -level 0 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    a3 {-code boss  -code 1 -level 5 -f ba snarf} {-code 1             -level 0 -f ba snarf}
    a4 {-code 1     -code 1 -level 0 -f ba}       {-code 1 -code 1     -level 0 -f ba}
    a5 {-code 0     -code 1 -level 0 -f ba}       {-code 1             -level 0 -f ba}
    a6 {-code 1     -code 1 -level 5 -f ba}       {-code 1 -code 1     -level 0 -f ba}
    a7 {-code 0     -code 1 -level 5 -f ba}       {-code 1             -level 0 -f ba}
    a8 {-code error -code 1 -level 0 -f ba}       {-code error -code 1 -level 0 -f ba}
    a9 {-code ok    -code 1 -level 0 -f ba}       {-code 1             -level 0 -f ba}
    b0 {-code error -code 1 -level 5 -f ba}       {-code error -code 1 -level 0 -f ba}
    b1 {-code ok    -code 1 -level 5 -f ba}       {-code 1             -level 0 -f ba}
    b2 {-code boss  -code 1 -level 0 -f ba}       {-code 1             -level 0 -f ba}
    b3 {-code boss  -code 1 -level 5 -f ba}       {-code 1             -level 0 -f ba}
    b4 {-code 1     -code 1 -level X -f ba snarf} {-code 1 -code 1     -level 0 -f ba snarf}
    b5 {-code 0     -code 1 -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    b6 {-code error -code 1 -level X -f ba snarf} {-code error -code 1 -level 0 -f ba snarf}
    b7 {-code ok    -code 1 -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    b8 {-code boss  -code 1 -level X -f ba snarf} {-code 1             -level 0 -f ba snarf}
    b9 {-code 1     -code 1 -level X -f ba}       {-code 1 -code 1     -level 0 -f ba}
    c0 {-code 0     -code 1 -level X -f ba}       {-code 1             -level 0 -f ba}
    c1 {-code error -code 1 -level X -f ba}       {-code error -code 1 -level 0 -f ba}
    c2 {-code ok    -code 1 -level X -f ba}       {-code 1             -level 0 -f ba}
    c3 {-code boss  -code 1 -level X -f ba}       {-code 1             -level 0 -f ba}

    c4 {-code 1     -code 0 -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    c5 {-code 0     -code 0 -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    c6 {-code 1     -code 0 -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    c7 {-code 0     -code 0 -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    c8 {-code error -code 0 -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    c9 {-code ok    -code 0 -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    d0 {-code error -code 0 -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    d1 {-code ok    -code 0 -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    d2 {-code boss  -code 0 -level 0 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    d3 {-code boss  -code 0 -level 5 -f ba snarf} {-code 1 -level 0 -f ba snarf}
    d4 {-code 1     -code 0 -level 0 -f ba}       {-code 1 -level 0 -f ba}
    d5 {-code 0     -code 0 -level 0 -f ba}       {-code 1 -level 0 -f ba}
    d6 {-code 1     -code 0 -level 5 -f ba}       {-code 1 -level 0 -f ba}
    d7 {-code 0     -code 0 -level 5 -f ba}       {-code 1 -level 0 -f ba}
    d8 {-code error -code 0 -level 0 -f ba}       {-code 1 -level 0 -f ba}
    d9 {-code ok    -code 0 -level 0 -f ba}       {-code 1 -level 0 -f ba}
    e0 {-code error -code 0 -level 5 -f ba}       {-code 1 -level 0 -f ba}
    e1 {-code ok    -code 0 -level 5 -f ba}       {-code 1 -level 0 -f ba}
    e2 {-code boss  -code 0 -level 0 -f ba}       {-code 1 -level 0 -f ba}
    e3 {-code boss  -code 0 -level 5 -f ba}       {-code 1 -level 0 -f ba}
    e4 {-code 1     -code 0 -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    e5 {-code 0     -code 0 -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    e6 {-code error -code 0 -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    e7 {-code ok    -code 0 -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    e8 {-code boss  -code 0 -level X -f ba snarf} {-code 1 -level 0 -f ba snarf}
    e9 {-code 1     -code 0 -level X -f ba}       {-code 1 -level 0 -f ba}
    f0 {-code 0     -code 0 -level X -f ba}       {-code 1 -level 0 -f ba}
    f1 {-code error -code 0 -level X -f ba}       {-code 1 -level 0 -f ba}
    f2 {-code ok    -code 0 -level X -f ba}       {-code 1 -level 0 -f ba}
    f3 {-code boss  -code 0 -level X -f ba}       {-code 1 -level 0 -f ba}
} {
    test io-71.$n {Tcl_SetChannelError} {testchannel} {

	set f [makeFile {... dummy ...} cutsplice]
	set c [open $f r]

	set res [testchannel setchannelerror $c [lrange $msg 0 end]]
	close $c
	removeFile cutsplice

	set res
    } [lrange $expected 0 end]

    test io-72.$n {Tcl_SetChannelErrorInterp} {testchannel} {

	set f [makeFile {... dummy ...} cutsplice]
	set c [open $f r]

	set res [testchannel setchannelerrorinterp $c [lrange $msg 0 end]]
	close $c
	removeFile cutsplice

	set res
    } [lrange $expected 0 end]
}

# ### ### ### ######### ######### #########

# cleanup
foreach file [list fooBar longfile script output test1 pipe my_script foo \
	bar test2 test3 cat stdout kyrillic.txt utf8-fcopy.txt utf8-rp.txt] {
    removeFile $file
}
cleanupTests
}
namespace delete ::tcl::test::io
return

Changes to tests/ioCmd.test.


1
2
3
4
5
6
7
.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
568
569
570
571
572
573
574



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































575
576
577
578
579
580
581
582
583
584
585

# Commands covered: open, close, gets, read, puts, seek, tell, eof, flush,
#		    fblocked, fconfigure, open, channel, fcopy
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
................................................................................
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: ioCmd.test,v 1.21.2.1 2005/05/05 17:56:16 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}

testConstraint fcopy [llength [info commands fcopy]]
................................................................................
test iocmd-15.12 {Tcl_FcopyObjCmd} {fcopy} {
    list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg
} {1 {expected integer but got "foo"}}

close $rfile
close $wfile




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































# cleanup
foreach file [list test1 test2 test3 test4] {
    removeFile $file
}
# delay long enough for background processes to finish
after 500
foreach file [list test5] {
    removeFile $file
}
cleanupTests
return
>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











1
2
3
4
5
6
7
8
.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
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
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
# -*- tcl -*-
# Commands covered: open, close, gets, read, puts, seek, tell, eof, flush,
#		    fblocked, fconfigure, open, channel, fcopy
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
................................................................................
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: ioCmd.test,v 1.21.2.2 2005/08/25 15:46:53 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}

testConstraint fcopy [llength [info commands fcopy]]
................................................................................
test iocmd-15.12 {Tcl_FcopyObjCmd} {fcopy} {
    list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg
} {1 {expected integer but got "foo"}}

close $rfile
close $wfile

# ### ### ### ######### ######### #########
## Testing the reflected channel.

test iocmd-20.0 {chan, wrong#args} {
    catch {chan} msg
    set msg
} {wrong # args: should be "chan subcommand ?argument ...?"}

test iocmd-20.1 {chan, unknown method} {
    catch {chan foo} msg
    set msg
} {unknown or ambiguous subcommand "foo": must be blocked, close, configure, copy, create, eof, event, flush, gets, names, postevent, puts, read, seek, tell, or truncate}

# --- --- --- --------- --------- ---------
# chan create, and method "initalize"

test iocmd-21.0 {chan create, wrong#args, not enough} {
    catch {chan create} msg
    set msg
} {wrong # args: should be "chan create mode cmdprefix"}

test iocmd-21.1 {chan create, wrong#args, too many} {
    catch {chan create a b c} msg
    set msg
} {wrong # args: should be "chan create mode cmdprefix"}

test iocmd-21.2 {chan create, invalid r/w mode, empty} {
    proc foo {} {}
    catch {chan create {} foo} msg
    rename foo {}
    set msg
} {bad mode list: is empty}

test iocmd-21.3 {chan create, invalid r/w mode, bad string} {
    proc foo {} {}
    catch {chan create {c} foo} msg
    rename foo {}
    set msg
} {bad mode "c": must be read or write}

test iocmd-21.4 {chan create, bad handler, not a list} {
    catch {chan create {r w} "foo \{"} msg
    set msg
} {unmatched open brace in list}

test iocmd-21.5 {chan create, bad handler, not a command} {
    catch {chan create {r w} foo} msg
    set msg
} {Initialize failure: invalid command name "foo"}

test iocmd-21.6 {chan create, initialize failed, bad signature} {
    proc foo {} {}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: wrong # args: should be "foo"}

test iocmd-21.7 {chan create, initialize failed, bad signature} {
    proc foo {} {}
    catch {chan create {r w} ::foo} msg
    rename foo {}
    set msg
} {Initialize failure: wrong # args: should be "::foo"}

test iocmd-21.8 {chan create, initialize failed, bad result, not a list} {
    proc foo {args} {return "\{"}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: unmatched open brace in list}

test iocmd-21.9 {chan create, initialize failed, bad result, not a list} {
    proc foo {args} {return \{\{\}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: unmatched open brace in list}

test iocmd-21.10 {chan create, initialize failed, bad result, empty list} {
    proc foo {args} {}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: Not all required methods supported}

test iocmd-21.11 {chan create, initialize failed, bad result, bogus method name} {
    proc foo {args} {return 1}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: bad method "1": must be blocking, cget, cgetall, configure, finalize, initialize, read, seek, watch, or write}

test iocmd-21.12 {chan create, initialize failed, bad result, ambiguous method name} {
    proc foo {args} {return {a b c}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: ambiguous method "c": must be blocking, cget, cgetall, configure, finalize, initialize, read, seek, watch, or write}

test iocmd-21.13 {chan create, initialize failed, bad result, required methods missing} {
    proc foo {args} {return {initialize finalize}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: Not all required methods supported}

test iocmd-21.14 {chan create, initialize failed, bad result, mode/handler mismatch} {
    proc foo {args} {return {initialize finalize watch read}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: Writing not supported, but requested}

test iocmd-21.15 {chan create, initialize failed, bad result, mode/handler mismatch} {
    proc foo {args} {return {initialize finalize watch write}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: Reading not supported, but requested}

test iocmd-21.16 {chan create, initialize failed, bad result, cget(all) mismatch} {
    proc foo {args} {return {initialize finalize watch cget write read}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: 'cgetall' not supported, but should be, as 'cget' is}

test iocmd-21.17 {chan create, initialize failed, bad result, cget(all) mismatch} {
    proc foo {args} {return {initialize finalize watch cgetall read write}}
    catch {chan create {r w} foo} msg
    rename foo {}
    set msg
} {Initialize failure: 'cget' not supported, but should be, as 'cgetall' is}

test iocmd-21.18 {chan create, initialize ok, creates channel} -match glob -body {
    proc foo {args} {
	global  res
	lappend res $args
	if {[lindex $args 0] ne "initialize"} {return}
	return {initialize finalize watch read write}
    }
    set res {}
    lappend res [file channel rc*]
    lappend res [chan create {r w} foo]
    lappend res [close [lindex $res end]]
    lappend res [file channel rc*]
    rename foo {}
    set res
} -result {{} {initialize rc* {read write}} rc* {finalize rc*} {} {}}

test iocmd-21.19 {chan create, init failure -> no channel, no finalize} -match glob -body {
    proc foo {args} {
	global  res
	lappend res $args
	return {}
    }
    set res {}
    lappend res [file channel rc*]
    lappend res [catch {chan create {r w} foo} msg]
    lappend res $msg
    lappend res [file channel rc*]
    rename foo {}
    set res
} -result {{} {initialize rc* {read write}} 1 {Initialize failure: Not all required methods supported} {}}

# --- --- --- --------- --------- ---------
# Helper commands to record the arguments to handler methods.

proc note  {item}  {global res ; lappend res $item ; return}
proc track {}      {upvar args item ; note $item; return}
proc notes {items} {foreach i $items {note $i}}

# Helper command, canned result for 'initialize' method.
# Gets the optional methods as arguments. Use return features
# to post the result higher up.

proc init {args} {
    lappend args initialize finalize watch read write
    return -code return $args
}

proc oninit {args} {
    upvar args hargs
    if {[lindex $hargs 0] ne "initialize"} {return}
    lappend args initialize finalize watch read write
    return -code return $args
}

proc onfinal {} {
    upvar args hargs
    if {[lindex $hargs 0] ne "finalize"} {return}
    return -code return ""
}

# --- --- --- --------- --------- ---------
# method finalize

test iocmd-22.1 {chan finalize, handler destruction has no effect on channel} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit; return}
    note [set c [chan create {r w} foo]]

    rename foo {}

    note [file channels rc*]
    note [catch {close $c} msg] ; note $msg
    note [file channels rc*]

    set res
} -result {{initialize rc* {read write}} rc* rc* 1 {invalid command name "foo"} {}}

test iocmd-22.2 {chan finalize, for close} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return {}}
    note [set c [chan create {r w} foo]]

    close $c

    # Close deleted the channel.
    note [file channels rc*]

    # Channel destruction does not kill handler command!
    note [info command foo]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} {} foo}

test iocmd-22.3 {chan finalize, for close, error, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code error 5}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg] ; note $msg
    # Channel is gone despite error.
    note [file channels rc*]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 5 {}}

test iocmd-22.4 {chan finalize, for close, error, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; error FOO}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg] ; note $msg

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 FOO}

test iocmd-22.5 {chan finalize, for close, arbitrary result, ignored} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return SOMETHING}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg]; note $msg

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 0 {}}

test iocmd-22.6 {chan finalize, for close, break, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 3}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg] ; note $msg

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 {}}

test iocmd-22.7 {chan finalize, for close, continue, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 4}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg] ; note $msg

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 {}}

test iocmd-22.8 {chan finalize, for close, custom code, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 777 BANG}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg] ; note $msg

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 BANG}

test iocmd-22.9 {chan finalize, for close, ignore level, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -level 5 -code 777 BANG}
    note [set c [chan create {r w} foo]]

    note [catch {close $c} msg opt] ; note $msg ; note $opt

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

# --- === *** ###########################
# method read

test iocmd-23.1 {chan read, regular data return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return snarf
    }
    set c [chan create {r w} foo]

    note [read $c 10]
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}

test iocmd-23.2 {chan read, bad data return, to much} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return [string repeat snarf 1000]
    }
    set c [chan create {r w} foo]

    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 {read delivered more than requested}}

test iocmd-23.3 {chan read, for non-readable channel} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	note MUST_NOT_HAPPEN
    }
    set c [chan create {w} foo]

    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {1 {channel "rc*" wasn't opened for reading}}

test iocmd-23.4 {chan read, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]
    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!}

test iocmd-23.5 {chan read, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]
    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!}

test iocmd-23.6 {chan read, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]
    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!}

test iocmd-23.7 {chan read, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code 777 BOOM!
    }
    set c [chan create {r w} foo]
    note [catch {read $c 2} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!}

test iocmd-23.8 {chan read, level is squashed} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -level 55 -code 777 BOOM!
    }
    set c [chan create {r w} foo]
    note [catch {read $c 2} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM! {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BOOM!}}

# --- === *** ###########################
# method write

test iocmd-24.1 {chan write, regular write} -match glob -body {
    set res {}
    proc foo {args} {
	oninit; onfinal ; track
	set     written [string length [lindex $args 2]]
	note   $written
	return $written
    }
    set c [chan create {r w} foo]

    puts -nonewline $c snarf ; flush $c
    close $c

    rename foo {}
    set res
} -result {{write rc* snarf} 5}

test iocmd-24.2 {chan write, partial write is ok} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	set     written [string length [lindex $args 2]]
	if {$written > 10} {set written [expr {$written / 2}]}
	note   $written
	return $written
    }
    set c [chan create {r w} foo]

    puts -nonewline $c snarfsnarfsnarf ; flush $c
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 7 {write rc* arfsnarf} 8}

test iocmd-24.3 {chan write, failed write} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note -1 ; return -1}

    set c [chan create {r w} foo]
    puts -nonewline $c snarfsnarfsnarf ; flush $c
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} -1}

test iocmd-24.4 {chan write, non-writable channel} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {1 {channel "rc*" wasn't opened for writing}}

test iocmd-24.5 {chan write, bad result, more written than data} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return 10000}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarf ; flush $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarf} 1 {write wrote more than requested}}

test iocmd-24.6 {chan write, bad result, zero-length write} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return 0}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarf ; flush $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarf} 1 {write wrote more than requested}}

test iocmd-24.7 {chan write, failed write, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!}

test iocmd-24.8 {chan write, failed write, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; error BOOM!}
    set c [chan create {r w} foo]

    notes [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!}

test iocmd-24.9 {chan write, failed write, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!}

test iocmd-24.10 {chan write, failed write, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!}

test iocmd-24.11 {chan write, failed write, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code 777 BOOM!}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!}

test iocmd-24.12 {chan write, failed write, non-numeric return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return BANG}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
    note $msg
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 {expected integer but got "BANG"}}

test iocmd-24.13 {chan write, failed write, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -level 55 -code 777 BOOM!}
    set c [chan create {r w} foo]

    note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg opt]
    note $msg
    note $opt
    close $c

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM! {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BOOM!}}

# --- === *** ###########################
# method cgetall

test iocmd-25.1 {chan configure, cgetall, standard options} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c]
    close $c

    rename foo {}
    set res
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *}}}

test iocmd-25.2 {chan configure, cgetall, no options} -match glob -body {
    set res {}
    proc foo {args} {oninit cget cgetall ; onfinal ; track ; return ""}
    set c [chan create {r w} foo]

    note [fconfigure $c]
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *}}}

test iocmd-25.3 {chan configure, cgetall, regular result} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "-bar foo -snarf x"
    }
    set c [chan create {r w} foo]

    note [fconfigure $c]
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *} -bar foo -snarf x}}

test iocmd-25.4 {chan configure, cgetall, bad result, list of uneven length} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "-bar"
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 {Expected list with even number of elements, got 1 element instead}}

test iocmd-25.5 {chan configure, cgetall, bad result, not a list} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "\{"
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 {unmatched open brace in list}}

test iocmd-25.6 {chan configure, cgetall, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!}

test iocmd-25.7 {chan configure, cgetall, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!}

test iocmd-25.8 {chan configure, cgetall, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!}

test iocmd-25.9 {chan configure, cgetall, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code 777 BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!}

test iocmd-25.10 {chan configure, cgetall, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -level 55 -code 777 BANG
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

# --- === *** ###########################
# method configure

test iocmd-26.1 {chan configure, set standard option} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track ; note MUST_NOT_HAPPEN
	return
    }
    set c [chan create {r w} foo]

    note [fconfigure $c -translation lf]
    close $c

    rename foo {}
    set res
} -result {{}}

test iocmd-26.2 {chan configure, set option, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!}

test iocmd-26.3 {chan configure, set option, ok return} -match glob -body {
    set res {}
    proc foo {args} {oninit configure ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -rc-foo bar]
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} {}}

test iocmd-26.4 {chan configure, set option, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!}

test iocmd-26.5 {chan configure, set option, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!}

test iocmd-26.6 {chan configure, set option, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code 444 BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!}

test iocmd-26.7 {chan configure, set option, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -level 55 -code 444 BANG
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo bar} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

# --- === *** ###########################
# method cget

test iocmd-27.1 {chan configure, get option, ok return} -match glob -body {
    set res {}
    proc foo {args} {oninit cget cgetall ; onfinal ; track ; return foo}
    set c [chan create {r w} foo]

    note [fconfigure $c -rc-foo]
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} foo}

test iocmd-27.2 {chan configure, get option, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!}

test iocmd-27.3 {chan configure, get option, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!}

test iocmd-27.4 {chan configure, get option, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!}

test iocmd-27.5 {chan configure, get option, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code 333 BOOM!
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!}

test iocmd-27.6 {chan configure, get option, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -level 77 -code 333 BANG
    }
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -rc-foo} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

# --- === *** ###########################
# method seek

test iocmd-28.1 {chan tell, not supported by handler} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [tell $c]
    close $c

    rename foo {}
    set res
} -result {-1}

test iocmd-28.2 {chan tell, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!}

test iocmd-28.3 {chan tell, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!}

test iocmd-28.4 {chan tell, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!}

test iocmd-28.5 {chan tell, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code 222 BOOM!}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!}

test iocmd-28.6 {chan tell, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -level 11 -code 222 BANG}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

test iocmd-28.7 {chan tell, regular return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return 88}
    set c [chan create {r w} foo]

    note [tell $c]
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 88}

test iocmd-28.8 {chan tell, negative return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -1}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 {Tried to seek before origin}}

test iocmd-28.9 {chan tell, string return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    note [catch {tell $c} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 {expected integer but got "BOGUS"}}

test iocmd-28.10 {chan seek, not supported by handler} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {1 {error during seek on "rc*": invalid argument}}

test iocmd-28.11 {chan seek, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!}

test iocmd-28.12 {chan seek, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!}

test iocmd-28.13 {chan seek, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!}

test iocmd-28.14 {chan seek, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code 99 BOOM!}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!}

test iocmd-28.15 {chan seek, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -level 33 -code 99 BANG}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg opt] ; note $msg ; note $opt
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

test iocmd-28.16 {chan seek, bogus return, negative location} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -45}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 {Tried to seek before origin}}

test iocmd-28.17 {chan seek, bogus return, string return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    note [catch {seek $c 0 start} msg] ; note $msg
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 {expected integer but got "BOGUS"}}

test iocmd-28.18 {chan seek, ok result} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return 23}
    set c [chan create {r w} foo]

    note [seek $c 0 current]
    close $c

    rename foo {}
    set res
} -result {{seek rc* 0 current} {}}

foreach {n code} {
    0 start
    1 current
    2 end
} {
    test iocmd-28.19.$n "chan seek, base conversion, $code" -match glob -body {
	set res {}
	proc foo {args} {oninit seek ; onfinal ; track ; return 0}

	set c [chan create {r w} foo]
	note [seek $c 0 $code]
	close $c

	rename foo {}
	set res
    } -result [list [list seek rc* 0 $code] {}]
}

# --- === *** ###########################
# method blocking

test iocmd-29.1 {chan blocking, no handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -blocking]
    close $c

    rename foo {}
    set res
} -result {1}

test iocmd-29.2 {chan blocking, no handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -blocking 0]
    note [fconfigure $c -blocking]
    close $c

    rename foo {}
    set res
} -result {{} 0}

test iocmd-29.3 {chan blocking, retrieval, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -blocking]
    close $c

    rename foo {}
    set res
} -result {1}

test iocmd-29.4 {chan blocking, resetting, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -blocking 0]
    note [fconfigure $c -blocking]
    close $c

    rename foo {}
    set res
} -result {{blocking rc* 0} {} 0}

test iocmd-29.5 {chan blocking, setting, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fconfigure $c -blocking 1]
    note [fconfigure $c -blocking]
    close $c

    rename foo {}
    set res
} -result {{blocking rc* 1} {} 1}

test iocmd-29.6 {chan blocking, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; error BOOM!}

    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg] ; note $msg

    # Catch the close. It changes blocking mode internally, and runs into the error result.
    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!}

test iocmd-29.7 {chan blocking, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg] ; note $msg

    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!}

test iocmd-29.8 {chan blocking, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg] ; note $msg

    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!}

test iocmd-29.9 {chan blocking, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code 44 BOOM!}
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg] ; note $msg

    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!}

test iocmd-29.10 {chan blocking, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -level 99 -code 44 BANG}
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg opt] ; note $msg ; note $opt

    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}}

test iocmd-29.11 {chan blocking, regular return ok, value ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    note [catch {fconfigure $c -blocking 0} msg] ; note $msg

    catch {close $c}
    rename foo {}
    set res
} -result {{blocking rc* 0} 0 {}}

# --- === *** ###########################
# method watch

test iocmd-30.1 {chan watch, read interest, some return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return IGNORED}
    set c [chan create {r w} foo]

    note [fileevent $c readable {set tick $tick}]
    close $c     ;# 2nd watch, interest zero.

    rename foo {}
    set res
} -result {{watch rc* read} {} {watch rc* {}}}

test iocmd-30.2 {chan watch, write interest, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code error BOOM!_IGNORED}
    set c [chan create {r w} foo]

    note [fileevent $c writable {set tick $tick}]
    note [fileevent $c writable {}]
    close $c

    rename foo {}
    set res
} -result {{watch rc* write} {} {watch rc* {}} {}}

test iocmd-30.3 {chan watch, accumulated interests} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fileevent $c writable {set tick $tick}]
    note [fileevent $c readable {set tick $tick}]
    note [fileevent $c writable {}]
    note [fileevent $c readable {}]
    close $c

    rename foo {}
    set res
} -result {{watch rc* write} {} {watch rc* {read write}} {} {watch rc* read} {} {watch rc* {}} {}}

test iocmd-30.4 {chan watch, unchanged interest not forwarded} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fileevent $c writable {set tick $tick}]
    note [fileevent $c readable {set tick $tick}] ;# Script is changing,
    note [fileevent $c readable {set tock $tock}] ;# interest does not.

    close $c ;# 3rd and 4th watch, removing the event handlers.
    rename foo {}
    set res
} -result {{watch rc* write} {} {watch rc* {read write}} {} {} {watch rc* write} {watch rc* {}}}

# --- === *** ###########################
# chan postevent

test iocmd-31.1 {chan postevent, restricted to reflected channels} -match glob -body {
    set c [open [makeFile {} goo] r]

    catch {chan postevent $c {r w}} msg

    close $c
    removeFile goo
    set msg
} -result {channel "file*" is not a reflected channel}

test iocmd-31.2 {chan postevent, unwanted events} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    catch {chan postevent $c {r w}} msg ; note $msg
    close $c

    rename foo {}
    set res
} -result {{tried to post events channel "rc*" is not interested in}}

test iocmd-31.3 {chan postevent, bad input, empty list} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    catch {chan postevent $c {}} msg ; note $msg
    close $c

    rename foo {}
    set res
} -result {{bad event list: is empty}}

test iocmd-31.4 {chan postevent, bad input, illlegal keyword} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    catch {chan postevent $c goo} msg ; note $msg
    close $c

    rename foo {}
    set res
} -result {{bad event "goo": must be read or write}}

test iocmd-31.5 {chan postevent, bad input, not a list} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    catch {chan postevent $c "\{"} msg ; note $msg
    close $c

    rename foo {}
    set res
} -result {{unmatched open brace in list}}

test iocmd-31.6 {chan postevent, posted events do happen} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fileevent $c readable {note TOCK}]

    set stop [after 10000 {note TIMEOUT}]
    after  1000 {note [chan postevent $c r]}
    vwait ::res
    catch {after cancel $stop}
    close $c

    rename foo {}
    set res
} -result {{watch rc* read} {} TOCK {} {watch rc* {}}}

test iocmd-31.7 {chan postevent, posted events do happen} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    note [fileevent $c writable {note TOCK}]

    set stop [after 10000 {note TIMEOUT}]
    after  1000 {note [chan postevent $c w]}
    vwait ::res
    catch {after cancel $stop}
    close $c

    rename foo {}
    set res
} -result {{watch rc* write} {} TOCK {} {watch rc* {}}}

# ### ### ### ######### ######### #########
## Same tests as above, but exercising the code forwarding and
## receiving driver operations to the originator thread.

# -*- tcl -*-
# ### ### ### ######### ######### #########
## Testing the reflected channel (Thread forwarding).
#
## The id numbers refer to the original test without thread
## forwarding, and gaps due to tests not applicable to forwarding are
## left to keep this asociation.

testConstraint testchannel [llength [info commands testchannel]]

# Duplicate of code in "thread.test". Find a better way of doing this
# without duplication. Maybe placement into a proc which transforms to
# nop after the first call, and placement of its defintion in a
# central location.

testConstraint testthread [expr {[info commands testthread] != {}}]

if {[testConstraint testthread]} {
    testthread errorproc ThreadError

    proc ThreadError {id info} {
	global threadError
	set threadError $info
    }

    proc ThreadNullError {id info} {
	# ignore
    }
}

# ### ### ### ######### ######### #########
## Helper command. Runs a script in a separate thread and returns the
## result. A channel is transfered into the thread as well, and list of
## configuation variables

proc inthread {chan script args} {

    # Test thread.

    set tid [testthread create]

    # Init thread configuration.
    # - Listed variables
    # - Id of main thread
    # - A number of helper commands

    foreach v $args {
	upvar 1 $v x
	testthread send $tid [list set $v $x]
    }
    testthread send $tid [list set mid $tcltest::mainThread]
    testthread send $tid {
	proc note {item} {global notes ; lappend notes $item}
	proc notes {} {global notes ; return $notes}
    }
    testthread send $tid [list proc s {} [list uplevel 1 $script]] ; # (*)

    # Transfer channel (cut/splice aka detach/attach)

    testchannel cut $chan
    testthread send $tid [list testchannel splice $chan]

    # Run test script, also run local event loop!
    # The local event loop waits for the result to come back.
    # It is also necessary for the execution of forwarded channel
    # operations.

    set ::tres ""
    testthread send -async $tid {
	after 500
	catch {s} res ; # This runs the script, 's' was defined at (*)
	testthread send -async $mid [list set ::tres $res]
    }
    vwait ::tres
    # Remove test thread, and return the captured result.

    tcltest::threadReap
    return $::tres
}

# ### ### ### ######### ######### #########

# ### ### ### ######### ######### #########

test iocmd.tf-22.2 {chan finalize, for close} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return {}}
    note [set c [chan create {r w} foo]]

    note [inthread $c {
	close $c
	# Close the deleted the channel.
	file channels rc*
    } c]

    # Channel destruction does not kill handler command!
    note [info command foo]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{initialize rc* {read write}} rc* {finalize rc*} {} foo}

test iocmd.tf-22.3 {chan finalize, for close, error, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code error 5}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg] ; note $msg
	# Channel is gone despite error.
	note [file channels rc*]
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 5 {}}

test iocmd.tf-22.4 {chan finalize, for close, error, close errror} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; error FOO}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg] ; note $msg
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 FOO}

test iocmd.tf-22.5 {chan finalize, for close, arbitrary result} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return SOMETHING}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg]; note $msg
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{initialize rc* {read write}} rc* {finalize rc*} 0 {}}

test iocmd.tf-22.6 {chan finalize, for close, break, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 3}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg] ; note $msg
	notes
    } c]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 {}} \
    -constraints {testchannel testthread}

test iocmd.tf-22.7 {chan finalize, for close, continue, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 4}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg] ; note $msg
	notes
    } c]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 {}} \
    -constraints {testchannel testthread}

test iocmd.tf-22.8 {chan finalize, for close, custom code, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -code 777 BANG}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg] ; note $msg
	notes
    } c]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 BANG} \
    -constraints {testchannel testthread}

test iocmd.tf-22.9 {chan finalize, for close, ignore level, close error} -match glob -body {
    set res {}
    proc foo {args} {track ; oninit ; return -level 5 -code 777 BANG}
    note [set c [chan create {r w} foo]]

    notes [inthread $c {
	note [catch {close $c} msg opt] ; note $msg ; note $opt
	notes
    } c]

    rename foo {}
    set res
} -result {{initialize rc* {read write}} rc* {finalize rc*} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method read

test iocmd.tf-23.1 {chan read, regular data return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return snarf
    }
    set c [chan create {r w} foo]
    notes [inthread $c {
	note [read $c 10]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}

test iocmd.tf-23.2 {chan read, bad data return, to much} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return [string repeat snarf 1000]
    }
    set c [chan create {r w} foo]
    notes [inthread $c {
	note [catch {[read $c 2]} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{read rc* 4096} 1 {read delivered more than requested}}

test iocmd.tf-23.3 {chan read, for non-readable channel} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	note MUST_NOT_HAPPEN
    }
    set c [chan create {w} foo]
    notes [inthread $c {
	note [catch {[read $c 2]} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {1 {channel "rc*" wasn't opened for reading}}

test iocmd.tf-23.4 {chan read, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {read $c 2} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-23.5 {chan read, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {read $c 2} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-23.6 {chan read, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {read $c 2} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-23.7 {chan read, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -code 777 BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {read $c 2} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-23.8 {chan read, level is squashed} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	return -level 55 -code 777 BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {read $c 2} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{read rc* 4096} 1 BOOM! {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BOOM!}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method write

test iocmd.tf-24.1 {chan write, regular write} -match glob -body {
    set res {}
    proc foo {args} {
	oninit; onfinal ; track
	set     written [string length [lindex $args 2]]
	note   $written
	return $written
    }
    set c [chan create {r w} foo]

    inthread $c {
	puts -nonewline $c snarf ; flush $c
	close $c
    } c

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{write rc* snarf} 5}

test iocmd.tf-24.2 {chan write, ack partial writes} -match glob -body {
    set res {}
    proc foo {args} {
	oninit ; onfinal ; track
	set     written [string length [lindex $args 2]]
	if {$written > 10} {set written [expr {$written / 2}]}
	note   $written
	return $written
    }
    set c [chan create {r w} foo]

    inthread $c {
	puts -nonewline $c snarfsnarfsnarf ; flush $c
	close $c
    } c

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{write rc* snarfsnarfsnarf} 7 {write rc* arfsnarf} 8}

test iocmd.tf-24.3 {chan write, failed write} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note -1 ; return -1}
    set c [chan create {r w} foo]

    inthread $c {
	puts -nonewline $c snarfsnarfsnarf ; flush $c
	close $c
    } c

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{write rc* snarfsnarfsnarf} -1}

test iocmd.tf-24.4 {chan write, non-writable channel} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {1 {channel "rc*" wasn't opened for writing}}

test iocmd.tf-24.5 {chan write, bad result, more written than data} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ;  return 10000}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarf ; flush $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{write rc* snarf} 1 {write wrote more than requested}}

test iocmd.tf-24.6 {chan write, zero writes} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return 0}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarf ; flush $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{write rc* snarf} 1 {write wrote more than requested}}

test iocmd.tf-24.7 {chan write, failed write, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-24.8 {chan write, failed write, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; error BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-24.9 {chan write, failed write, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-24.10 {chan write, failed write, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-24.11 {chan write, failed write, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code 777 BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-24.12 {chan write, failed write, non-numeric return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return BANG}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg]
	note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 {expected integer but got "BANG"}} \
    -constraints {testchannel testthread}

test iocmd.tf-24.13 {chan write, failed write, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -level 55 -code 777 BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {puts -nonewline $c snarfsnarfsnarf ; flush $c} msg opt]
	note $msg
	note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{write rc* snarfsnarfsnarf} 1 BOOM! {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BOOM!}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method cgetall

test iocmd.tf-25.1 {chan configure, cgetall, standard options} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *}}}

test iocmd.tf-25.2 {chan configure, cgetall, no options} -match glob -body {
    set res {}
    proc foo {args} {oninit cget cgetall ; onfinal ; track ; return ""}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *}}}

test iocmd.tf-25.3 {chan configure, cgetall, regular result} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "-bar foo -snarf x"
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -translation {auto *} -bar foo -snarf x}}

test iocmd.tf-25.4 {chan configure, cgetall, bad result, list of uneven length} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "-bar"
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{cgetall rc*} 1 {Expected list with even number of elements, got 1 element instead}}

test iocmd.tf-25.5 {chan configure, cgetall, bad result, not a list} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return "\{"
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{cgetall rc*} 1 {unmatched open brace in list}}

test iocmd.tf-25.6 {chan configure, cgetall, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{cgetall rc*} 1 BOOM!}

test iocmd.tf-25.7 {chan configure, cgetall, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-25.8 {chan configure, cgetall, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-25.9 {chan configure, cgetall, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code 777 BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-25.10 {chan configure, cgetall, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -level 55 -code 777 BANG
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cgetall rc*} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method configure

test iocmd.tf-26.1 {chan configure, set standard option} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track ; note MUST_NOT_HAPPEN
	return
    }

    set c [chan create {r w} foo]
    notes [inthread $c {
	note [fconfigure $c -translation lf]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{}}

test iocmd.tf-26.2 {chan configure, set option, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{configure rc* -rc-foo bar} 1 BOOM!}

test iocmd.tf-26.3 {chan configure, set option, ok return} -match glob -body {
    set res {}
    proc foo {args} {oninit configure ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -rc-foo bar]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{configure rc* -rc-foo bar} {}}

test iocmd.tf-26.4 {chan configure, set option, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code break BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-26.5 {chan configure, set option, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-26.6 {chan configure, set option, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -code 444 BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo bar} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-26.7 {chan configure, set option, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit configure ; onfinal ; track
	return -level 55 -code 444 BANG
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo bar} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{configure rc* -rc-foo bar} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method cget

test iocmd.tf-27.1 {chan configure, get option, ok return} -match glob -body {
    set res {}
    proc foo {args} {oninit cget cgetall ; onfinal ; track ; return foo}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -rc-foo]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{cget rc* -rc-foo} foo}

test iocmd.tf-27.2 {chan configure, get option, error return} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{cget rc* -rc-foo} 1 BOOM!}

test iocmd.tf-27.3 {chan configure, get option, break return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code error BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-27.4 {chan configure, get option, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code continue BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-27.5 {chan configure, get option, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -code 333 BOOM!
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-27.6 {chan configure, get option, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {
	oninit cget cgetall ; onfinal ; track
	return -level 77 -code 333 BANG
    }
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -rc-foo} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{cget rc* -rc-foo} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method seek

test iocmd.tf-28.1 {chan tell, not supported by handler} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [tell $c]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {-1} \
    -constraints {testchannel testthread}

test iocmd.tf-28.2 {chan tell, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.3 {chan tell, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.4 {chan tell, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.5 {chan tell, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code 222 BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.6 {chan tell, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -level 11 -code 222 BANG}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.7 {chan tell, regular return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return 88}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [tell $c]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 88} \
    -constraints {testchannel testthread}

test iocmd.tf-28.8 {chan tell, negative return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -1}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 {Tried to seek before origin}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.9 {chan tell, string return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {tell $c} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} 1 {expected integer but got "BOGUS"}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.10 {chan seek, not supported by handler} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {1 {error during seek on "rc*": invalid argument}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.11 {chan seek, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code error BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.12 {chan seek, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.13 {chan seek, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.14 {chan seek, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -code 99 BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-28.15 {chan seek, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -level 33 -code 99 BANG}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg opt] ; note $msg ; note $opt
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.16 {chan seek, bogus return, negative location} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return -45}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 {Tried to seek before origin}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.17 {chan seek, bogus return, string return} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {seek $c 0 start} msg] ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 start} 1 {expected integer but got "BOGUS"}} \
    -constraints {testchannel testthread}

test iocmd.tf-28.18 {chan seek, ok result} -match glob -body {
    set res {}
    proc foo {args} {oninit seek ; onfinal ; track ; return 23}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [seek $c 0 current]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{seek rc* 0 current} {}} \
    -constraints {testchannel testthread}

foreach {n code} {
    0 start
    1 current
    2 end
} {
    test iocmd.tf-28.19.$n "chan seek, base conversion, $code" -match glob -body {
	set res {}
	proc foo {args} {oninit seek ; onfinal ; track ; return 0}
	set c [chan create {r w} foo]

	notes [inthread $c {
	    note [seek $c 0 $code]
	    close $c
	    notes
	} c code]

	rename foo {}
	set res
    } -result [list [list seek rc* 0 $code] {}] \
	-constraints {testchannel testthread}
}

# --- === *** ###########################
# method blocking

test iocmd.tf-29.1 {chan blocking, no handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -blocking]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {1} \
    -constraints {testchannel testthread}

test iocmd.tf-29.2 {chan blocking, no handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -blocking 0]
	note [fconfigure $c -blocking]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{} 0} \
    -constraints {testchannel testthread}

test iocmd.tf-29.3 {chan blocking, retrieval, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; note MUST_NOT_HAPPEN ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -blocking]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {1} \
    -constraints {testchannel testthread}

test iocmd.tf-29.4 {chan blocking, resetting, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -blocking 0]
	note [fconfigure $c -blocking]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} {} 0} \
    -constraints {testchannel testthread}

test iocmd.tf-29.5 {chan blocking, setting, handler support} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fconfigure $c -blocking 1]
	note [fconfigure $c -blocking]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 1} {} 1} \
    -constraints {testchannel testthread}

test iocmd.tf-29.6 {chan blocking, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; error BOOM!}

    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg] ; note $msg
	# Catch the close. It changes blocking mode internally, and runs into the error result.
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-29.7 {chan blocking, break return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code break BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg] ; note $msg
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-29.8 {chan blocking, continue return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code continue BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg] ; note $msg
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-29.9 {chan blocking, custom return is error} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -code 44 BOOM!}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg] ; note $msg
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BOOM!} \
    -constraints {testchannel testthread}

test iocmd.tf-29.10 {chan blocking, level is ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return -level 99 -code 44 BANG}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg opt] ; note $msg ; note $opt
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 1 BANG {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo BANG}} \
    -constraints {testchannel testthread}

test iocmd.tf-29.11 {chan blocking, regular return ok, value ignored} -match glob -body {
    set res {}
    proc foo {args} {oninit blocking ; onfinal ; track ; return BOGUS}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [catch {fconfigure $c -blocking 0} msg] ; note $msg
	catch {close $c}
	notes
    } c]

    rename foo {}
    set res
} -result {{blocking rc* 0} 0 {}} \
    -constraints {testchannel testthread}

# --- === *** ###########################
# method watch

test iocmd.tf-30.1 {chan watch, read interest, some return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return IGNORED}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fileevent $c readable {set tick $tick}]
	close $c     ;# 2nd watch, interest zero.
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{watch rc* read} {watch rc* {}} {}}

test iocmd.tf-30.2 {chan watch, write interest, error return} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return -code error BOOM!_IGNORED}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fileevent $c writable {set tick $tick}]
	note [fileevent $c writable {}]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} -result {{watch rc* write} {watch rc* {}} {} {}}

test iocmd.tf-30.3 {chan watch, accumulated interests} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fileevent $c writable {set tick $tick}]
	note [fileevent $c readable {set tick $tick}]
	note [fileevent $c writable {}]
	note [fileevent $c readable {}]
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{watch rc* write} {watch rc* {read write}} {watch rc* read} {watch rc* {}} {} {} {} {}}

test iocmd.tf-30.4 {chan watch, unchanged interest not forwarded} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	note [fileevent $c writable {set tick $tick}]
	note [fileevent $c readable {set tick $tick}] ;# Script is changing,
	note [fileevent $c readable {set tock $tock}] ;# interest does not.
	close $c ;# 3rd and 4th watch, removing the event handlers.
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{watch rc* write} {watch rc* {read write}} {watch rc* write} {watch rc* {}} {} {} {}}

# --- === *** ###########################
# postevent
# Not possible from a thread not containing the command handler.
# Check that this is rejected.

test iocmd.tf-31.8 {chan postevent, bad input} -match glob -body {
    set res {}
    proc foo {args} {oninit ; onfinal ; track ; return}
    set c [chan create {r w} foo]

    notes [inthread $c {
	catch {chan postevent $c r} msg ; note $msg
	close $c
	notes
    } c]

    rename foo {}
    set res
} -constraints {testchannel testthread} \
    -result {{postevent for channel "rc*" called from outside interpreter}}


# ### ### ### ######### ######### #########

# ### ### ### ######### ######### #########

rename track {}
# cleanup
foreach file [list test1 test2 test3 test4] {
    removeFile $file
}
# delay long enough for background processes to finish
after 500
foreach file [list test5] {
    removeFile $file
}
cleanupTests
return

Changes to unix/Makefile.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
386
387
388
389
390
391
392

393
394
395
396
397
398
399
....
1016
1017
1018
1019
1020
1021
1022



1023
1024
1025
1026
1027
1028
1029
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.157.2.15 2005/08/16 16:55:18 dgp Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#----------------------------------------------------------------
................................................................................

GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
	tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o \
	tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompExpr.o \
	tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclEncoding.o \
	tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o \
	tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o \
	tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o \
	tclLiteral.o tclLoad.o tclMain.o tclNamesp.o tclNotify.o \
	tclObj.o tclPanic.o tclParse.o tclParseExpr.o tclPathObj.o tclPipe.o \
	tclPkg.o tclPkgConfig.o tclPosixStr.o \
	tclPreserve.o tclProc.o tclRegexp.o \
	tclResolve.o tclResult.o tclScan.o tclStringObj.o \
	tclStrToD.o tclThread.o \
	tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o \
................................................................................
	$(GENERIC_DIR)/tclIndexObj.c \
	$(GENERIC_DIR)/tclInterp.c \
	$(GENERIC_DIR)/tclIO.c \
	$(GENERIC_DIR)/tclIOCmd.c \
	$(GENERIC_DIR)/tclIOGT.c \
	$(GENERIC_DIR)/tclIOSock.c \
	$(GENERIC_DIR)/tclIOUtil.c \

	$(GENERIC_DIR)/tclLink.c \
	$(GENERIC_DIR)/tclListObj.c \
	$(GENERIC_DIR)/tclLiteral.c \
	$(GENERIC_DIR)/tclLoad.c \
	$(GENERIC_DIR)/tclMain.c \
	$(GENERIC_DIR)/tclNamesp.c \
	$(GENERIC_DIR)/tclNotify.c \
................................................................................

tclIOSock.o: $(GENERIC_DIR)/tclIOSock.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclIOSock.c

tclIOUtil.o: $(GENERIC_DIR)/tclIOUtil.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclIOUtil.c




tclLink.o: $(GENERIC_DIR)/tclLink.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLink.c

tclListObj.o: $(GENERIC_DIR)/tclListObj.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclListObj.c

tclLiteral.o: $(GENERIC_DIR)/tclLiteral.c







|







 







|







 







>







 







>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
....
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.157.2.16 2005/08/25 15:47:07 dgp Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#----------------------------------------------------------------
................................................................................

GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
	tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o \
	tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompExpr.o \
	tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclEncoding.o \
	tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o \
	tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o \
	tclIORChan.o tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o \
	tclLiteral.o tclLoad.o tclMain.o tclNamesp.o tclNotify.o \
	tclObj.o tclPanic.o tclParse.o tclParseExpr.o tclPathObj.o tclPipe.o \
	tclPkg.o tclPkgConfig.o tclPosixStr.o \
	tclPreserve.o tclProc.o tclRegexp.o \
	tclResolve.o tclResult.o tclScan.o tclStringObj.o \
	tclStrToD.o tclThread.o \
	tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o \
................................................................................
	$(GENERIC_DIR)/tclIndexObj.c \
	$(GENERIC_DIR)/tclInterp.c \
	$(GENERIC_DIR)/tclIO.c \
	$(GENERIC_DIR)/tclIOCmd.c \
	$(GENERIC_DIR)/tclIOGT.c \
	$(GENERIC_DIR)/tclIOSock.c \
	$(GENERIC_DIR)/tclIOUtil.c \
	$(GENERIC_DIR)/tclIORChan.c \
	$(GENERIC_DIR)/tclLink.c \
	$(GENERIC_DIR)/tclListObj.c \
	$(GENERIC_DIR)/tclLiteral.c \
	$(GENERIC_DIR)/tclLoad.c \
	$(GENERIC_DIR)/tclMain.c \
	$(GENERIC_DIR)/tclNamesp.c \
	$(GENERIC_DIR)/tclNotify.c \
................................................................................

tclIOSock.o: $(GENERIC_DIR)/tclIOSock.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclIOSock.c

tclIOUtil.o: $(GENERIC_DIR)/tclIOUtil.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclIOUtil.c

tclIORChan.o: $(GENERIC_DIR)/tclIORChan.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclIORChan.c

tclLink.o: $(GENERIC_DIR)/tclLink.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLink.c

tclListObj.o: $(GENERIC_DIR)/tclListObj.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclListObj.c

tclLiteral.o: $(GENERIC_DIR)/tclLiteral.c

Changes to unix/configure.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/bash -norc
dnl	This file is an input file used by the GNU "autoconf" program to
dnl	generate the file "configure", which is run during Tcl installation
dnl	to configure the system for the local environment.
#
# RCS: @(#) $Id: configure.in,v 1.123.2.7 2005/08/02 18:16:53 dgp Exp $

AC_INIT([tcl],[8.5])
AC_PREREQ(2.57)

dnl AC_CONFIG_HEADERS([tclConfig.h])
dnl AC_CONFIG_COMMANDS_PRE([DEFS="-DHAVE_TCL_CONFIG_H  -imacros tclConfig.h"])
dnl AH_TOP([#ifndef _TCLCONFIG
dnl #define _TCLCONFIG])
dnl AH_BOTTOM([#endif /* _TCLCONFIG */])






|


|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/bash -norc
dnl	This file is an input file used by the GNU "autoconf" program to
dnl	generate the file "configure", which is run during Tcl installation
dnl	to configure the system for the local environment.
#
# RCS: @(#) $Id: configure.in,v 1.123.2.8 2005/08/25 15:47:07 dgp Exp $

AC_INIT([tcl],[8.5])
AC_PREREQ(2.59)

dnl AC_CONFIG_HEADERS([tclConfig.h])
dnl AC_CONFIG_COMMANDS_PRE([DEFS="-DHAVE_TCL_CONFIG_H  -imacros tclConfig.h"])
dnl AH_TOP([#ifndef _TCLCONFIG
dnl #define _TCLCONFIG])
dnl AH_BOTTOM([#endif /* _TCLCONFIG */])

Changes to unix/tclConfig.h.in.

308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME

/* Is getcwd Posix-compliant? */
#undef USEGETWD

/* Should we use <a.out.h> when doing dynamic loading? */
#undef USE_A_OUT_H

/* Do we need a special AIX hack for timezones? */
#undef USE_DELTA_FOR_TZ

/* May we include <dirent2.h>? */
#undef USE_DIRENT2_H

/* Should we use FIONBIO? */
#undef USE_FIONBIO

/* Use the sgtty API for serial lines */
#undef USE_SGTTY

/* Should we use <sys/exec_aout.h> when doing dynamic loading? */
#undef USE_SYS_EXEC_AOUT_H

/* Should we use <sys/exec.h> when doing dynamic loading? */
#undef USE_SYS_EXEC_H

/* Use the termio API for serial lines */
#undef USE_TERMIO

/* Use the termios API for serial lines */
#undef USE_TERMIOS

/* Do we want to use the threaded memory allocator? */







<
<
<












<
<
<
<
<
<







308
309
310
311
312
313
314



315
316
317
318
319
320
321
322
323
324
325
326






327
328
329
330
331
332
333

/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME

/* Is getcwd Posix-compliant? */
#undef USEGETWD




/* Do we need a special AIX hack for timezones? */
#undef USE_DELTA_FOR_TZ

/* May we include <dirent2.h>? */
#undef USE_DIRENT2_H

/* Should we use FIONBIO? */
#undef USE_FIONBIO

/* Use the sgtty API for serial lines */
#undef USE_SGTTY







/* Use the termio API for serial lines */
#undef USE_TERMIO

/* Use the termios API for serial lines */
#undef USE_TERMIOS

/* Do we want to use the threaded memory allocator? */

Changes to win/Makefile.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
238
239
240
241
242
243
244

245
246
247
248
249
250
251
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.84.2.11 2005/08/16 16:55:18 dgp Exp $

VERSION = @TCL_VERSION@

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
................................................................................
	tclHash.$(OBJEXT) \
	tclHistory.$(OBJEXT) \
	tclIndexObj.$(OBJEXT) \
	tclInterp.$(OBJEXT) \
	tclIO.$(OBJEXT) \
	tclIOCmd.$(OBJEXT) \
	tclIOGT.$(OBJEXT) \

	tclIOSock.$(OBJEXT) \
	tclIOUtil.$(OBJEXT) \
	tclLink.$(OBJEXT) \
	tclLiteral.$(OBJEXT) \
	tclListObj.$(OBJEXT) \
	tclLoad.$(OBJEXT) \
	tclMain.$(OBJEXT) \







|







 







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.84.2.12 2005/08/25 15:47:07 dgp Exp $

VERSION = @TCL_VERSION@

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
................................................................................
	tclHash.$(OBJEXT) \
	tclHistory.$(OBJEXT) \
	tclIndexObj.$(OBJEXT) \
	tclInterp.$(OBJEXT) \
	tclIO.$(OBJEXT) \
	tclIOCmd.$(OBJEXT) \
	tclIOGT.$(OBJEXT) \
	tclIORChan.$(OBJEXT) \
	tclIOSock.$(OBJEXT) \
	tclIOUtil.$(OBJEXT) \
	tclLink.$(OBJEXT) \
	tclLiteral.$(OBJEXT) \
	tclListObj.$(OBJEXT) \
	tclLoad.$(OBJEXT) \
	tclMain.$(OBJEXT) \

Changes to win/configure.

3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148

	# USE_THREAD_ALLOC tells us to try the special thread-based
	# allocator that significantly reduces lock contention
	cat >>confdefs.h <<\_ACEOF
#define USE_THREAD_ALLOC 1
_ACEOF

	# USE_THREAD_STORAGE tells us to use the new generic thread
	# storage subsystem.
	cat >>confdefs.h <<\_ACEOF
#define USE_THREAD_STORAGE 1
_ACEOF

    else
	TCL_THREADS=0
	echo "$as_me:$LINENO: result: no (default)" >&5
echo "${ECHO_T}no (default)" >&6
    fi









<
<
<
<
<
<







3129
3130
3131
3132
3133
3134
3135






3136
3137
3138
3139
3140
3141
3142

	# USE_THREAD_ALLOC tells us to try the special thread-based
	# allocator that significantly reduces lock contention
	cat >>confdefs.h <<\_ACEOF
#define USE_THREAD_ALLOC 1
_ACEOF







    else
	TCL_THREADS=0
	echo "$as_me:$LINENO: result: no (default)" >&5
echo "${ECHO_T}no (default)" >&6
    fi


Changes to win/configure.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/bash -norc
# This file is an input file used by the GNU "autoconf" program to
# generate the file "configure", which is run during Tcl installation
# to configure the system for the local environment.
#
# RCS: @(#) $Id: configure.in,v 1.81.2.4 2005/07/12 20:37:32 kennykb Exp $

AC_INIT(../generic/tcl.h)
AC_PREREQ(2.57)

# The following define is needed when building with Cygwin since newer
# versions of autoconf incorrectly set SHELL to /bin/bash instead of
# /bin/sh. The bash shell seems to suffer from some strange failures.
SHELL=/bin/sh

TCL_VERSION=8.5





|


|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/bash -norc
# This file is an input file used by the GNU "autoconf" program to
# generate the file "configure", which is run during Tcl installation
# to configure the system for the local environment.
#
# RCS: @(#) $Id: configure.in,v 1.81.2.5 2005/08/25 15:47:07 dgp Exp $

AC_INIT(../generic/tcl.h)
AC_PREREQ(2.59)

# The following define is needed when building with Cygwin since newer
# versions of autoconf incorrectly set SHELL to /bin/bash instead of
# /bin/sh. The bash shell seems to suffer from some strange failures.
SHELL=/bin/sh

TCL_VERSION=8.5

Changes to win/makefile.vc.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
280
281
282
283
284
285
286

287
288
289
290
291
292
293
# 
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 Ajuba Solutions.
# Copyright (c) 2001-2005 ActiveState Corporation.
# Copyright (c) 2001-2004 David Gravereaux.
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: makefile.vc,v 1.135.2.7 2005/08/16 16:55:18 dgp Exp $
#------------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK)
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK)
MSG = ^
You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
................................................................................
	$(TMP_DIR)\tclIndexObj.obj \
	$(TMP_DIR)\tclInterp.obj \
	$(TMP_DIR)\tclIO.obj \
	$(TMP_DIR)\tclIOCmd.obj \
	$(TMP_DIR)\tclIOGT.obj \
	$(TMP_DIR)\tclIOSock.obj \
	$(TMP_DIR)\tclIOUtil.obj \

	$(TMP_DIR)\tclLink.obj \
	$(TMP_DIR)\tclListObj.obj \
	$(TMP_DIR)\tclLiteral.obj \
	$(TMP_DIR)\tclLoad.obj \
	$(TMP_DIR)\tclMain.obj \
	$(TMP_DIR)\tclNamesp.obj \
	$(TMP_DIR)\tclNotify.obj \







|







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# 
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 Ajuba Solutions.
# Copyright (c) 2001-2005 ActiveState Corporation.
# Copyright (c) 2001-2004 David Gravereaux.
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: makefile.vc,v 1.135.2.8 2005/08/25 15:47:07 dgp Exp $
#------------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK)
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK)
MSG = ^
You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
................................................................................
	$(TMP_DIR)\tclIndexObj.obj \
	$(TMP_DIR)\tclInterp.obj \
	$(TMP_DIR)\tclIO.obj \
	$(TMP_DIR)\tclIOCmd.obj \
	$(TMP_DIR)\tclIOGT.obj \
	$(TMP_DIR)\tclIOSock.obj \
	$(TMP_DIR)\tclIOUtil.obj \
	$(TMP_DIR)\tclIORChan.obj \
	$(TMP_DIR)\tclLink.obj \
	$(TMP_DIR)\tclListObj.obj \
	$(TMP_DIR)\tclLiteral.obj \
	$(TMP_DIR)\tclLoad.obj \
	$(TMP_DIR)\tclMain.obj \
	$(TMP_DIR)\tclNamesp.obj \
	$(TMP_DIR)\tclNotify.obj \