Check-in [faf6373107]
Not logged in

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

Overview
Comment:merge updates from HEAD
Timelines: family | ancestors | descendants | both | dgp-refactor
Files: files | file ages | folders
SHA1: faf63731077927723c4debb11ffa1b9766dcdc76
User & Date: dgp 2009-04-10 18:09:29.000
Context
2009-04-10
21:15
merge updates from HEAD check-in: fd08f75512 user: dgp tags: dgp-refactor
18:09
merge updates from HEAD check-in: faf6373107 user: dgp tags: dgp-refactor
2009-04-07
18:46
merge updates from HEAD check-in: 8cc32f55f3 user: dgp tags: dgp-refactor
Changes
Unified Diff Ignore Whitespace Patch
Changes to ChangeLog.


































































1
2
3
4

5
6
7
8
9
10
11


































































2009-04-07  Don Porter  <dgp@users.sourceforge.net>

	* generic/tclStringObj.c:	Correction so that value of
	TCL_GROWTH_MIN_ALLOC is everywhere expressed in bytes as comment claims.


2009-04-04  Donal K. Fellows  <dkf@users.sf.net>

	* doc/vwait.n: [Bug 1910136]: Extend description and examples to make
	it clearer just how this command interprets variable names.

2009-03-30  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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
2008-04-10  Daniel Steffen  <das@users.sourceforge.net>

	* macosx/tclMacOSXNotify.c:	revise CoreFoundation notifier to allow
					embedding into applications that
					already have a CFRunLoop running and
					want to run the tcl event loop via
					Tcl_ServiceModeHook(TCL_SERVICE_ALL).

	* macosx/tclMacOSXNotify.c:	add CFRunLoop based Tcl_Sleep() and 
	* unix/tclUnixChan.c:		TclUnixWaitForFile() implementations
	* unix/tclUnixEvent.c:		and disable select() based ones in
					CoreFoundation builds.

	* unix/tclUnixNotify.c:		simplify, sync with tclMacOSXNotify.c.

	* generic/tclInt.decls: 	add TclMacOSXNotifierAddRunLoopMode()
	* generic/tclIntPlatDecls.h:	internal API, regen.
	* generic/tclStubInit.c:

	* unix/configure.in (Darwin):	use Darwin SUSv3 extensions if
					available; remove /Network locations
					from default tcl package search path
					(NFS mounted locations and thus slow).
	* unix/configure:		autoconf-2.59
	* unix/tclConfig.h.in:		autoheader-2.59

	* macosx/tclMacOSXBundle.c:	on Mac OS X 10.4 and later, replace
					deprecated NSModule API by dlfcn API.

2009-04-10  Donal K. Fellows  <dkf@users.sf.net>

	* doc/StringObj.3: [Bug 2089279]: Corrected example so that it works
	on 64-bit machines as well.

2009-04-10  Pat Thoyts  <patthoyts@users.sourceforge.net>

	* tests/http.test: [Bug 26245326]: Added specific check for problem
	* tests/httpd: (return incomplete HTTP response header).

2009-04-08  Kevin B. Kenny <kennykb@acm.org>

	* tools/tclZIC.tcl: Always emit files with Unix line termination.
	* library/tzdata: Olson's tzdata2009e
	
2009-04-09  Don Porter  <dgp@users.sourceforge.net>

	* library/http/http.tcl:	[Bug 26245326]: Handle incomplete
	lines in the "connecting" state. Thanks to Sergei Golovan.

2009-04-08  Andreas Kupries  <andreask@activestate.com>

	* library/platform/platform.tcl: Extended the darwin sections to add
	* library/platform/pkgIndex.tcl: a kernel version number to the
	* unix/Makefile.in: identifier for anything from Leopard (10.5) on up.
	* win/Makefile.in: Extended patterns for same. Extended cpu
	* doc/platform.n: recognition for 64bit Tcl running on a 32bit kernel
	on a 64bit processor (By Daniel Steffen). Bumped version to 1.0.4.
	Updated Makefiles.

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

	* library/tcltest/tcltest.tcl:  [Bug 2570363]: Converted [eval]s (some
	* library/tcltest/pkgIndex.tcl: unsafe!) to {*} in tcltest package. 
	* unix/Makefile.in:     => tcltest 2.3.1
	* win/Makefile.in:

2009-04-07  Don Porter  <dgp@users.sourceforge.net>

	* generic/tclStringObj.c:	Correction so that value of
	TCL_GROWTH_MIN_ALLOC is everywhere expressed in bytes as comment
	claims.

2009-04-04  Donal K. Fellows  <dkf@users.sf.net>

	* doc/vwait.n: [Bug 1910136]: Extend description and examples to make
	it clearer just how this command interprets variable names.

2009-03-30  Don Porter  <dgp@users.sourceforge.net>
Changes to doc/StringObj.3.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'\"
'\" Copyright (c) 1994-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: StringObj.3,v 1.13.4.13 2008/12/18 23:19:07 dgp Exp $
'\" 
.so man.macros
.TH Tcl_StringObj 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_NewStringObj, Tcl_NewUnicodeObj, Tcl_SetStringObj, Tcl_SetUnicodeObj, Tcl_GetStringFromObj, Tcl_GetString, Tcl_GetUnicodeFromObj, Tcl_GetUnicode, Tcl_GetUniChar, Tcl_GetCharLength, Tcl_GetRange, Tcl_AppendToObj, Tcl_AppendUnicodeToObj, Tcl_AppendObjToObj, Tcl_AppendStringsToObj, Tcl_AppendStringsToObjVA, Tcl_AppendLimitedToObj, Tcl_Format, Tcl_AppendFormatToObj, Tcl_ObjPrintf, Tcl_AppendPrintfToObj, Tcl_SetObjLength, Tcl_AttemptSetObjLength, Tcl_ConcatObj \- manipulate Tcl objects as strings
.SH SYNOPSIS






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
'\"
'\" Copyright (c) 1994-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: StringObj.3,v 1.13.4.14 2009/04/10 18:09:29 dgp Exp $
'\" 
.so man.macros
.TH Tcl_StringObj 3 8.1 Tcl "Tcl Library Procedures"
.BS
.SH NAME
Tcl_NewStringObj, Tcl_NewUnicodeObj, Tcl_SetStringObj, Tcl_SetUnicodeObj, Tcl_GetStringFromObj, Tcl_GetString, Tcl_GetUnicodeFromObj, Tcl_GetUnicode, Tcl_GetUniChar, Tcl_GetCharLength, Tcl_GetRange, Tcl_AppendToObj, Tcl_AppendUnicodeToObj, Tcl_AppendObjToObj, Tcl_AppendStringsToObj, Tcl_AppendStringsToObjVA, Tcl_AppendLimitedToObj, Tcl_Format, Tcl_AppendFormatToObj, Tcl_ObjPrintf, Tcl_AppendPrintfToObj, Tcl_SetObjLength, Tcl_AttemptSetObjLength, Tcl_ConcatObj \- manipulate Tcl objects as strings
.SH SYNOPSIS
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
conversion specifier passed to \fBTcl_ObjPrintf\fR includes a precision,
the value is taken as a number of bytes, as \fBsprintf\fR does, and not
as a number of characters, as \fBformat\fR does.  This is done on the
assumption that C code is more likely to know how many bytes it is
passing around than the number of encoded characters those bytes happen
to represent.  The variable number of arguments passed in should be of
the types that would be suitable for passing to \fBsprintf\fR.  Note in
this example usage, \fIx\fR is of type \fBlong\fR.
.PP
.CS
long x = 5;
Tcl_Obj *objPtr = \fBTcl_ObjPrintf\fR("Value is %d", x);
.CE
.PP
If the value of \fIformat\fR contains internal inconsistencies or invalid
specifier formats, the formatted string result produced by
\fBTcl_ObjPrintf\fR will be an error message describing the error.
.PP







|


|







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
conversion specifier passed to \fBTcl_ObjPrintf\fR includes a precision,
the value is taken as a number of bytes, as \fBsprintf\fR does, and not
as a number of characters, as \fBformat\fR does.  This is done on the
assumption that C code is more likely to know how many bytes it is
passing around than the number of encoded characters those bytes happen
to represent.  The variable number of arguments passed in should be of
the types that would be suitable for passing to \fBsprintf\fR.  Note in
this example usage, \fIx\fR is of type \fBint\fR.
.PP
.CS
int x = 5;
Tcl_Obj *objPtr = \fBTcl_ObjPrintf\fR("Value is %d", x);
.CE
.PP
If the value of \fIformat\fR contains internal inconsistencies or invalid
specifier formats, the formatted string result produced by
\fBTcl_ObjPrintf\fR will be an error message describing the error.
.PP
Changes to doc/platform.n.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'\"
'\" Copyright (c) 2006 ActiveState Software Inc
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @(#) $Id: platform.n,v 1.1.2.5 2008/03/26 20:00:00 dgp Exp $
'\" 
.so man.macros
.TH "platform" n 1.0.3 platform "Tcl Bundled Packages"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
platform \- System identification support code and utilities
.SH SYNOPSIS
.nf
\fBpackage require platform ?1.0.3?\fR
.sp
\fBplatform::generic\fR
\fBplatform::identify\fR
\fBplatform::patterns \fIidentifier\fR
.fi
.BE
.SH DESCRIPTION






|


|






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'\"
'\" Copyright (c) 2006 ActiveState Software Inc
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
'\" RCS: @(#) $Id: platform.n,v 1.1.2.6 2009/04/10 18:09:29 dgp Exp $
'\" 
.so man.macros
.TH "platform" n 1.0.4 platform "Tcl Bundled Packages"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
platform \- System identification support code and utilities
.SH SYNOPSIS
.nf
\fBpackage require platform ?1.0.4?\fR
.sp
\fBplatform::generic\fR
\fBplatform::identify\fR
\fBplatform::patterns \fIidentifier\fR
.fi
.BE
.SH DESCRIPTION
Changes to generic/tclInt.decls.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
# Copyright (c) 2007 Daniel A. Steffen <das@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: tclInt.decls,v 1.61.2.42 2009/03/03 05:59:40 dgp Exp $

library tcl

# Define the unsupported generic interfaces.

interface tclInt








|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
# Copyright (c) 2007 Daniel A. Steffen <das@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: tclInt.decls,v 1.61.2.43 2009/04/10 18:09:29 dgp Exp $

library tcl

# Define the unsupported generic interfaces.

interface tclInt

1177
1178
1179
1180
1181
1182
1183



	    const Tcl_StatBuf *statBufPtr)
}
declare 18 macosx {
    int TclMacOSXMatchType(Tcl_Interp *interp, const char *pathName,
	    const char *fileName, Tcl_StatBuf *statBufPtr,
	    Tcl_GlobTypeData *types)
}










>
>
>
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
	    const Tcl_StatBuf *statBufPtr)
}
declare 18 macosx {
    int TclMacOSXMatchType(Tcl_Interp *interp, const char *pathName,
	    const char *fileName, Tcl_StatBuf *statBufPtr,
	    Tcl_GlobTypeData *types)
}
declare 19 macosx {
    void TclMacOSXNotifierAddRunLoopMode(const void *runLoopMode)
}
Changes to generic/tclIntPlatDecls.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * tclIntPlatDecls.h --
 *
 *	This file contains the declarations for all platform dependent
 *	unsupported functions that are exported by the Tcl library.  These
 *	interfaces are not guaranteed to remain the same between
 *	versions.  Use at your own risk.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * All rights reserved.
 *
 * RCS: @(#) $Id: tclIntPlatDecls.h,v 1.20.2.13 2008/10/23 15:51:10 dgp Exp $
 */

#ifndef _TCLINTPLATDECLS
#define _TCLINTPLATDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * tclIntPlatDecls.h --
 *
 *	This file contains the declarations for all platform dependent
 *	unsupported functions that are exported by the Tcl library.  These
 *	interfaces are not guaranteed to remain the same between
 *	versions.  Use at your own risk.
 *
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * All rights reserved.
 *
 * RCS: @(#) $Id: tclIntPlatDecls.h,v 1.20.2.14 2009/04/10 18:09:29 dgp Exp $
 */

#ifndef _TCLINTPLATDECLS
#define _TCLINTPLATDECLS

#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
364
365
366
367
368
369
370






371
372
373
374
375
376
377
#define TclMacOSXMatchType_TCL_DECLARED
/* 18 */
EXTERN int		TclMacOSXMatchType (Tcl_Interp * interp,
				const char * pathName, const char * fileName,
				Tcl_StatBuf * statBufPtr,
				Tcl_GlobTypeData * types);
#endif






#endif /* MACOSX */

typedef struct TclIntPlatStubs {
    int magic;
    const struct TclIntPlatStubHooks *hooks;

#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */







>
>
>
>
>
>







364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#define TclMacOSXMatchType_TCL_DECLARED
/* 18 */
EXTERN int		TclMacOSXMatchType (Tcl_Interp * interp,
				const char * pathName, const char * fileName,
				Tcl_StatBuf * statBufPtr,
				Tcl_GlobTypeData * types);
#endif
#ifndef TclMacOSXNotifierAddRunLoopMode_TCL_DECLARED
#define TclMacOSXNotifierAddRunLoopMode_TCL_DECLARED
/* 19 */
EXTERN void		TclMacOSXNotifierAddRunLoopMode (
				const void * runLoopMode);
#endif
#endif /* MACOSX */

typedef struct TclIntPlatStubs {
    int magic;
    const struct TclIntPlatStubHooks *hooks;

#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
439
440
441
442
443
444
445

446
447
448
449
450
451
452
    struct tm * (*tclpGmtime_unix) (const time_t * clock); /* 12 */
    char * (*tclpInetNtoa) (struct in_addr addr); /* 13 */
    int (*tclUnixCopyFile) (const char * src, const char * dst, const Tcl_StatBuf * statBufPtr, int dontCopyAtts); /* 14 */
    int (*tclMacOSXGetFileAttribute) (Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj ** attributePtrPtr); /* 15 */
    int (*tclMacOSXSetFileAttribute) (Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj * attributePtr); /* 16 */
    int (*tclMacOSXCopyFileAttributes) (const char * src, const char * dst, const Tcl_StatBuf * statBufPtr); /* 17 */
    int (*tclMacOSXMatchType) (Tcl_Interp * interp, const char * pathName, const char * fileName, Tcl_StatBuf * statBufPtr, Tcl_GlobTypeData * types); /* 18 */

#endif /* MACOSX */
} TclIntPlatStubs;

#if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
extern const TclIntPlatStubs *tclIntPlatStubsPtr;
#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */








>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
    struct tm * (*tclpGmtime_unix) (const time_t * clock); /* 12 */
    char * (*tclpInetNtoa) (struct in_addr addr); /* 13 */
    int (*tclUnixCopyFile) (const char * src, const char * dst, const Tcl_StatBuf * statBufPtr, int dontCopyAtts); /* 14 */
    int (*tclMacOSXGetFileAttribute) (Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj ** attributePtrPtr); /* 15 */
    int (*tclMacOSXSetFileAttribute) (Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj * attributePtr); /* 16 */
    int (*tclMacOSXCopyFileAttributes) (const char * src, const char * dst, const Tcl_StatBuf * statBufPtr); /* 17 */
    int (*tclMacOSXMatchType) (Tcl_Interp * interp, const char * pathName, const char * fileName, Tcl_StatBuf * statBufPtr, Tcl_GlobTypeData * types); /* 18 */
    void (*tclMacOSXNotifierAddRunLoopMode) (const void * runLoopMode); /* 19 */
#endif /* MACOSX */
} TclIntPlatStubs;

#if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
extern const TclIntPlatStubs *tclIntPlatStubsPtr;
#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */

689
690
691
692
693
694
695




696
697
698
699
700
701
702
703
704
705
#define TclMacOSXCopyFileAttributes \
	(tclIntPlatStubsPtr->tclMacOSXCopyFileAttributes) /* 17 */
#endif
#ifndef TclMacOSXMatchType
#define TclMacOSXMatchType \
	(tclIntPlatStubsPtr->tclMacOSXMatchType) /* 18 */
#endif




#endif /* MACOSX */

#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 /* _TCLINTPLATDECLS */







>
>
>
>










696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
#define TclMacOSXCopyFileAttributes \
	(tclIntPlatStubsPtr->tclMacOSXCopyFileAttributes) /* 17 */
#endif
#ifndef TclMacOSXMatchType
#define TclMacOSXMatchType \
	(tclIntPlatStubsPtr->tclMacOSXMatchType) /* 18 */
#endif
#ifndef TclMacOSXNotifierAddRunLoopMode
#define TclMacOSXNotifierAddRunLoopMode \
	(tclIntPlatStubsPtr->tclMacOSXNotifierAddRunLoopMode) /* 19 */
#endif
#endif /* MACOSX */

#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 /* _TCLINTPLATDECLS */
Changes to generic/tclStubInit.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * tclStubInit.c --
 *
 *	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.84.2.54 2009/02/11 17:27:47 dgp Exp $
 */

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

/*
 * Remove macros that will interfere with the definitions below.










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * tclStubInit.c --
 *
 *	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.84.2.55 2009/04/10 18:09:29 dgp Exp $
 */

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

/*
 * Remove macros that will interfere with the definitions below.
358
359
360
361
362
363
364

365
366
367
368
369
370
371
    TclpGmtime_unix, /* 12 */
    TclpInetNtoa, /* 13 */
    TclUnixCopyFile, /* 14 */
    TclMacOSXGetFileAttribute, /* 15 */
    TclMacOSXSetFileAttribute, /* 16 */
    TclMacOSXCopyFileAttributes, /* 17 */
    TclMacOSXMatchType, /* 18 */

#endif /* MACOSX */
};

static const TclPlatStubs tclPlatStubs = {
    TCL_STUB_MAGIC,
    NULL,
#ifdef __WIN32__ /* WIN */







>







358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    TclpGmtime_unix, /* 12 */
    TclpInetNtoa, /* 13 */
    TclUnixCopyFile, /* 14 */
    TclMacOSXGetFileAttribute, /* 15 */
    TclMacOSXSetFileAttribute, /* 16 */
    TclMacOSXCopyFileAttributes, /* 17 */
    TclMacOSXMatchType, /* 18 */
    TclMacOSXNotifierAddRunLoopMode, /* 19 */
#endif /* MACOSX */
};

static const TclPlatStubs tclPlatStubs = {
    TCL_STUB_MAGIC,
    NULL,
#ifdef __WIN32__ /* WIN */
Changes to library/http/http.tcl.
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
# http.tcl --
#
#	Client-side HTTP for GET, POST, and HEAD commands. These routines can
#	be used in untrusted code that uses the Safesock security policy.
#	These procedures use a callback interface to avoid using vwait, which
#	is not defined in the safe base.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: http.tcl,v 1.44.2.13 2009/02/25 13:50:41 dgp Exp $

package require Tcl 8.4
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
package provide http 2.7.3

namespace eval http {
    # Allow resourcing to not clobber existing data

    variable http
    if {![info exists http]} {
	array set http {
	    -accept */*
	    -proxyhost {}
	    -proxyport {}
	    -proxyfilter http::ProxyRequired
	    -urlencoding utf-8
	}



	set http(-useragent) "Tcl http client package [package provide http]"



    }

    proc init {} {
	# Set up the map for quoting chars. RFC3986 Section 2.3 say percent
	# encode all except: "... percent-encoded octets in the ranges of
	# ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period
	# (%2E), underscore (%5F), or tilde (%7E) should not be created by URI










|

|


|













>
>
>
|
>
>
>







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
# http.tcl --
#
#	Client-side HTTP for GET, POST, and HEAD commands. These routines can
#	be used in untrusted code that uses the Safesock security policy.
#	These procedures use a callback interface to avoid using vwait, which
#	is not defined in the safe base.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: http.tcl,v 1.44.2.14 2009/04/10 18:09:29 dgp Exp $

package require Tcl 8.6
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
package provide http 2.8.0

namespace eval http {
    # Allow resourcing to not clobber existing data

    variable http
    if {![info exists http]} {
	array set http {
	    -accept */*
	    -proxyhost {}
	    -proxyport {}
	    -proxyfilter http::ProxyRequired
	    -urlencoding utf-8
	}
	# We need a useragent string of this style or various servers will refuse to
	# send us compressed content even when we ask for it. This follows the
	# de-facto layout of user-agent strings in current browsers.
	set http(-useragent) "Mozilla/5.0\
            ([string totitle $::tcl_platform(platform)]; U;\
            $::tcl_platform(os) $::tcl_platform(osVersion))\
            http/[package provide http] Tcl/[package provide Tcl]"
    }

    proc init {} {
	# Set up the map for quoting chars. RFC3986 Section 2.3 say percent
	# encode all except: "... percent-encoded octets in the ranges of
	# ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period
	# (%2E), underscore (%5F), or tilde (%7E) should not be created by URI
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#
#	Debugging output -- define this to observe HTTP/1.1 socket usage.
#	Should echo any args received.
#
# Arguments:
#     msg	Message to output
#
proc http::Log {args} {}

# http::register --
#
#     See documentation for details.
#
# Arguments:
#     proto	URL protocol prefix, e.g. https







|







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#
#	Debugging output -- define this to observe HTTP/1.1 socket usage.
#	Should echo any args received.
#
# Arguments:
#     msg	Message to output
#
if {[info command http::Log] eq {}} { proc http::Log {args} {} }

# http::register --
#
#     See documentation for details.
#
# Arguments:
#     proto	URL protocol prefix, e.g. https
645
646
647
648
649
650
651




652
653
654
655
656
657
658
659
	# work properly.
	fconfigure $state(-querychannel) -blocking 1 -translation binary
	set contDone 0
    }
    if {[info exists state(-method)] && $state(-method) ne ""} {
	set how $state(-method)
    }





    if {[catch {
	puts $sock "$how $srvurl HTTP/$state(-protocol)"
	puts $sock "Accept: $http(-accept)"
	array set hdrs $state(-headers)
	if {[info exists hdrs(Host)]} {
	    # Allow Host spoofing. [Bug 928154]
	    puts $sock "Host: $hdrs(Host)"







>
>
>
>
|







651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
	# work properly.
	fconfigure $state(-querychannel) -blocking 1 -translation binary
	set contDone 0
    }
    if {[info exists state(-method)] && $state(-method) ne ""} {
	set how $state(-method)
    }
    # We cannot handle chunked encodings with -handler, so force HTTP/1.0
    # until we can manage this.
    if {[info exists state(-handler)]} {
	set state(-protocol) 1.0
    }
    if {[catch {
	puts $sock "$how $srvurl HTTP/$state(-protocol)"
	puts $sock "Accept: $http(-accept)"
	array set hdrs $state(-headers)
	if {[info exists hdrs(Host)]} {
	    # Allow Host spoofing. [Bug 928154]
	    puts $sock "Host: $hdrs(Host)"
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
		set contDone 1
		set state(querylength) $value
	    }
	    if {[string length $key]} {
		puts $sock "$key: $value"
	    }
	}
	# Soft zlib dependency check - no package require
        if {
	    !$accept_encoding_seen &&
	    ([package vsatisfies [package provide Tcl] 8.6]
		|| [llength [package provide zlib]]) &&
	    !([info exists state(-channel)] || [info exists state(-handler)])
        } then {
	    puts $sock "Accept-Encoding: gzip, identity, *;q=0.1"
        }
	if {$isQueryChannel && $state(querylength) == 0} {
	    # Try to determine size of data in channel. If we cannot seek, the
	    # surrounding catch will trap us

	    set start [tell $state(-querychannel)]
	    seek $state(-querychannel) 0 end







<
<
|
<
<
<
<
|







699
700
701
702
703
704
705


706




707
708
709
710
711
712
713
714
		set contDone 1
		set state(querylength) $value
	    }
	    if {[string length $key]} {
		puts $sock "$key: $value"
	    }
	}


        if {!$accept_encoding_seen && ![info exists state(-handler)]} {




	    puts $sock "Accept-Encoding: deflate,gzip,compress"
        }
	if {$isQueryChannel && $state(querylength) == 0} {
	    # Try to determine size of data in channel. If we cannot seek, the
	    # surrounding catch will trap us

	    set start [tell $state(-querychannel)]
	    seek $state(-querychannel) 0 end
958
959
960
961
962
963
964
965
966
967


968
969
970
971
972
973
974
		Log "WARNING: additional data left on closed socket"
	    }
	}
	CloseSocket $sock
	return
    }
    if {$state(state) eq "connecting"} {
	set state(state) "header"
	if {[catch {gets $sock state(http)} n]} {
	    return [Finish $token $n]


	}
    } elseif {$state(state) eq "header"} {
	if {[catch {gets $sock line} n]} {
	    return [Finish $token $n]
	} elseif {$n == 0} {
	    # We have now read all headers
	    # We ignore HTTP/1.1 100 Continue returns. RFC2616 sec 8.2.3







<


>
>







962
963
964
965
966
967
968

969
970
971
972
973
974
975
976
977
978
979
		Log "WARNING: additional data left on closed socket"
	    }
	}
	CloseSocket $sock
	return
    }
    if {$state(state) eq "connecting"} {

	if {[catch {gets $sock state(http)} n]} {
	    return [Finish $token $n]
	} elseif {$n >= 0} {
	    set state(state) "header"
	}
    } elseif {$state(state) eq "header"} {
	if {[catch {gets $sock line} n]} {
	    return [Finish $token $n]
	} elseif {$n == 0} {
	    # We have now read all headers
	    # We ignore HTTP/1.1 100 Continue returns. RFC2616 sec 8.2.3
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

	    if {
		$state(-binary) || ![string match -nocase text* $state(type)]
	    } then {
		# Turn off conversions for non-text data
		set state(binary) 1
	    }
	    if {
		$state(binary) || [string match *gzip* $state(coding)] ||
		[string match *compress* $state(coding)]
	    } then {
		if {[info exists state(-channel)]} {

		    fconfigure $state(-channel) -translation binary
		}
	    }
	    if {
		[info exists state(-channel)] &&
		![info exists state(-handler)]
	    } then {
		# Initiate a sequence of background fcopies
		fileevent $sock readable {}
		CopyStart $sock $token
		return

	    }
	} elseif {$n > 0} {
	    # Process header lines
	    if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
		switch -- [string tolower $key] {
		    content-type {
			set state(type) [string trim [string tolower $value]]







<
<
<
<
|
>


<
<
<
|
<
|
|
|
|
>







1009
1010
1011
1012
1013
1014
1015




1016
1017
1018
1019



1020

1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032

	    if {
		$state(-binary) || ![string match -nocase text* $state(type)]
	    } then {
		# Turn off conversions for non-text data
		set state(binary) 1
	    }




	    if {[info exists state(-channel)]} {
		if {$state(binary) || [llength [ContentEncoding $token]]} {
		    fconfigure $state(-channel) -translation binary
		}



		if {![info exists state(-handler)]} {

		    # Initiate a sequence of background fcopies
		    fileevent $sock readable {}
		    CopyStart $sock $token
		    return
		}
	    }
	} elseif {$n > 0} {
	    # Process header lines
	    if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
		switch -- [string tolower $key] {
		    content-type {
			set state(type) [string trim [string tolower $value]]
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174











1175
1176
1177
1178
1179






























1180
1181
1182
1183
1184
1185
1186
# Arguments
#	sock	The socket to copy from
#	token	The token returned from http::geturl
#
# Side Effects
#	This closes the connection upon error

proc http::CopyStart {sock token} {
    variable $token
    upvar 0 $token state











    if {[catch {
	fcopy $sock $state(-channel) -size $state(-blocksize) -command \
	    [list http::CopyDone $token]
    } err]} then {
	Finish $token $err






























    }
}

# http::CopyDone
#
#	fcopy completion callback
#







|
<
|
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
# Arguments
#	sock	The socket to copy from
#	token	The token returned from http::geturl
#
# Side Effects
#	This closes the connection upon error

proc http::CopyStart {sock token {initial 1}} {

    upvar #0 $token state
    if {[info exists state(transfer)] && $state(transfer) eq "chunked"} {
	foreach coding [ContentEncoding $token] {
	    lappend state(zlib) [zlib stream $coding]
	}
	make-transformation-chunked $sock [namespace code [list CopyChunk $token]]
    } else {
	if {$initial} {
	    foreach coding [ContentEncoding $token] {
		zlib push $coding $sock
	    }
	}
	if {[catch {
	    fcopy $sock $state(-channel) -size $state(-blocksize) -command \
		[list http::CopyDone $token]
	} err]} {
	    Finish $token $err
	}
    }
}

proc http::CopyChunk {token chunk} {
    upvar 0 $token state
    if {[set count [string length $chunk]]} {
	incr state(currentsize) $count
	if {[info exists state(zlib)]} {
	    foreach stream $state(zlib) {
		set chunk [$stream add $chunk]
	    }
	}
	puts -nonewline $state(-channel) $chunk
	if {[info exists state(-progress)]} {
	    eval [linsert $state(-progress) end \
		      $token $state(totalsize) $state(currentsize)]
	}
    } else {
	Log "CopyChunk Finish $token"
	if {[info exists state(zlib)]} {
	    set excess ""
	    foreach stream $state(zlib) {
		catch {set excess [$stream add -finalize $excess]}
	    }
	    puts -nonewline $state(-channel) $excess
	    foreach stream $state(zlib) { $stream close }
	    unset state(zlib)
	}
	Eof $token ;# FIX ME: pipelining.
    }
}

# http::CopyDone
#
#	fcopy completion callback
#
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
    }
    # At this point the token may have been reset
    if {[string length $error]} {
	Finish $token $error
    } elseif {[catch {eof $sock} iseof] || $iseof} {
	Eof $token
    } else {
	CopyStart $sock $token
    }
}

# http::Eof
#
#	Handle eof on the socket
#







|







1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
    }
    # At this point the token may have been reset
    if {[string length $error]} {
	Finish $token $error
    } elseif {[catch {eof $sock} iseof] || $iseof} {
	Eof $token
    } else {
	CopyStart $sock $token 0
    }
}

# http::Eof
#
#	Handle eof on the socket
#
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
    if {$state(state) eq "header"} {
	# Premature eof
	set state(status) eof
    } else {
	set state(status) ok
    }

    if {($state(coding) eq "gzip") && [string length $state(body)] > 0} {
        if {[catch {
	    if {[package vsatisfies [package present Tcl] 8.6]} {
		# The zlib integration into 8.6 includes proper gzip support
		set state(body) [zlib gunzip $state(body)]
	    } else {
		set state(body) [Gunzip $state(body)]
	    }
        } err]} then {

	    return [Finish $token $err]
        }
    }

    if {!$state(binary)} {
        # If we are getting text, set the incoming channel's encoding
        # correctly.  iso8859-1 is the RFC default, but this could be any IANA
        # charset.  However, we only know how to convert what we have
        # encodings for.

        set enc [CharsetToEncoding $state(charset)]
        if {$enc ne "binary"} {
	    set state(body) [encoding convertfrom $enc $state(body)]
        }

        # Translate text line endings.
        set state(body) [string map {\r\n \n \r \n} $state(body)]
    }

    Finish $token
}

# http::wait --
#
#	See documentation for details.
#







|
|
|
<
|
<
<

|
>

|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







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
    if {$state(state) eq "header"} {
	# Premature eof
	set state(status) eof
    } else {
	set state(status) ok
    }

    if {[string length $state(body)] > 0} {
	if {[catch {
	    foreach coding [ContentEncoding $token] {

		set state(body) [zlib $coding $state(body)]


	    }
	} err]} {
	    Log "error doing $coding '$state(body)'"
	    return [Finish $token $err]
	}
	

	if {!$state(binary)} {
	    # If we are getting text, set the incoming channel's encoding
	    # correctly.  iso8859-1 is the RFC default, but this could be any IANA
	    # charset.  However, we only know how to convert what we have
	    # encodings for.
	    
	    set enc [CharsetToEncoding $state(charset)]
	    if {$enc ne "binary"} {
		set state(body) [encoding convertfrom $enc $state(body)]
	    }
	    
	    # Translate text line endings.
	    set state(body) [string map {\r\n \n \r \n} $state(body)]
	}
    }
    Finish $token
}

# http::wait --
#
#	See documentation for details.
#
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
    if {$idx >= 0} {
	return $encoding
    } else {
	return "binary"
    }
}


# http::Gunzip --
#



#	Decompress data transmitted using the gzip transfer coding.
#

# FIX ME: redo using zlib sinflate
proc http::Gunzip {data} {
    binary scan $data Scb5icc magic method flags time xfl os


    set pos 10
    if {$magic != 0x1f8b} {
        return -code error "invalid data: supplied data is not in gzip format"
    }
    if {$method != 8} {
        return -code error "invalid compression method"
    }

    # lassign [split $flags ""] f_text f_crc f_extra f_name f_comment
    foreach {f_text f_crc f_extra f_name f_comment} [split $flags ""] break

    set extra ""
    if {$f_extra} {
	binary scan $data @${pos}S xlen
        incr pos 2
        set extra [string range $data $pos $xlen]
        set pos [incr xlen]
    }




    set name ""

    if {$f_name} {
        set ndx [string first \0 $data $pos]
        set name [string range $data $pos $ndx]
        set pos [incr ndx]
    }


    set comment ""
    if {$f_comment} {
        set ndx [string first \0 $data $pos]
        set comment [string range $data $pos $ndx]
        set pos [incr ndx]
    }





    set fcrc ""
    if {$f_crc} {
	set fcrc [string range $data $pos [incr pos]]


        incr pos
    }

    binary scan [string range $data end-7 end] ii crc size
    set inflated [zlib inflate [string range $data $pos end-8]]
    set chk [zlib crc32 $inflated]
    if {($crc & 0xffffffff) != ($chk & 0xffffffff)} {
	return -code error "invalid data: checksum mismatch $crc != $chk"
    }


    return $inflated
}

# Local variables:
# indent-tabs-mode: t
# End:







>
|
<
>
>
>
|
<
|
|
|
<
>
>
|
<
|
|
<
<
|
|
<
<
>
|
<
<
<
<
<
|

>
>
>
|
>
|
<
|
|
<
|
>
|
|
|
|
|
|
>
>
>
>
|
<
<
|
>
>
|
|
|
<
<
<
<
<
|
>
>
|





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
    if {$idx >= 0} {
	return $encoding
    } else {
	return "binary"
    }
}

# Return the list of content-encoding transformations we need to do in order.
proc http::ContentEncoding {token} {

    upvar 0 $token state
    set r {}
    if {[info exists state(coding)]} {
	foreach coding [split $state(coding) ,] {

	    switch -exact -- $coding {
		deflate { lappend r inflate }
		gzip - x-gzip { lappend r gunzip }

		compress - x-compress { lappend r decompress }
		identity {}
		default {

		    return -code error "unsupported content-encoding \"$coding\""
		}


	    }
	}


    }
    return $r





}

proc http::make-transformation-chunked {chan command} {
    set lambda {{chan command} {
        set data ""
        set size -1
        yield
        while {1} {

            chan configure $chan -translation {crlf binary}
            while {[gets $chan line] < 1} { yield }

            chan configure $chan -translation {binary binary}
            if {[scan $line %x size] != 1} { return -code error "invalid size: \"$line\"" }
            set chunk ""
            while {$size && ![chan eof $chan]} {
                set part [chan read $chan $size]
                incr size -[string length $part]
                append chunk $part
            }
            if {[catch {
		uplevel #0 [linsert $command end $chunk]
	    }]} then {
		http::Log "Error in callback: $::errorInfo"
	    }


            if {[string length $chunk] == 0} {
		# channel might have been closed in the callback
                catch {chan event $chan readable {}}
                return
            }
        }





    }}
    coroutine dechunk$chan ::apply $lambda $chan $command
    chan event $chan readable [namespace origin dechunk$chan]
    return
}

# Local variables:
# indent-tabs-mode: t
# End:
Changes to library/http/pkgIndex.tcl.
1
2
3
4
# Tcl package index file, version 1.1

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded http 2.7.3 [list tclPkgSetup $dir http 2.7.3 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
<
<
|
|


1
2


if {![package vsatisfies [package provide Tcl] 8.6]} {return}
package ifneeded http 2.8.0 [list tclPkgSetup $dir http 2.8.0 {{http.tcl source {::http::config ::http::formatQuery ::http::geturl ::http::reset ::http::wait ::http::register ::http::unregister ::http::mapReply}}}]
Changes to library/platform/pkgIndex.tcl.
1
2
3
package ifneeded platform        1.0.3 [list source [file join $dir platform.tcl]]
package ifneeded platform::shell 1.1.4 [list source [file join $dir shell.tcl]]

|


1
2
3
package ifneeded platform        1.0.4 [list source [file join $dir platform.tcl]]
package ifneeded platform::shell 1.1.4 [list source [file join $dir shell.tcl]]

Changes to library/platform/platform.tcl.
107
108
109
110
111
112
113







114
115
116
117
118
119
120
		if {$tcl_platform(wordSize) == 8} {
		    append cpu 64
		}
	    }
	}
	darwin {
	    set plat macosx







	}
	aix {
	    set cpu powerpc
	    if {$tcl_platform(wordSize) == 8} {
		append cpu 64
	    }
	}







>
>
>
>
>
>
>







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
		if {$tcl_platform(wordSize) == 8} {
		    append cpu 64
		}
	    }
	}
	darwin {
	    set plat macosx
	    # Correctly identify the cpu when running as a 64bit
	    # process on a machine with a 32bit kernel
	    if {$cpu eq "ix86"} {
		if {$tcl_platform(wordSize) == 8} {
		    set cpu x86_64
		}
	    }
	}
	aix {
	    set cpu powerpc
	    if {$tcl_platform(wordSize) == 8} {
		append cpu 64
	    }
	}
149
150
151
152
153
154
155








156
157
158
159
160
161
162
    regexp {^([^-]+)-([^-]+)$} $id -> plat cpu

    switch -- $plat {
	solaris {
	    regsub {^5} $tcl_platform(osVersion) 2 text
	    append plat $text
	    return "${plat}-${cpu}"








	}
	linux {
	    # Look for the libc*.so and determine its version
	    # (libc5/6, libc6 further glibc 2.X)

	    set v unknown








>
>
>
>
>
>
>
>







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    regexp {^([^-]+)-([^-]+)$} $id -> plat cpu

    switch -- $plat {
	solaris {
	    regsub {^5} $tcl_platform(osVersion) 2 text
	    append plat $text
	    return "${plat}-${cpu}"
	}
	macosx {
	    set major [lindex [split $tcl_platform(osVersion) .] 0]
	    if {$major > 8} {
		incr major -4
		append plat 10.$major
		return "${plat}-${cpu}"
	    }
	}
	linux {
	    # Look for the libc*.so and determine its version
	    # (libc5/6, libc6 further glibc 2.X)

	    set v unknown

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
	    if {[regexp {linux-glibc([^-]*)-(.*)} $id -> v cpu]} {
		foreach {major minor} [split $v .] break
		incr minor -1
		for {set j $minor} {$j >= 0} {incr j -1} {
		    lappend res linux-glibc${major}.${j}-${cpu}
		}
	    }























	}
	macosx-powerpc -
	macosx-ix86    {
	    lappend res macosx-universal
	}
    }
    lappend res tcl ; # Pure tcl packages are always compatible.
    return $res
}


# ### ### ### ######### ######### #########
## Ready

package provide platform 1.0.3

# ### ### ### ######### ######### #########
## Demo application

if {[info exists argv0] && ($argv0 eq [info script])} {
    puts ====================================
    parray tcl_platform







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














|







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
	    if {[regexp {linux-glibc([^-]*)-(.*)} $id -> v cpu]} {
		foreach {major minor} [split $v .] break
		incr minor -1
		for {set j $minor} {$j >= 0} {incr j -1} {
		    lappend res linux-glibc${major}.${j}-${cpu}
		}
	    }
	}
	macosx*-*    {
	    # 10.5+ 
	    if {[regexp {macosx([^-]*)-(.*)} $id -> v cpu]} {
		if {$v ne ""} {
		    foreach {major minor} [split $v .] break

		    # Add 10.5 to 10.minor to patterns.
		    set res {}
		    for {set j $minor} {$j >= 5} {incr j -1} {
			lappend res macosx${major}.${j}-${cpu}
			lappend res macosx${major}.${j}-universal
		    }

		    # Add unversioned patterns for 10.3/10.4 builds.
		    lappend res macosx-${cpu}
		    lappend res macosx-universal
		} else {
		    lappend res macosx-universal
		}
	    } else {
		lappend res macosx-universal
	    }
	}
	macosx-powerpc -
	macosx-ix86    {
	    lappend res macosx-universal
	}
    }
    lappend res tcl ; # Pure tcl packages are always compatible.
    return $res
}


# ### ### ### ######### ######### #########
## Ready

package provide platform 1.0.4

# ### ### ### ######### ######### #########
## Demo application

if {[info exists argv0] && ($argv0 eq [info script])} {
    puts ====================================
    parray tcl_platform
Changes to library/tcltest/pkgIndex.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex -direct" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

if {![package vsatisfies [package provide Tcl] 8.5]} {return}
package ifneeded tcltest 2.3.0 [list source [file join $dir tcltest.tcl]]











|
1
2
3
4
5
6
7
8
9
10
11
12
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex -direct" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

if {![package vsatisfies [package provide Tcl] 8.5]} {return}
package ifneeded tcltest 2.3.1 [list source [file join $dir tcltest.tcl]]
Changes to library/tcltest/tcltest.tcl.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2000 by Ajuba Solutions
# Contributions from Don Porter, NIST, 2002.  (not subject to US copyright)
# All rights reserved.
#
# RCS: @(#) $Id: tcltest.tcl,v 1.82.2.10 2007/12/06 06:51:43 dgp Exp $

package require Tcl 8.5		;# -verbose line uses [info frame]
namespace eval tcltest {

    # When the version number changes, be sure to update the pkgIndex.tcl file,
    # and the install directory in the Makefiles.  When the minor version
    # changes (new feature) be sure to update the man page as well.
    variable Version 2.3.0

    # Compatibility support for dumb variables defined in tcltest 1
    # Do not use these.  Call [package provide Tcl] and [info patchlevel]
    # yourself.  You don't need tcltest to wrap it for you.
    variable version [package provide Tcl]
    variable patchLevel [info patchlevel]








|







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2000 by Ajuba Solutions
# Contributions from Don Porter, NIST, 2002.  (not subject to US copyright)
# All rights reserved.
#
# RCS: @(#) $Id: tcltest.tcl,v 1.82.2.11 2009/04/10 18:09:29 dgp Exp $

package require Tcl 8.5		;# -verbose line uses [info frame]
namespace eval tcltest {

    # When the version number changes, be sure to update the pkgIndex.tcl file,
    # and the install directory in the Makefiles.  When the minor version
    # changes (new feature) be sure to update the man page as well.
    variable Version 2.3.1

    # Compatibility support for dumb variables defined in tcltest 1
    # Do not use these.  Call [package provide Tcl] and [info patchlevel]
    # yourself.  You don't need tcltest to wrap it for you.
    variable version [package provide Tcl]
    variable patchLevel [info patchlevel]

598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
		return -code error $option
	    }
	    return -code error "missing value for option $option"
	}
    }
    proc configure args {
	RemoveAutoConfigureTraces
	set code [catch {eval Configure $args} msg]
	return -code $code $msg
    }
    
    proc AcceptVerbose { level } {
	set level [AcceptList $level]
	if {[llength $level] == 1} {
	    if {![regexp {^(pass|body|skip|start|error|line)$} $level]} {







|







598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
		return -code error $option
	    }
	    return -code error "missing value for option $option"
	}
    }
    proc configure args {
	RemoveAutoConfigureTraces
	set code [catch {Configure {*}$args} msg]
	return -code $code $msg
    }
    
    proc AcceptVerbose { level } {
	set level [AcceptList $level]
	if {[llength $level] == 1} {
	    if {![regexp {^(pass|body|skip|start|error|line)$} $level]} {
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
	exit 1
    }

    if {[llength $flagArray] == 0} {
	RemoveAutoConfigureTraces
    } else {
	set args $flagArray
	while {[llength $args]>1 && [catch {eval configure $args} msg]} {

	    # Something went wrong parsing $args for tcltest options
	    # Check whether the problem is "unknown option"
	    if {[regexp {^unknown option (\S+):} $msg -> option]} {
		# Could be this is an option the Hook knows about
		set moreOptions [processCmdLineArgsAddFlagsHook]
		if {[lsearch -exact $moreOptions $option] == -1} {







|







1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
	exit 1
    }

    if {[llength $flagArray] == 0} {
	RemoveAutoConfigureTraces
    } else {
	set args $flagArray
	while {[llength $args]>1 && [catch {configure {*}$args} msg]} {

	    # Something went wrong parsing $args for tcltest options
	    # Check whether the problem is "unknown option"
	    if {[regexp {^unknown option (\S+):} $msg -> option]} {
		# Could be this is an option the Hook knows about
		set moreOptions [processCmdLineArgsAddFlagsHook]
		if {[lsearch -exact $moreOptions $option] == -1} {
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
	    append errData [lindex $args end]$newline
	    return
	}
    }

    # If we haven't returned by now, we don't know how to handle the
    # input.  Let puts handle it.
    return [eval Puts $args]
}

# tcltest::Eval --
#
#	Evaluate the script in the test environment.  If ignoreOutput is
#       false, store data sent to stderr and stdout in outData and
#       errData.  Otherwise, ignore this output altogether.







|







1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
	    append errData [lindex $args end]$newline
	    return
	}
    }

    # If we haven't returned by now, we don't know how to handle the
    # input.  Let puts handle it.
    return [Puts {*}$args]
}

# tcltest::Eval --
#
#	Evaluate the script in the test environment.  If ignoreOutput is
#       false, store data sent to stderr and stdout in outData and
#       errData.  Otherwise, ignore this output altogether.
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
    } else {
	# "constraints" argument exists;
	# make sure that the constraints are satisfied.

	set doTest 0
	if {[string match {*[$\[]*} $constraints] != 0} {
	    # full expression, e.g. {$foo > [info tclversion]}
	    catch {set doTest [uplevel #0 expr $constraints]}
	} elseif {[regexp {[^.:_a-zA-Z0-9 \n\r\t]+} $constraints] != 0} {
	    # something like {a || b} should be turned into
	    # $testConstraints(a) || $testConstraints(b).
	    regsub -all {[.\w]+} $constraints {$testConstraints(&)} c
	    catch {set doTest [eval expr $c]}
	} elseif {![catch {llength $constraints}]} {
	    # just simple constraints such as {unixOnly fonts}.
	    set doTest 1
	    foreach constraint $constraints {
		if {(![info exists testConstraints($constraint)]) \
			|| (!$testConstraints($constraint))} {
		    set doTest 0







|




|







2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
    } else {
	# "constraints" argument exists;
	# make sure that the constraints are satisfied.

	set doTest 0
	if {[string match {*[$\[]*} $constraints] != 0} {
	    # full expression, e.g. {$foo > [info tclversion]}
	    catch {set doTest [uplevel #0 [list expr $constraints]]}
	} elseif {[regexp {[^.:_a-zA-Z0-9 \n\r\t]+} $constraints] != 0} {
	    # something like {a || b} should be turned into
	    # $testConstraints(a) || $testConstraints(b).
	    regsub -all {[.\w]+} $constraints {$testConstraints(&)} c
	    catch {set doTest [eval [list expr $c]]}
	} elseif {![catch {llength $constraints}]} {
	    # just simple constraints such as {unixOnly fonts}.
	    set doTest 1
	    foreach constraint $constraints {
		if {(![info exists testConstraints($constraint)]) \
			|| (!$testConstraints($constraint))} {
		    set doTest 0
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
#	primarily be used in 'all.tcl' files.  It is used in
#	runAllTests.
#
# Side Effects:
#       None

# a lower case version is needed for compatibility with tcltest 1.0
proc tcltest::getMatchingFiles args {eval GetMatchingFiles $args}

proc tcltest::GetMatchingFiles { args } {
    if {[llength $args]} {
	set dirList $args
    } else {
	# Finding tests only in [testsDirectory] is normal operation.
	# This procedure is written to accept multiple directory arguments







|







2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
#	primarily be used in 'all.tcl' files.  It is used in
#	runAllTests.
#
# Side Effects:
#       None

# a lower case version is needed for compatibility with tcltest 1.0
proc tcltest::getMatchingFiles args {GetMatchingFiles {*}$args}

proc tcltest::GetMatchingFiles { args } {
    if {[llength $args]} {
	set dirList $args
    } else {
	# Finding tests only in [testsDirectory] is normal operation.
	# This procedure is written to accept multiple directory arguments
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
    proc ConfigureFromEnvironment {} {
	upvar #0 env(TCLTEST_OPTIONS) options
	if {[catch {llength $options} msg]} {
	    Warn "invalid TCLTEST_OPTIONS \"$options\":\n  invalid\
		    Tcl list: $msg"
	    return
	}
	if {[llength $::env(TCLTEST_OPTIONS)] % 2} {
	    Warn "invalid TCLTEST_OPTIONS: \"$options\":\n  should be\
		    -option value ?-option value ...?"
	    return
	}
	if {[catch {eval Configure $::env(TCLTEST_OPTIONS)} msg]} {
	    Warn "invalid TCLTEST_OPTIONS: \"$options\":\n  $msg"
	    return
	}
    }
    if {[info exists ::env(TCLTEST_OPTIONS)]} {
	ConfigureFromEnvironment
    }







|




|







3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
    proc ConfigureFromEnvironment {} {
	upvar #0 env(TCLTEST_OPTIONS) options
	if {[catch {llength $options} msg]} {
	    Warn "invalid TCLTEST_OPTIONS \"$options\":\n  invalid\
		    Tcl list: $msg"
	    return
	}
	if {[llength $options] % 2} {
	    Warn "invalid TCLTEST_OPTIONS: \"$options\":\n  should be\
		    -option value ?-option value ...?"
	    return
	}
	if {[catch {Configure {*}$options} msg]} {
	    Warn "invalid TCLTEST_OPTIONS: \"$options\":\n  $msg"
	    return
	}
    }
    if {[info exists ::env(TCLTEST_OPTIONS)]} {
	ConfigureFromEnvironment
    }
Changes to library/tzdata/Africa/Casablanca.
19
20
21
22
23
24
25


26
    {244249200 0 0 WET}
    {265507200 3600 1 WEST}
    {271033200 0 0 WET}
    {448243200 3600 0 CET}
    {504918000 0 0 WET}
    {1212278400 3600 1 WEST}
    {1220223600 0 0 WET}


}







>
>

19
20
21
22
23
24
25
26
27
28
    {244249200 0 0 WET}
    {265507200 3600 1 WEST}
    {271033200 0 0 WET}
    {448243200 3600 0 CET}
    {504918000 0 0 WET}
    {1212278400 3600 1 WEST}
    {1220223600 0 0 WET}
    {1243814400 3600 1 WEST}
    {1250809200 0 0 WET}
}
Changes to library/tzdata/Africa/Tunis.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    {1128038400 3600 0 CET}
    {1143334800 7200 1 CEST}
    {1162083600 3600 0 CET}
    {1174784400 7200 1 CEST}
    {1193533200 3600 0 CET}
    {1206838800 7200 1 CEST}
    {1224982800 3600 0 CET}
    {1238288400 7200 1 CEST}
    {1256432400 3600 0 CET}
    {1269738000 7200 1 CEST}
    {1288486800 3600 0 CET}
    {1301187600 7200 1 CEST}
    {1319936400 3600 0 CET}
    {1332637200 7200 1 CEST}
    {1351386000 3600 0 CET}
    {1364691600 7200 1 CEST}







<
<







32
33
34
35
36
37
38


39
40
41
42
43
44
45
    {1128038400 3600 0 CET}
    {1143334800 7200 1 CEST}
    {1162083600 3600 0 CET}
    {1174784400 7200 1 CEST}
    {1193533200 3600 0 CET}
    {1206838800 7200 1 CEST}
    {1224982800 3600 0 CET}


    {1269738000 7200 1 CEST}
    {1288486800 3600 0 CET}
    {1301187600 7200 1 CEST}
    {1319936400 3600 0 CET}
    {1332637200 7200 1 CEST}
    {1351386000 3600 0 CET}
    {1364691600 7200 1 CEST}
Changes to library/tzdata/America/Argentina/San_Luis.
57
58
59
60
61
62
63























































































































































































64
    {675748800 -10800 0 ART}
    {938919600 -10800 1 WARST}
    {952052400 -10800 0 ART}
    {1085972400 -14400 0 WART}
    {1090728000 -10800 0 ART}
    {1198983600 -7200 1 ARST}
    {1200880800 -10800 0 ART}























































































































































































}







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

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
    {675748800 -10800 0 ART}
    {938919600 -10800 1 WARST}
    {952052400 -10800 0 ART}
    {1085972400 -14400 0 WART}
    {1090728000 -10800 0 ART}
    {1198983600 -7200 1 ARST}
    {1200880800 -10800 0 ART}
    {1237086000 -14400 0 WART}
    {1237089600 -14400 0 WART}
    {1255838400 -10800 1 WARST}
    {1269140400 -14400 0 WART}
    {1287288000 -10800 1 WARST}
    {1300590000 -14400 0 WART}
    {1318737600 -10800 1 WARST}
    {1332039600 -14400 0 WART}
    {1350792000 -10800 1 WARST}
    {1363489200 -14400 0 WART}
    {1382241600 -10800 1 WARST}
    {1394938800 -14400 0 WART}
    {1413691200 -10800 1 WARST}
    {1426388400 -14400 0 WART}
    {1445140800 -10800 1 WARST}
    {1458442800 -14400 0 WART}
    {1476590400 -10800 1 WARST}
    {1489892400 -14400 0 WART}
    {1508040000 -10800 1 WARST}
    {1521342000 -14400 0 WART}
    {1540094400 -10800 1 WARST}
    {1552791600 -14400 0 WART}
    {1571544000 -10800 1 WARST}
    {1584241200 -14400 0 WART}
    {1602993600 -10800 1 WARST}
    {1616295600 -14400 0 WART}
    {1634443200 -10800 1 WARST}
    {1647745200 -14400 0 WART}
    {1665892800 -10800 1 WARST}
    {1679194800 -14400 0 WART}
    {1697342400 -10800 1 WARST}
    {1710644400 -14400 0 WART}
    {1729396800 -10800 1 WARST}
    {1742094000 -14400 0 WART}
    {1760846400 -10800 1 WARST}
    {1773543600 -14400 0 WART}
    {1792296000 -10800 1 WARST}
    {1805598000 -14400 0 WART}
    {1823745600 -10800 1 WARST}
    {1837047600 -14400 0 WART}
    {1855195200 -10800 1 WARST}
    {1868497200 -14400 0 WART}
    {1887249600 -10800 1 WARST}
    {1899946800 -14400 0 WART}
    {1918699200 -10800 1 WARST}
    {1931396400 -14400 0 WART}
    {1950148800 -10800 1 WARST}
    {1963450800 -14400 0 WART}
    {1981598400 -10800 1 WARST}
    {1994900400 -14400 0 WART}
    {2013048000 -10800 1 WARST}
    {2026350000 -14400 0 WART}
    {2044497600 -10800 1 WARST}
    {2057799600 -14400 0 WART}
    {2076552000 -10800 1 WARST}
    {2089249200 -14400 0 WART}
    {2108001600 -10800 1 WARST}
    {2120698800 -14400 0 WART}
    {2139451200 -10800 1 WARST}
    {2152753200 -14400 0 WART}
    {2170900800 -10800 1 WARST}
    {2184202800 -14400 0 WART}
    {2202350400 -10800 1 WARST}
    {2215652400 -14400 0 WART}
    {2234404800 -10800 1 WARST}
    {2247102000 -14400 0 WART}
    {2265854400 -10800 1 WARST}
    {2278551600 -14400 0 WART}
    {2297304000 -10800 1 WARST}
    {2310001200 -14400 0 WART}
    {2328753600 -10800 1 WARST}
    {2342055600 -14400 0 WART}
    {2360203200 -10800 1 WARST}
    {2373505200 -14400 0 WART}
    {2391652800 -10800 1 WARST}
    {2404954800 -14400 0 WART}
    {2423707200 -10800 1 WARST}
    {2436404400 -14400 0 WART}
    {2455156800 -10800 1 WARST}
    {2467854000 -14400 0 WART}
    {2486606400 -10800 1 WARST}
    {2499908400 -14400 0 WART}
    {2518056000 -10800 1 WARST}
    {2531358000 -14400 0 WART}
    {2549505600 -10800 1 WARST}
    {2562807600 -14400 0 WART}
    {2580955200 -10800 1 WARST}
    {2594257200 -14400 0 WART}
    {2613009600 -10800 1 WARST}
    {2625706800 -14400 0 WART}
    {2644459200 -10800 1 WARST}
    {2657156400 -14400 0 WART}
    {2675908800 -10800 1 WARST}
    {2689210800 -14400 0 WART}
    {2707358400 -10800 1 WARST}
    {2720660400 -14400 0 WART}
    {2738808000 -10800 1 WARST}
    {2752110000 -14400 0 WART}
    {2770862400 -10800 1 WARST}
    {2783559600 -14400 0 WART}
    {2802312000 -10800 1 WARST}
    {2815009200 -14400 0 WART}
    {2833761600 -10800 1 WARST}
    {2847063600 -14400 0 WART}
    {2865211200 -10800 1 WARST}
    {2878513200 -14400 0 WART}
    {2896660800 -10800 1 WARST}
    {2909962800 -14400 0 WART}
    {2928110400 -10800 1 WARST}
    {2941412400 -14400 0 WART}
    {2960164800 -10800 1 WARST}
    {2972862000 -14400 0 WART}
    {2991614400 -10800 1 WARST}
    {3004311600 -14400 0 WART}
    {3023064000 -10800 1 WARST}
    {3036366000 -14400 0 WART}
    {3054513600 -10800 1 WARST}
    {3067815600 -14400 0 WART}
    {3085963200 -10800 1 WARST}
    {3099265200 -14400 0 WART}
    {3118017600 -10800 1 WARST}
    {3130714800 -14400 0 WART}
    {3149467200 -10800 1 WARST}
    {3162164400 -14400 0 WART}
    {3180916800 -10800 1 WARST}
    {3193614000 -14400 0 WART}
    {3212366400 -10800 1 WARST}
    {3225668400 -14400 0 WART}
    {3243816000 -10800 1 WARST}
    {3257118000 -14400 0 WART}
    {3275265600 -10800 1 WARST}
    {3288567600 -14400 0 WART}
    {3307320000 -10800 1 WARST}
    {3320017200 -14400 0 WART}
    {3338769600 -10800 1 WARST}
    {3351466800 -14400 0 WART}
    {3370219200 -10800 1 WARST}
    {3383521200 -14400 0 WART}
    {3401668800 -10800 1 WARST}
    {3414970800 -14400 0 WART}
    {3433118400 -10800 1 WARST}
    {3446420400 -14400 0 WART}
    {3464568000 -10800 1 WARST}
    {3477870000 -14400 0 WART}
    {3496622400 -10800 1 WARST}
    {3509319600 -14400 0 WART}
    {3528072000 -10800 1 WARST}
    {3540769200 -14400 0 WART}
    {3559521600 -10800 1 WARST}
    {3572823600 -14400 0 WART}
    {3590971200 -10800 1 WARST}
    {3604273200 -14400 0 WART}
    {3622420800 -10800 1 WARST}
    {3635722800 -14400 0 WART}
    {3654475200 -10800 1 WARST}
    {3667172400 -14400 0 WART}
    {3685924800 -10800 1 WARST}
    {3698622000 -14400 0 WART}
    {3717374400 -10800 1 WARST}
    {3730676400 -14400 0 WART}
    {3748824000 -10800 1 WARST}
    {3762126000 -14400 0 WART}
    {3780273600 -10800 1 WARST}
    {3793575600 -14400 0 WART}
    {3811723200 -10800 1 WARST}
    {3825025200 -14400 0 WART}
    {3843777600 -10800 1 WARST}
    {3856474800 -14400 0 WART}
    {3875227200 -10800 1 WARST}
    {3887924400 -14400 0 WART}
    {3906676800 -10800 1 WARST}
    {3919978800 -14400 0 WART}
    {3938126400 -10800 1 WARST}
    {3951428400 -14400 0 WART}
    {3969576000 -10800 1 WARST}
    {3982878000 -14400 0 WART}
    {4001630400 -10800 1 WARST}
    {4014327600 -14400 0 WART}
    {4033080000 -10800 1 WARST}
    {4045777200 -14400 0 WART}
    {4064529600 -10800 1 WARST}
    {4077226800 -14400 0 WART}
    {4095979200 -10800 1 WARST}
}
Changes to library/tzdata/America/Havana.
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
    {986101200 -14400 1 CDT}
    {1004245200 -18000 0 CST}
    {1018155600 -14400 1 CDT}
    {1035694800 -18000 0 CST}
    {1049605200 -14400 1 CDT}
    {1067144400 -18000 0 CST}
    {1081054800 -14400 1 CDT}
    {1112504400 -14400 1 CDT}
    {1143954000 -14400 1 CDT}
    {1162098000 -18000 0 CST}
    {1173589200 -14400 1 CDT}
    {1193547600 -18000 0 CST}
    {1205643600 -14400 1 CDT}
    {1224997200 -18000 0 CST}
    {1237093200 -14400 1 CDT}
    {1256446800 -18000 0 CST}
    {1269147600 -14400 1 CDT}
    {1288501200 -18000 0 CST}
    {1300597200 -14400 1 CDT}
    {1319950800 -18000 0 CST}
    {1332046800 -14400 1 CDT}
    {1351400400 -18000 0 CST}
    {1363496400 -14400 1 CDT}
    {1382850000 -18000 0 CST}
    {1394946000 -14400 1 CDT}
    {1414299600 -18000 0 CST}
    {1426395600 -14400 1 CDT}
    {1445749200 -18000 0 CST}
    {1458450000 -14400 1 CDT}
    {1477803600 -18000 0 CST}
    {1489899600 -14400 1 CDT}
    {1509253200 -18000 0 CST}
    {1521349200 -14400 1 CDT}
    {1540702800 -18000 0 CST}
    {1552798800 -14400 1 CDT}
    {1572152400 -18000 0 CST}
    {1584248400 -14400 1 CDT}
    {1603602000 -18000 0 CST}
    {1616302800 -14400 1 CDT}
    {1635656400 -18000 0 CST}
    {1647752400 -14400 1 CDT}
    {1667106000 -18000 0 CST}
    {1679202000 -14400 1 CDT}
    {1698555600 -18000 0 CST}
    {1710651600 -14400 1 CDT}
    {1730005200 -18000 0 CST}
    {1742101200 -14400 1 CDT}
    {1761454800 -18000 0 CST}
    {1773550800 -14400 1 CDT}
    {1792904400 -18000 0 CST}
    {1805605200 -14400 1 CDT}
    {1824958800 -18000 0 CST}
    {1837054800 -14400 1 CDT}
    {1856408400 -18000 0 CST}
    {1868504400 -14400 1 CDT}
    {1887858000 -18000 0 CST}
    {1899954000 -14400 1 CDT}
    {1919307600 -18000 0 CST}
    {1931403600 -14400 1 CDT}
    {1950757200 -18000 0 CST}
    {1963458000 -14400 1 CDT}
    {1982811600 -18000 0 CST}
    {1994907600 -14400 1 CDT}
    {2014261200 -18000 0 CST}
    {2026357200 -14400 1 CDT}
    {2045710800 -18000 0 CST}
    {2057806800 -14400 1 CDT}
    {2077160400 -18000 0 CST}
    {2089256400 -14400 1 CDT}
    {2108610000 -18000 0 CST}
    {2120706000 -14400 1 CDT}
    {2140059600 -18000 0 CST}
    {2152760400 -14400 1 CDT}
    {2172114000 -18000 0 CST}
    {2184210000 -14400 1 CDT}
    {2203563600 -18000 0 CST}
    {2215659600 -14400 1 CDT}
    {2235013200 -18000 0 CST}
    {2247109200 -14400 1 CDT}
    {2266462800 -18000 0 CST}
    {2278558800 -14400 1 CDT}
    {2297912400 -18000 0 CST}
    {2310008400 -14400 1 CDT}
    {2329362000 -18000 0 CST}
    {2342062800 -14400 1 CDT}
    {2361416400 -18000 0 CST}
    {2373512400 -14400 1 CDT}
    {2392866000 -18000 0 CST}
    {2404962000 -14400 1 CDT}
    {2424315600 -18000 0 CST}
    {2436411600 -14400 1 CDT}
    {2455765200 -18000 0 CST}
    {2467861200 -14400 1 CDT}
    {2487214800 -18000 0 CST}
    {2499915600 -14400 1 CDT}
    {2519269200 -18000 0 CST}
    {2531365200 -14400 1 CDT}
    {2550718800 -18000 0 CST}
    {2562814800 -14400 1 CDT}
    {2582168400 -18000 0 CST}
    {2594264400 -14400 1 CDT}
    {2613618000 -18000 0 CST}
    {2625714000 -14400 1 CDT}
    {2645067600 -18000 0 CST}
    {2657163600 -14400 1 CDT}
    {2676517200 -18000 0 CST}
    {2689218000 -14400 1 CDT}
    {2708571600 -18000 0 CST}
    {2720667600 -14400 1 CDT}
    {2740021200 -18000 0 CST}
    {2752117200 -14400 1 CDT}
    {2771470800 -18000 0 CST}
    {2783566800 -14400 1 CDT}
    {2802920400 -18000 0 CST}
    {2815016400 -14400 1 CDT}
    {2834370000 -18000 0 CST}
    {2847070800 -14400 1 CDT}
    {2866424400 -18000 0 CST}
    {2878520400 -14400 1 CDT}
    {2897874000 -18000 0 CST}
    {2909970000 -14400 1 CDT}
    {2929323600 -18000 0 CST}
    {2941419600 -14400 1 CDT}
    {2960773200 -18000 0 CST}
    {2972869200 -14400 1 CDT}
    {2992222800 -18000 0 CST}
    {3004318800 -14400 1 CDT}
    {3023672400 -18000 0 CST}
    {3036373200 -14400 1 CDT}
    {3055726800 -18000 0 CST}
    {3067822800 -14400 1 CDT}
    {3087176400 -18000 0 CST}
    {3099272400 -14400 1 CDT}
    {3118626000 -18000 0 CST}
    {3130722000 -14400 1 CDT}
    {3150075600 -18000 0 CST}
    {3162171600 -14400 1 CDT}
    {3181525200 -18000 0 CST}
    {3193621200 -14400 1 CDT}
    {3212974800 -18000 0 CST}
    {3225675600 -14400 1 CDT}
    {3245029200 -18000 0 CST}
    {3257125200 -14400 1 CDT}
    {3276478800 -18000 0 CST}
    {3288574800 -14400 1 CDT}
    {3307928400 -18000 0 CST}
    {3320024400 -14400 1 CDT}
    {3339378000 -18000 0 CST}
    {3351474000 -14400 1 CDT}
    {3370827600 -18000 0 CST}
    {3383528400 -14400 1 CDT}
    {3402882000 -18000 0 CST}
    {3414978000 -14400 1 CDT}
    {3434331600 -18000 0 CST}
    {3446427600 -14400 1 CDT}
    {3465781200 -18000 0 CST}
    {3477877200 -14400 1 CDT}
    {3497230800 -18000 0 CST}
    {3509326800 -14400 1 CDT}
    {3528680400 -18000 0 CST}
    {3540776400 -14400 1 CDT}
    {3560130000 -18000 0 CST}
    {3572830800 -14400 1 CDT}
    {3592184400 -18000 0 CST}
    {3604280400 -14400 1 CDT}
    {3623634000 -18000 0 CST}
    {3635730000 -14400 1 CDT}
    {3655083600 -18000 0 CST}
    {3667179600 -14400 1 CDT}
    {3686533200 -18000 0 CST}
    {3698629200 -14400 1 CDT}
    {3717982800 -18000 0 CST}
    {3730683600 -14400 1 CDT}
    {3750037200 -18000 0 CST}
    {3762133200 -14400 1 CDT}
    {3781486800 -18000 0 CST}
    {3793582800 -14400 1 CDT}
    {3812936400 -18000 0 CST}
    {3825032400 -14400 1 CDT}
    {3844386000 -18000 0 CST}
    {3856482000 -14400 1 CDT}
    {3875835600 -18000 0 CST}
    {3887931600 -14400 1 CDT}
    {3907285200 -18000 0 CST}
    {3919986000 -14400 1 CDT}
    {3939339600 -18000 0 CST}
    {3951435600 -14400 1 CDT}
    {3970789200 -18000 0 CST}
    {3982885200 -14400 1 CDT}
    {4002238800 -18000 0 CST}
    {4014334800 -14400 1 CDT}
    {4033688400 -18000 0 CST}
    {4045784400 -14400 1 CDT}
    {4065138000 -18000 0 CST}
    {4077234000 -14400 1 CDT}
    {4096587600 -18000 0 CST}
}







<
<





|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|


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
    {986101200 -14400 1 CDT}
    {1004245200 -18000 0 CST}
    {1018155600 -14400 1 CDT}
    {1035694800 -18000 0 CST}
    {1049605200 -14400 1 CDT}
    {1067144400 -18000 0 CST}
    {1081054800 -14400 1 CDT}


    {1162098000 -18000 0 CST}
    {1173589200 -14400 1 CDT}
    {1193547600 -18000 0 CST}
    {1205643600 -14400 1 CDT}
    {1224997200 -18000 0 CST}
    {1236488400 -14400 1 CDT}
    {1256446800 -18000 0 CST}
    {1268542800 -14400 1 CDT}
    {1288501200 -18000 0 CST}
    {1299992400 -14400 1 CDT}
    {1319950800 -18000 0 CST}
    {1331442000 -14400 1 CDT}
    {1351400400 -18000 0 CST}
    {1362891600 -14400 1 CDT}
    {1382850000 -18000 0 CST}
    {1394341200 -14400 1 CDT}
    {1414299600 -18000 0 CST}
    {1425790800 -14400 1 CDT}
    {1445749200 -18000 0 CST}
    {1457845200 -14400 1 CDT}
    {1477803600 -18000 0 CST}
    {1489294800 -14400 1 CDT}
    {1509253200 -18000 0 CST}
    {1520744400 -14400 1 CDT}
    {1540702800 -18000 0 CST}
    {1552194000 -14400 1 CDT}
    {1572152400 -18000 0 CST}
    {1583643600 -14400 1 CDT}
    {1603602000 -18000 0 CST}
    {1615698000 -14400 1 CDT}
    {1635656400 -18000 0 CST}
    {1647147600 -14400 1 CDT}
    {1667106000 -18000 0 CST}
    {1678597200 -14400 1 CDT}
    {1698555600 -18000 0 CST}
    {1710046800 -14400 1 CDT}
    {1730005200 -18000 0 CST}
    {1741496400 -14400 1 CDT}
    {1761454800 -18000 0 CST}
    {1772946000 -14400 1 CDT}
    {1792904400 -18000 0 CST}
    {1805000400 -14400 1 CDT}
    {1824958800 -18000 0 CST}
    {1836450000 -14400 1 CDT}
    {1856408400 -18000 0 CST}
    {1867899600 -14400 1 CDT}
    {1887858000 -18000 0 CST}
    {1899349200 -14400 1 CDT}
    {1919307600 -18000 0 CST}
    {1930798800 -14400 1 CDT}
    {1950757200 -18000 0 CST}
    {1962853200 -14400 1 CDT}
    {1982811600 -18000 0 CST}
    {1994302800 -14400 1 CDT}
    {2014261200 -18000 0 CST}
    {2025752400 -14400 1 CDT}
    {2045710800 -18000 0 CST}
    {2057202000 -14400 1 CDT}
    {2077160400 -18000 0 CST}
    {2088651600 -14400 1 CDT}
    {2108610000 -18000 0 CST}
    {2120101200 -14400 1 CDT}
    {2140059600 -18000 0 CST}
    {2152155600 -14400 1 CDT}
    {2172114000 -18000 0 CST}
    {2183605200 -14400 1 CDT}
    {2203563600 -18000 0 CST}
    {2215054800 -14400 1 CDT}
    {2235013200 -18000 0 CST}
    {2246504400 -14400 1 CDT}
    {2266462800 -18000 0 CST}
    {2277954000 -14400 1 CDT}
    {2297912400 -18000 0 CST}
    {2309403600 -14400 1 CDT}
    {2329362000 -18000 0 CST}
    {2341458000 -14400 1 CDT}
    {2361416400 -18000 0 CST}
    {2372907600 -14400 1 CDT}
    {2392866000 -18000 0 CST}
    {2404357200 -14400 1 CDT}
    {2424315600 -18000 0 CST}
    {2435806800 -14400 1 CDT}
    {2455765200 -18000 0 CST}
    {2467256400 -14400 1 CDT}
    {2487214800 -18000 0 CST}
    {2499310800 -14400 1 CDT}
    {2519269200 -18000 0 CST}
    {2530760400 -14400 1 CDT}
    {2550718800 -18000 0 CST}
    {2562210000 -14400 1 CDT}
    {2582168400 -18000 0 CST}
    {2593659600 -14400 1 CDT}
    {2613618000 -18000 0 CST}
    {2625109200 -14400 1 CDT}
    {2645067600 -18000 0 CST}
    {2656558800 -14400 1 CDT}
    {2676517200 -18000 0 CST}
    {2688613200 -14400 1 CDT}
    {2708571600 -18000 0 CST}
    {2720062800 -14400 1 CDT}
    {2740021200 -18000 0 CST}
    {2751512400 -14400 1 CDT}
    {2771470800 -18000 0 CST}
    {2782962000 -14400 1 CDT}
    {2802920400 -18000 0 CST}
    {2814411600 -14400 1 CDT}
    {2834370000 -18000 0 CST}
    {2846466000 -14400 1 CDT}
    {2866424400 -18000 0 CST}
    {2877915600 -14400 1 CDT}
    {2897874000 -18000 0 CST}
    {2909365200 -14400 1 CDT}
    {2929323600 -18000 0 CST}
    {2940814800 -14400 1 CDT}
    {2960773200 -18000 0 CST}
    {2972264400 -14400 1 CDT}
    {2992222800 -18000 0 CST}
    {3003714000 -14400 1 CDT}
    {3023672400 -18000 0 CST}
    {3035768400 -14400 1 CDT}
    {3055726800 -18000 0 CST}
    {3067218000 -14400 1 CDT}
    {3087176400 -18000 0 CST}
    {3098667600 -14400 1 CDT}
    {3118626000 -18000 0 CST}
    {3130117200 -14400 1 CDT}
    {3150075600 -18000 0 CST}
    {3161566800 -14400 1 CDT}
    {3181525200 -18000 0 CST}
    {3193016400 -14400 1 CDT}
    {3212974800 -18000 0 CST}
    {3225070800 -14400 1 CDT}
    {3245029200 -18000 0 CST}
    {3256520400 -14400 1 CDT}
    {3276478800 -18000 0 CST}
    {3287970000 -14400 1 CDT}
    {3307928400 -18000 0 CST}
    {3319419600 -14400 1 CDT}
    {3339378000 -18000 0 CST}
    {3350869200 -14400 1 CDT}
    {3370827600 -18000 0 CST}
    {3382923600 -14400 1 CDT}
    {3402882000 -18000 0 CST}
    {3414373200 -14400 1 CDT}
    {3434331600 -18000 0 CST}
    {3445822800 -14400 1 CDT}
    {3465781200 -18000 0 CST}
    {3477272400 -14400 1 CDT}
    {3497230800 -18000 0 CST}
    {3508722000 -14400 1 CDT}
    {3528680400 -18000 0 CST}
    {3540171600 -14400 1 CDT}
    {3560130000 -18000 0 CST}
    {3572226000 -14400 1 CDT}
    {3592184400 -18000 0 CST}
    {3603675600 -14400 1 CDT}
    {3623634000 -18000 0 CST}
    {3635125200 -14400 1 CDT}
    {3655083600 -18000 0 CST}
    {3666574800 -14400 1 CDT}
    {3686533200 -18000 0 CST}
    {3698024400 -14400 1 CDT}
    {3717982800 -18000 0 CST}
    {3730078800 -14400 1 CDT}
    {3750037200 -18000 0 CST}
    {3761528400 -14400 1 CDT}
    {3781486800 -18000 0 CST}
    {3792978000 -14400 1 CDT}
    {3812936400 -18000 0 CST}
    {3824427600 -14400 1 CDT}
    {3844386000 -18000 0 CST}
    {3855877200 -14400 1 CDT}
    {3875835600 -18000 0 CST}
    {3887326800 -14400 1 CDT}
    {3907285200 -18000 0 CST}
    {3919381200 -14400 1 CDT}
    {3939339600 -18000 0 CST}
    {3950830800 -14400 1 CDT}
    {3970789200 -18000 0 CST}
    {3982280400 -14400 1 CDT}
    {4002238800 -18000 0 CST}
    {4013730000 -14400 1 CDT}
    {4033688400 -18000 0 CST}
    {4045179600 -14400 1 CDT}
    {4065138000 -18000 0 CST}
    {4076629200 -14400 1 CDT}
    {4096587600 -18000 0 CST}
}
Changes to library/tzdata/America/Resolute.
55
56
57
58
59
60
61



























































































































































































62
    {1067151600 -21600 0 CST}
    {1081065600 -18000 1 CDT}
    {1099206000 -21600 0 CST}
    {1112515200 -18000 1 CDT}
    {1130655600 -21600 0 CST}
    {1143964800 -18000 1 CDT}
    {1162108800 -18000 0 EST}



























































































































































































}







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

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
    {1067151600 -21600 0 CST}
    {1081065600 -18000 1 CDT}
    {1099206000 -21600 0 CST}
    {1112515200 -18000 1 CDT}
    {1130655600 -21600 0 CST}
    {1143964800 -18000 1 CDT}
    {1162108800 -18000 0 EST}
    {1162710000 -18000 0 EST}
    {1173596400 -18000 0 CDT}
    {1194159600 -18000 0 EST}
    {1205046000 -18000 0 CDT}
    {1225609200 -18000 0 EST}
    {1236495600 -18000 0 CDT}
    {1257058800 -18000 0 EST}
    {1268550000 -18000 0 CDT}
    {1289113200 -18000 0 EST}
    {1299999600 -18000 0 CDT}
    {1320562800 -18000 0 EST}
    {1331449200 -18000 0 CDT}
    {1352012400 -18000 0 EST}
    {1362898800 -18000 0 CDT}
    {1383462000 -18000 0 EST}
    {1394348400 -18000 0 CDT}
    {1414911600 -18000 0 EST}
    {1425798000 -18000 0 CDT}
    {1446361200 -18000 0 EST}
    {1457852400 -18000 0 CDT}
    {1478415600 -18000 0 EST}
    {1489302000 -18000 0 CDT}
    {1509865200 -18000 0 EST}
    {1520751600 -18000 0 CDT}
    {1541314800 -18000 0 EST}
    {1552201200 -18000 0 CDT}
    {1572764400 -18000 0 EST}
    {1583650800 -18000 0 CDT}
    {1604214000 -18000 0 EST}
    {1615705200 -18000 0 CDT}
    {1636268400 -18000 0 EST}
    {1647154800 -18000 0 CDT}
    {1667718000 -18000 0 EST}
    {1678604400 -18000 0 CDT}
    {1699167600 -18000 0 EST}
    {1710054000 -18000 0 CDT}
    {1730617200 -18000 0 EST}
    {1741503600 -18000 0 CDT}
    {1762066800 -18000 0 EST}
    {1772953200 -18000 0 CDT}
    {1793516400 -18000 0 EST}
    {1805007600 -18000 0 CDT}
    {1825570800 -18000 0 EST}
    {1836457200 -18000 0 CDT}
    {1857020400 -18000 0 EST}
    {1867906800 -18000 0 CDT}
    {1888470000 -18000 0 EST}
    {1899356400 -18000 0 CDT}
    {1919919600 -18000 0 EST}
    {1930806000 -18000 0 CDT}
    {1951369200 -18000 0 EST}
    {1962860400 -18000 0 CDT}
    {1983423600 -18000 0 EST}
    {1994310000 -18000 0 CDT}
    {2014873200 -18000 0 EST}
    {2025759600 -18000 0 CDT}
    {2046322800 -18000 0 EST}
    {2057209200 -18000 0 CDT}
    {2077772400 -18000 0 EST}
    {2088658800 -18000 0 CDT}
    {2109222000 -18000 0 EST}
    {2120108400 -18000 0 CDT}
    {2140671600 -18000 0 EST}
    {2152162800 -18000 0 CDT}
    {2172726000 -18000 0 EST}
    {2183612400 -18000 0 CDT}
    {2204175600 -18000 0 EST}
    {2215062000 -18000 0 CDT}
    {2235625200 -18000 0 EST}
    {2246511600 -18000 0 CDT}
    {2267074800 -18000 0 EST}
    {2277961200 -18000 0 CDT}
    {2298524400 -18000 0 EST}
    {2309410800 -18000 0 CDT}
    {2329974000 -18000 0 EST}
    {2341465200 -18000 0 CDT}
    {2362028400 -18000 0 EST}
    {2372914800 -18000 0 CDT}
    {2393478000 -18000 0 EST}
    {2404364400 -18000 0 CDT}
    {2424927600 -18000 0 EST}
    {2435814000 -18000 0 CDT}
    {2456377200 -18000 0 EST}
    {2467263600 -18000 0 CDT}
    {2487826800 -18000 0 EST}
    {2499318000 -18000 0 CDT}
    {2519881200 -18000 0 EST}
    {2530767600 -18000 0 CDT}
    {2551330800 -18000 0 EST}
    {2562217200 -18000 0 CDT}
    {2582780400 -18000 0 EST}
    {2593666800 -18000 0 CDT}
    {2614230000 -18000 0 EST}
    {2625116400 -18000 0 CDT}
    {2645679600 -18000 0 EST}
    {2656566000 -18000 0 CDT}
    {2677129200 -18000 0 EST}
    {2688620400 -18000 0 CDT}
    {2709183600 -18000 0 EST}
    {2720070000 -18000 0 CDT}
    {2740633200 -18000 0 EST}
    {2751519600 -18000 0 CDT}
    {2772082800 -18000 0 EST}
    {2782969200 -18000 0 CDT}
    {2803532400 -18000 0 EST}
    {2814418800 -18000 0 CDT}
    {2834982000 -18000 0 EST}
    {2846473200 -18000 0 CDT}
    {2867036400 -18000 0 EST}
    {2877922800 -18000 0 CDT}
    {2898486000 -18000 0 EST}
    {2909372400 -18000 0 CDT}
    {2929935600 -18000 0 EST}
    {2940822000 -18000 0 CDT}
    {2961385200 -18000 0 EST}
    {2972271600 -18000 0 CDT}
    {2992834800 -18000 0 EST}
    {3003721200 -18000 0 CDT}
    {3024284400 -18000 0 EST}
    {3035775600 -18000 0 CDT}
    {3056338800 -18000 0 EST}
    {3067225200 -18000 0 CDT}
    {3087788400 -18000 0 EST}
    {3098674800 -18000 0 CDT}
    {3119238000 -18000 0 EST}
    {3130124400 -18000 0 CDT}
    {3150687600 -18000 0 EST}
    {3161574000 -18000 0 CDT}
    {3182137200 -18000 0 EST}
    {3193023600 -18000 0 CDT}
    {3213586800 -18000 0 EST}
    {3225078000 -18000 0 CDT}
    {3245641200 -18000 0 EST}
    {3256527600 -18000 0 CDT}
    {3277090800 -18000 0 EST}
    {3287977200 -18000 0 CDT}
    {3308540400 -18000 0 EST}
    {3319426800 -18000 0 CDT}
    {3339990000 -18000 0 EST}
    {3350876400 -18000 0 CDT}
    {3371439600 -18000 0 EST}
    {3382930800 -18000 0 CDT}
    {3403494000 -18000 0 EST}
    {3414380400 -18000 0 CDT}
    {3434943600 -18000 0 EST}
    {3445830000 -18000 0 CDT}
    {3466393200 -18000 0 EST}
    {3477279600 -18000 0 CDT}
    {3497842800 -18000 0 EST}
    {3508729200 -18000 0 CDT}
    {3529292400 -18000 0 EST}
    {3540178800 -18000 0 CDT}
    {3560742000 -18000 0 EST}
    {3572233200 -18000 0 CDT}
    {3592796400 -18000 0 EST}
    {3603682800 -18000 0 CDT}
    {3624246000 -18000 0 EST}
    {3635132400 -18000 0 CDT}
    {3655695600 -18000 0 EST}
    {3666582000 -18000 0 CDT}
    {3687145200 -18000 0 EST}
    {3698031600 -18000 0 CDT}
    {3718594800 -18000 0 EST}
    {3730086000 -18000 0 CDT}
    {3750649200 -18000 0 EST}
    {3761535600 -18000 0 CDT}
    {3782098800 -18000 0 EST}
    {3792985200 -18000 0 CDT}
    {3813548400 -18000 0 EST}
    {3824434800 -18000 0 CDT}
    {3844998000 -18000 0 EST}
    {3855884400 -18000 0 CDT}
    {3876447600 -18000 0 EST}
    {3887334000 -18000 0 CDT}
    {3907897200 -18000 0 EST}
    {3919388400 -18000 0 CDT}
    {3939951600 -18000 0 EST}
    {3950838000 -18000 0 CDT}
    {3971401200 -18000 0 EST}
    {3982287600 -18000 0 CDT}
    {4002850800 -18000 0 EST}
    {4013737200 -18000 0 CDT}
    {4034300400 -18000 0 EST}
    {4045186800 -18000 0 CDT}
    {4065750000 -18000 0 EST}
    {4076636400 -18000 0 CDT}
    {4097199600 -18000 0 EST}
}
Changes to library/tzdata/Asia/Amman.
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
    {828655200 10800 1 EEST}
    {843170400 7200 0 EET}
    {860104800 10800 1 EEST}
    {874620000 7200 0 EET}
    {891554400 10800 1 EEST}
    {906069600 7200 0 EET}
    {930780000 10800 1 EEST}
    {938642400 7200 0 EET}
    {954367200 10800 1 EEST}
    {970092000 7200 0 EET}
    {985816800 10800 1 EEST}
    {1001541600 7200 0 EET}
    {1017266400 10800 1 EEST}
    {1032991200 7200 0 EET}
    {1048716000 10800 1 EEST}
    {1066946400 7200 0 EET}
    {1080165600 10800 1 EEST}
    {1097791200 7200 0 EET}
    {1112220000 10800 1 EEST}
    {1128031200 7200 0 EET}
    {1143669600 10800 1 EEST}
    {1161900000 7200 0 EET}
    {1175119200 10800 1 EEST}
    {1193349600 7200 0 EET}
    {1206568800 10800 1 EEST}
    {1225404000 7200 0 EET}
    {1238018400 10800 1 EEST}
    {1256853600 7200 0 EET}
    {1269468000 10800 1 EEST}
    {1288303200 7200 0 EET}
    {1301522400 10800 1 EEST}
    {1319752800 7200 0 EET}
    {1332972000 10800 1 EEST}
    {1351202400 7200 0 EET}
    {1364421600 10800 1 EEST}
    {1382652000 7200 0 EET}
    {1395871200 10800 1 EEST}
    {1414706400 7200 0 EET}
    {1427320800 10800 1 EEST}
    {1446156000 7200 0 EET}
    {1459375200 10800 1 EEST}
    {1477605600 7200 0 EET}
    {1490824800 10800 1 EEST}
    {1509055200 7200 0 EET}
    {1522274400 10800 1 EEST}
    {1540504800 7200 0 EET}
    {1553724000 10800 1 EEST}
    {1571954400 7200 0 EET}
    {1585173600 10800 1 EEST}
    {1604008800 7200 0 EET}
    {1616623200 10800 1 EEST}
    {1635458400 7200 0 EET}
    {1648677600 10800 1 EEST}
    {1666908000 7200 0 EET}
    {1680127200 10800 1 EEST}
    {1698357600 7200 0 EET}
    {1711576800 10800 1 EEST}
    {1729807200 7200 0 EET}
    {1743026400 10800 1 EEST}
    {1761861600 7200 0 EET}
    {1774476000 10800 1 EEST}
    {1793311200 7200 0 EET}
    {1805925600 10800 1 EEST}
    {1824760800 7200 0 EET}
    {1837980000 10800 1 EEST}
    {1856210400 7200 0 EET}
    {1869429600 10800 1 EEST}
    {1887660000 7200 0 EET}
    {1900879200 10800 1 EEST}
    {1919109600 7200 0 EET}
    {1932328800 10800 1 EEST}
    {1951164000 7200 0 EET}
    {1963778400 10800 1 EEST}
    {1982613600 7200 0 EET}
    {1995832800 10800 1 EEST}
    {2014063200 7200 0 EET}
    {2027282400 10800 1 EEST}
    {2045512800 7200 0 EET}
    {2058732000 10800 1 EEST}
    {2076962400 7200 0 EET}
    {2090181600 10800 1 EEST}
    {2109016800 7200 0 EET}
    {2121631200 10800 1 EEST}
    {2140466400 7200 0 EET}
    {2153080800 10800 1 EEST}
    {2171916000 7200 0 EET}
    {2185135200 10800 1 EEST}
    {2203365600 7200 0 EET}
    {2216584800 10800 1 EEST}
    {2234815200 7200 0 EET}
    {2248034400 10800 1 EEST}
    {2266264800 7200 0 EET}
    {2279484000 10800 1 EEST}
    {2298319200 7200 0 EET}
    {2310933600 10800 1 EEST}
    {2329768800 7200 0 EET}
    {2342988000 10800 1 EEST}
    {2361218400 7200 0 EET}
    {2374437600 10800 1 EEST}
    {2392668000 7200 0 EET}
    {2405887200 10800 1 EEST}
    {2424117600 7200 0 EET}
    {2437336800 10800 1 EEST}
    {2455567200 7200 0 EET}
    {2468786400 10800 1 EEST}
    {2487621600 7200 0 EET}
    {2500236000 10800 1 EEST}
    {2519071200 7200 0 EET}
    {2532290400 10800 1 EEST}
    {2550520800 7200 0 EET}
    {2563740000 10800 1 EEST}
    {2581970400 7200 0 EET}
    {2595189600 10800 1 EEST}
    {2613420000 7200 0 EET}
    {2626639200 10800 1 EEST}
    {2645474400 7200 0 EET}
    {2658088800 10800 1 EEST}
    {2676924000 7200 0 EET}
    {2689538400 10800 1 EEST}
    {2708373600 7200 0 EET}
    {2721592800 10800 1 EEST}
    {2739823200 7200 0 EET}
    {2753042400 10800 1 EEST}
    {2771272800 7200 0 EET}
    {2784492000 10800 1 EEST}
    {2802722400 7200 0 EET}
    {2815941600 10800 1 EEST}
    {2834776800 7200 0 EET}
    {2847391200 10800 1 EEST}
    {2866226400 7200 0 EET}
    {2879445600 10800 1 EEST}
    {2897676000 7200 0 EET}
    {2910895200 10800 1 EEST}
    {2929125600 7200 0 EET}
    {2942344800 10800 1 EEST}
    {2960575200 7200 0 EET}
    {2973794400 10800 1 EEST}
    {2992629600 7200 0 EET}
    {3005244000 10800 1 EEST}
    {3024079200 7200 0 EET}
    {3036693600 10800 1 EEST}
    {3055528800 7200 0 EET}
    {3068748000 10800 1 EEST}
    {3086978400 7200 0 EET}
    {3100197600 10800 1 EEST}
    {3118428000 7200 0 EET}
    {3131647200 10800 1 EEST}
    {3149877600 7200 0 EET}
    {3163096800 10800 1 EEST}
    {3181932000 7200 0 EET}
    {3194546400 10800 1 EEST}
    {3213381600 7200 0 EET}
    {3226600800 10800 1 EEST}
    {3244831200 7200 0 EET}
    {3258050400 10800 1 EEST}
    {3276280800 7200 0 EET}
    {3289500000 10800 1 EEST}
    {3307730400 7200 0 EET}
    {3320949600 10800 1 EEST}
    {3339180000 7200 0 EET}
    {3352399200 10800 1 EEST}
    {3371234400 7200 0 EET}
    {3383848800 10800 1 EEST}
    {3402684000 7200 0 EET}
    {3415903200 10800 1 EEST}
    {3434133600 7200 0 EET}
    {3447352800 10800 1 EEST}
    {3465583200 7200 0 EET}
    {3478802400 10800 1 EEST}
    {3497032800 7200 0 EET}
    {3510252000 10800 1 EEST}
    {3529087200 7200 0 EET}
    {3541701600 10800 1 EEST}
    {3560536800 7200 0 EET}
    {3573151200 10800 1 EEST}
    {3591986400 7200 0 EET}
    {3605205600 10800 1 EEST}
    {3623436000 7200 0 EET}
    {3636655200 10800 1 EEST}
    {3654885600 7200 0 EET}
    {3668104800 10800 1 EEST}
    {3686335200 7200 0 EET}
    {3699554400 10800 1 EEST}
    {3718389600 7200 0 EET}
    {3731004000 10800 1 EEST}
    {3749839200 7200 0 EET}
    {3763058400 10800 1 EEST}
    {3781288800 7200 0 EET}
    {3794508000 10800 1 EEST}
    {3812738400 7200 0 EET}
    {3825957600 10800 1 EEST}
    {3844188000 7200 0 EET}
    {3857407200 10800 1 EEST}
    {3876242400 7200 0 EET}
    {3888856800 10800 1 EEST}
    {3907692000 7200 0 EET}
    {3920306400 10800 1 EEST}
    {3939141600 7200 0 EET}
    {3952360800 10800 1 EEST}
    {3970591200 7200 0 EET}
    {3983810400 10800 1 EEST}
    {4002040800 7200 0 EET}
    {4015260000 10800 1 EEST}
    {4033490400 7200 0 EET}
    {4046709600 10800 1 EEST}
    {4065544800 7200 0 EET}
    {4078159200 10800 1 EEST}
    {4096994400 7200 0 EET}
}







|

|

|
|
|
|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|


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
    {828655200 10800 1 EEST}
    {843170400 7200 0 EET}
    {860104800 10800 1 EEST}
    {874620000 7200 0 EET}
    {891554400 10800 1 EEST}
    {906069600 7200 0 EET}
    {930780000 10800 1 EEST}
    {938124000 7200 0 EET}
    {954367200 10800 1 EEST}
    {970178400 7200 0 EET}
    {985816800 10800 1 EEST}
    {1001628000 7200 0 EET}
    {1017352800 10800 1 EEST}
    {1033077600 7200 0 EET}
    {1048802400 10800 1 EEST}
    {1066946400 7200 0 EET}
    {1080252000 10800 1 EEST}
    {1097791200 7200 0 EET}
    {1111701600 10800 1 EEST}
    {1128031200 7200 0 EET}
    {1143756000 10800 1 EEST}
    {1161900000 7200 0 EET}
    {1175205600 10800 1 EEST}
    {1193349600 7200 0 EET}
    {1206655200 10800 1 EEST}
    {1225404000 7200 0 EET}
    {1238104800 10800 1 EEST}
    {1256853600 7200 0 EET}
    {1269554400 10800 1 EEST}
    {1288303200 7200 0 EET}
    {1301004000 10800 1 EEST}
    {1319752800 7200 0 EET}
    {1333058400 10800 1 EEST}
    {1351202400 7200 0 EET}
    {1364508000 10800 1 EEST}
    {1382652000 7200 0 EET}
    {1395957600 10800 1 EEST}
    {1414706400 7200 0 EET}
    {1427407200 10800 1 EEST}
    {1446156000 7200 0 EET}
    {1458856800 10800 1 EEST}
    {1477605600 7200 0 EET}
    {1490911200 10800 1 EEST}
    {1509055200 7200 0 EET}
    {1522360800 10800 1 EEST}
    {1540504800 7200 0 EET}
    {1553810400 10800 1 EEST}
    {1571954400 7200 0 EET}
    {1585260000 10800 1 EEST}
    {1604008800 7200 0 EET}
    {1616709600 10800 1 EEST}
    {1635458400 7200 0 EET}
    {1648159200 10800 1 EEST}
    {1666908000 7200 0 EET}
    {1680213600 10800 1 EEST}
    {1698357600 7200 0 EET}
    {1711663200 10800 1 EEST}
    {1729807200 7200 0 EET}
    {1743112800 10800 1 EEST}
    {1761861600 7200 0 EET}
    {1774562400 10800 1 EEST}
    {1793311200 7200 0 EET}
    {1806012000 10800 1 EEST}
    {1824760800 7200 0 EET}
    {1838066400 10800 1 EEST}
    {1856210400 7200 0 EET}
    {1869516000 10800 1 EEST}
    {1887660000 7200 0 EET}
    {1900965600 10800 1 EEST}
    {1919109600 7200 0 EET}
    {1932415200 10800 1 EEST}
    {1951164000 7200 0 EET}
    {1963864800 10800 1 EEST}
    {1982613600 7200 0 EET}
    {1995314400 10800 1 EEST}
    {2014063200 7200 0 EET}
    {2027368800 10800 1 EEST}
    {2045512800 7200 0 EET}
    {2058818400 10800 1 EEST}
    {2076962400 7200 0 EET}
    {2090268000 10800 1 EEST}
    {2109016800 7200 0 EET}
    {2121717600 10800 1 EEST}
    {2140466400 7200 0 EET}
    {2153167200 10800 1 EEST}
    {2171916000 7200 0 EET}
    {2184616800 10800 1 EEST}
    {2203365600 7200 0 EET}
    {2216671200 10800 1 EEST}
    {2234815200 7200 0 EET}
    {2248120800 10800 1 EEST}
    {2266264800 7200 0 EET}
    {2279570400 10800 1 EEST}
    {2298319200 7200 0 EET}
    {2311020000 10800 1 EEST}
    {2329768800 7200 0 EET}
    {2342469600 10800 1 EEST}
    {2361218400 7200 0 EET}
    {2374524000 10800 1 EEST}
    {2392668000 7200 0 EET}
    {2405973600 10800 1 EEST}
    {2424117600 7200 0 EET}
    {2437423200 10800 1 EEST}
    {2455567200 7200 0 EET}
    {2468872800 10800 1 EEST}
    {2487621600 7200 0 EET}
    {2500322400 10800 1 EEST}
    {2519071200 7200 0 EET}
    {2531772000 10800 1 EEST}
    {2550520800 7200 0 EET}
    {2563826400 10800 1 EEST}
    {2581970400 7200 0 EET}
    {2595276000 10800 1 EEST}
    {2613420000 7200 0 EET}
    {2626725600 10800 1 EEST}
    {2645474400 7200 0 EET}
    {2658175200 10800 1 EEST}
    {2676924000 7200 0 EET}
    {2689624800 10800 1 EEST}
    {2708373600 7200 0 EET}
    {2721679200 10800 1 EEST}
    {2739823200 7200 0 EET}
    {2753128800 10800 1 EEST}
    {2771272800 7200 0 EET}
    {2784578400 10800 1 EEST}
    {2802722400 7200 0 EET}
    {2816028000 10800 1 EEST}
    {2834776800 7200 0 EET}
    {2847477600 10800 1 EEST}
    {2866226400 7200 0 EET}
    {2878927200 10800 1 EEST}
    {2897676000 7200 0 EET}
    {2910981600 10800 1 EEST}
    {2929125600 7200 0 EET}
    {2942431200 10800 1 EEST}
    {2960575200 7200 0 EET}
    {2973880800 10800 1 EEST}
    {2992629600 7200 0 EET}
    {3005330400 10800 1 EEST}
    {3024079200 7200 0 EET}
    {3036780000 10800 1 EEST}
    {3055528800 7200 0 EET}
    {3068229600 10800 1 EEST}
    {3086978400 7200 0 EET}
    {3100284000 10800 1 EEST}
    {3118428000 7200 0 EET}
    {3131733600 10800 1 EEST}
    {3149877600 7200 0 EET}
    {3163183200 10800 1 EEST}
    {3181932000 7200 0 EET}
    {3194632800 10800 1 EEST}
    {3213381600 7200 0 EET}
    {3226082400 10800 1 EEST}
    {3244831200 7200 0 EET}
    {3258136800 10800 1 EEST}
    {3276280800 7200 0 EET}
    {3289586400 10800 1 EEST}
    {3307730400 7200 0 EET}
    {3321036000 10800 1 EEST}
    {3339180000 7200 0 EET}
    {3352485600 10800 1 EEST}
    {3371234400 7200 0 EET}
    {3383935200 10800 1 EEST}
    {3402684000 7200 0 EET}
    {3415384800 10800 1 EEST}
    {3434133600 7200 0 EET}
    {3447439200 10800 1 EEST}
    {3465583200 7200 0 EET}
    {3478888800 10800 1 EEST}
    {3497032800 7200 0 EET}
    {3510338400 10800 1 EEST}
    {3529087200 7200 0 EET}
    {3541788000 10800 1 EEST}
    {3560536800 7200 0 EET}
    {3573237600 10800 1 EEST}
    {3591986400 7200 0 EET}
    {3605292000 10800 1 EEST}
    {3623436000 7200 0 EET}
    {3636741600 10800 1 EEST}
    {3654885600 7200 0 EET}
    {3668191200 10800 1 EEST}
    {3686335200 7200 0 EET}
    {3699640800 10800 1 EEST}
    {3718389600 7200 0 EET}
    {3731090400 10800 1 EEST}
    {3749839200 7200 0 EET}
    {3762540000 10800 1 EEST}
    {3781288800 7200 0 EET}
    {3794594400 10800 1 EEST}
    {3812738400 7200 0 EET}
    {3826044000 10800 1 EEST}
    {3844188000 7200 0 EET}
    {3857493600 10800 1 EEST}
    {3876242400 7200 0 EET}
    {3888943200 10800 1 EEST}
    {3907692000 7200 0 EET}
    {3920392800 10800 1 EEST}
    {3939141600 7200 0 EET}
    {3951842400 10800 1 EEST}
    {3970591200 7200 0 EET}
    {3983896800 10800 1 EEST}
    {4002040800 7200 0 EET}
    {4015346400 10800 1 EEST}
    {4033490400 7200 0 EET}
    {4046796000 10800 1 EEST}
    {4065544800 7200 0 EET}
    {4078245600 10800 1 EEST}
    {4096994400 7200 0 EET}
}
Changes to library/tzdata/Asia/Damascus.
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
    {1128114000 7200 0 EET}
    {1143842400 10800 1 EEST}
    {1158872400 7200 0 EET}
    {1175205600 10800 1 EEST}
    {1193950800 7200 0 EET}
    {1207260000 10800 1 EEST}
    {1225486800 7200 0 EET}
    {1238709600 10800 1 EEST}
    {1257022800 7200 0 EET}
    {1270159200 10800 1 EEST}
    {1288558800 7200 0 EET}
    {1301608800 10800 1 EEST}
    {1320094800 7200 0 EET}
    {1333663200 10800 1 EEST}
    {1351717200 7200 0 EET}
    {1365112800 10800 1 EEST}
    {1383253200 7200 0 EET}
    {1396562400 10800 1 EEST}
    {1414789200 7200 0 EET}
    {1428012000 10800 1 EEST}
    {1446325200 7200 0 EET}
    {1459461600 10800 1 EEST}
    {1477947600 7200 0 EET}
    {1491516000 10800 1 EEST}
    {1509483600 7200 0 EET}
    {1522965600 10800 1 EEST}
    {1541019600 7200 0 EET}
    {1554415200 10800 1 EEST}
    {1572555600 7200 0 EET}
    {1585864800 10800 1 EEST}
    {1604178000 7200 0 EET}
    {1617314400 10800 1 EEST}
    {1635714000 7200 0 EET}
    {1648764000 10800 1 EEST}
    {1667250000 7200 0 EET}
    {1680818400 10800 1 EEST}
    {1698786000 7200 0 EET}
    {1712268000 10800 1 EEST}
    {1730408400 7200 0 EET}
    {1743717600 10800 1 EEST}
    {1761944400 7200 0 EET}
    {1775167200 10800 1 EEST}
    {1793480400 7200 0 EET}
    {1806616800 10800 1 EEST}
    {1825016400 7200 0 EET}
    {1838671200 10800 1 EEST}
    {1856638800 7200 0 EET}
    {1870120800 10800 1 EEST}
    {1888174800 7200 0 EET}
    {1901570400 10800 1 EEST}
    {1919710800 7200 0 EET}
    {1933020000 10800 1 EEST}
    {1951246800 7200 0 EET}
    {1964469600 10800 1 EEST}
    {1982869200 7200 0 EET}
    {1995919200 10800 1 EEST}
    {2014405200 7200 0 EET}
    {2027973600 10800 1 EEST}
    {2045941200 7200 0 EET}
    {2059423200 10800 1 EEST}
    {2077477200 7200 0 EET}
    {2090872800 10800 1 EEST}
    {2109099600 7200 0 EET}
    {2122322400 10800 1 EEST}
    {2140635600 7200 0 EET}
    {2153772000 10800 1 EEST}
    {2172171600 7200 0 EET}
    {2185221600 10800 1 EEST}
    {2203707600 7200 0 EET}
    {2217276000 10800 1 EEST}
    {2235330000 7200 0 EET}
    {2248725600 10800 1 EEST}
    {2266866000 7200 0 EET}
    {2280175200 10800 1 EEST}
    {2298402000 7200 0 EET}
    {2311624800 10800 1 EEST}
    {2329938000 7200 0 EET}
    {2343074400 10800 1 EEST}
    {2361560400 7200 0 EET}
    {2375128800 10800 1 EEST}
    {2393096400 7200 0 EET}
    {2406578400 10800 1 EEST}
    {2424632400 7200 0 EET}
    {2438028000 10800 1 EEST}
    {2456168400 7200 0 EET}
    {2469477600 10800 1 EEST}
    {2487790800 7200 0 EET}
    {2500927200 10800 1 EEST}
    {2519326800 7200 0 EET}
    {2532376800 10800 1 EEST}
    {2550862800 7200 0 EET}
    {2564431200 10800 1 EEST}
    {2582398800 7200 0 EET}
    {2595880800 10800 1 EEST}
    {2614021200 7200 0 EET}
    {2627330400 10800 1 EEST}
    {2645557200 7200 0 EET}
    {2658780000 10800 1 EEST}
    {2677093200 7200 0 EET}
    {2690229600 10800 1 EEST}
    {2708629200 7200 0 EET}
    {2722284000 10800 1 EEST}
    {2740251600 7200 0 EET}
    {2753733600 10800 1 EEST}
    {2771787600 7200 0 EET}
    {2785183200 10800 1 EEST}
    {2803323600 7200 0 EET}
    {2816632800 10800 1 EEST}
    {2834859600 7200 0 EET}
    {2848082400 10800 1 EEST}
    {2866482000 7200 0 EET}
    {2879532000 10800 1 EEST}
    {2898018000 7200 0 EET}
    {2911586400 10800 1 EEST}
    {2929554000 7200 0 EET}
    {2943036000 10800 1 EEST}
    {2961090000 7200 0 EET}
    {2974485600 10800 1 EEST}
    {2992712400 7200 0 EET}
    {3005935200 10800 1 EEST}
    {3024248400 7200 0 EET}
    {3037384800 10800 1 EEST}
    {3055784400 7200 0 EET}
    {3068834400 10800 1 EEST}
    {3087320400 7200 0 EET}
    {3100888800 10800 1 EEST}
    {3118942800 7200 0 EET}
    {3132338400 10800 1 EEST}
    {3150478800 7200 0 EET}
    {3163788000 10800 1 EEST}
    {3182014800 7200 0 EET}
    {3195237600 10800 1 EEST}
    {3213550800 7200 0 EET}
    {3226687200 10800 1 EEST}
    {3245173200 7200 0 EET}
    {3258741600 10800 1 EEST}
    {3276709200 7200 0 EET}
    {3290191200 10800 1 EEST}
    {3308245200 7200 0 EET}
    {3321640800 10800 1 EEST}
    {3339781200 7200 0 EET}
    {3353090400 10800 1 EEST}
    {3371403600 7200 0 EET}
    {3384540000 10800 1 EEST}
    {3402939600 7200 0 EET}
    {3415989600 10800 1 EEST}
    {3434475600 7200 0 EET}
    {3448044000 10800 1 EEST}
    {3466011600 7200 0 EET}
    {3479493600 10800 1 EEST}
    {3497634000 7200 0 EET}
    {3510943200 10800 1 EEST}
    {3529170000 7200 0 EET}
    {3542392800 10800 1 EEST}
    {3560706000 7200 0 EET}
    {3573842400 10800 1 EEST}
    {3592242000 7200 0 EET}
    {3605896800 10800 1 EEST}
    {3623864400 7200 0 EET}
    {3637346400 10800 1 EEST}
    {3655400400 7200 0 EET}
    {3668796000 10800 1 EEST}
    {3686936400 7200 0 EET}
    {3700245600 10800 1 EEST}
    {3718472400 7200 0 EET}
    {3731695200 10800 1 EEST}
    {3750094800 7200 0 EET}
    {3763144800 10800 1 EEST}
    {3781630800 7200 0 EET}
    {3795199200 10800 1 EEST}
    {3813166800 7200 0 EET}
    {3826648800 10800 1 EEST}
    {3844702800 7200 0 EET}
    {3858098400 10800 1 EEST}
    {3876325200 7200 0 EET}
    {3889548000 10800 1 EEST}
    {3907861200 7200 0 EET}
    {3920997600 10800 1 EEST}
    {3939397200 7200 0 EET}
    {3952447200 10800 1 EEST}
    {3970933200 7200 0 EET}
    {3984501600 10800 1 EEST}
    {4002555600 7200 0 EET}
    {4015951200 10800 1 EEST}
    {4034091600 7200 0 EET}
    {4047400800 10800 1 EEST}
    {4065627600 7200 0 EET}
    {4078850400 10800 1 EEST}
    {4097163600 7200 0 EET}
}







|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|


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
    {1128114000 7200 0 EET}
    {1143842400 10800 1 EEST}
    {1158872400 7200 0 EET}
    {1175205600 10800 1 EEST}
    {1193950800 7200 0 EET}
    {1207260000 10800 1 EEST}
    {1225486800 7200 0 EET}
    {1238104800 10800 1 EEST}
    {1257022800 7200 0 EET}
    {1269554400 10800 1 EEST}
    {1288558800 7200 0 EET}
    {1301004000 10800 1 EEST}
    {1320094800 7200 0 EET}
    {1333058400 10800 1 EEST}
    {1351717200 7200 0 EET}
    {1364508000 10800 1 EEST}
    {1383253200 7200 0 EET}
    {1395957600 10800 1 EEST}
    {1414789200 7200 0 EET}
    {1427407200 10800 1 EEST}
    {1446325200 7200 0 EET}
    {1458856800 10800 1 EEST}
    {1477947600 7200 0 EET}
    {1490911200 10800 1 EEST}
    {1509483600 7200 0 EET}
    {1522360800 10800 1 EEST}
    {1541019600 7200 0 EET}
    {1553810400 10800 1 EEST}
    {1572555600 7200 0 EET}
    {1585260000 10800 1 EEST}
    {1604178000 7200 0 EET}
    {1616709600 10800 1 EEST}
    {1635714000 7200 0 EET}
    {1648159200 10800 1 EEST}
    {1667250000 7200 0 EET}
    {1680213600 10800 1 EEST}
    {1698786000 7200 0 EET}
    {1711663200 10800 1 EEST}
    {1730408400 7200 0 EET}
    {1743112800 10800 1 EEST}
    {1761944400 7200 0 EET}
    {1774562400 10800 1 EEST}
    {1793480400 7200 0 EET}
    {1806012000 10800 1 EEST}
    {1825016400 7200 0 EET}
    {1838066400 10800 1 EEST}
    {1856638800 7200 0 EET}
    {1869516000 10800 1 EEST}
    {1888174800 7200 0 EET}
    {1900965600 10800 1 EEST}
    {1919710800 7200 0 EET}
    {1932415200 10800 1 EEST}
    {1951246800 7200 0 EET}
    {1963864800 10800 1 EEST}
    {1982869200 7200 0 EET}
    {1995314400 10800 1 EEST}
    {2014405200 7200 0 EET}
    {2027368800 10800 1 EEST}
    {2045941200 7200 0 EET}
    {2058818400 10800 1 EEST}
    {2077477200 7200 0 EET}
    {2090268000 10800 1 EEST}
    {2109099600 7200 0 EET}
    {2121717600 10800 1 EEST}
    {2140635600 7200 0 EET}
    {2153167200 10800 1 EEST}
    {2172171600 7200 0 EET}
    {2184616800 10800 1 EEST}
    {2203707600 7200 0 EET}
    {2216671200 10800 1 EEST}
    {2235330000 7200 0 EET}
    {2248120800 10800 1 EEST}
    {2266866000 7200 0 EET}
    {2279570400 10800 1 EEST}
    {2298402000 7200 0 EET}
    {2311020000 10800 1 EEST}
    {2329938000 7200 0 EET}
    {2342469600 10800 1 EEST}
    {2361560400 7200 0 EET}
    {2374524000 10800 1 EEST}
    {2393096400 7200 0 EET}
    {2405973600 10800 1 EEST}
    {2424632400 7200 0 EET}
    {2437423200 10800 1 EEST}
    {2456168400 7200 0 EET}
    {2468872800 10800 1 EEST}
    {2487790800 7200 0 EET}
    {2500322400 10800 1 EEST}
    {2519326800 7200 0 EET}
    {2531772000 10800 1 EEST}
    {2550862800 7200 0 EET}
    {2563826400 10800 1 EEST}
    {2582398800 7200 0 EET}
    {2595276000 10800 1 EEST}
    {2614021200 7200 0 EET}
    {2626725600 10800 1 EEST}
    {2645557200 7200 0 EET}
    {2658175200 10800 1 EEST}
    {2677093200 7200 0 EET}
    {2689624800 10800 1 EEST}
    {2708629200 7200 0 EET}
    {2721679200 10800 1 EEST}
    {2740251600 7200 0 EET}
    {2753128800 10800 1 EEST}
    {2771787600 7200 0 EET}
    {2784578400 10800 1 EEST}
    {2803323600 7200 0 EET}
    {2816028000 10800 1 EEST}
    {2834859600 7200 0 EET}
    {2847477600 10800 1 EEST}
    {2866482000 7200 0 EET}
    {2878927200 10800 1 EEST}
    {2898018000 7200 0 EET}
    {2910981600 10800 1 EEST}
    {2929554000 7200 0 EET}
    {2942431200 10800 1 EEST}
    {2961090000 7200 0 EET}
    {2973880800 10800 1 EEST}
    {2992712400 7200 0 EET}
    {3005330400 10800 1 EEST}
    {3024248400 7200 0 EET}
    {3036780000 10800 1 EEST}
    {3055784400 7200 0 EET}
    {3068229600 10800 1 EEST}
    {3087320400 7200 0 EET}
    {3100284000 10800 1 EEST}
    {3118942800 7200 0 EET}
    {3131733600 10800 1 EEST}
    {3150478800 7200 0 EET}
    {3163183200 10800 1 EEST}
    {3182014800 7200 0 EET}
    {3194632800 10800 1 EEST}
    {3213550800 7200 0 EET}
    {3226082400 10800 1 EEST}
    {3245173200 7200 0 EET}
    {3258136800 10800 1 EEST}
    {3276709200 7200 0 EET}
    {3289586400 10800 1 EEST}
    {3308245200 7200 0 EET}
    {3321036000 10800 1 EEST}
    {3339781200 7200 0 EET}
    {3352485600 10800 1 EEST}
    {3371403600 7200 0 EET}
    {3383935200 10800 1 EEST}
    {3402939600 7200 0 EET}
    {3415384800 10800 1 EEST}
    {3434475600 7200 0 EET}
    {3447439200 10800 1 EEST}
    {3466011600 7200 0 EET}
    {3478888800 10800 1 EEST}
    {3497634000 7200 0 EET}
    {3510338400 10800 1 EEST}
    {3529170000 7200 0 EET}
    {3541788000 10800 1 EEST}
    {3560706000 7200 0 EET}
    {3573237600 10800 1 EEST}
    {3592242000 7200 0 EET}
    {3605292000 10800 1 EEST}
    {3623864400 7200 0 EET}
    {3636741600 10800 1 EEST}
    {3655400400 7200 0 EET}
    {3668191200 10800 1 EEST}
    {3686936400 7200 0 EET}
    {3699640800 10800 1 EEST}
    {3718472400 7200 0 EET}
    {3731090400 10800 1 EEST}
    {3750094800 7200 0 EET}
    {3762540000 10800 1 EEST}
    {3781630800 7200 0 EET}
    {3794594400 10800 1 EEST}
    {3813166800 7200 0 EET}
    {3826044000 10800 1 EEST}
    {3844702800 7200 0 EET}
    {3857493600 10800 1 EEST}
    {3876325200 7200 0 EET}
    {3888943200 10800 1 EEST}
    {3907861200 7200 0 EET}
    {3920392800 10800 1 EEST}
    {3939397200 7200 0 EET}
    {3951842400 10800 1 EEST}
    {3970933200 7200 0 EET}
    {3983896800 10800 1 EEST}
    {4002555600 7200 0 EET}
    {4015346400 10800 1 EEST}
    {4034091600 7200 0 EET}
    {4046796000 10800 1 EEST}
    {4065627600 7200 0 EET}
    {4078245600 10800 1 EEST}
    {4097163600 7200 0 EET}
}
Changes to library/tzdata/Asia/Gaza.
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
    {1113516000 10800 1 EEST}
    {1128380400 7200 0 EET}
    {1143842400 10800 1 EEST}
    {1158872400 7200 0 EET}
    {1175378400 10800 1 EEST}
    {1189638000 7200 0 EET}
    {1207000800 10800 1 EEST}
    {1219878000 7200 0 EET}
    {1238536800 10800 1 EEST}
    {1251327600 7200 0 EET}
    {1270072800 10800 1 EEST}
    {1282777200 7200 0 EET}
    {1301608800 10800 1 EEST}
    {1314226800 7200 0 EET}
    {1333231200 10800 1 EEST}
    {1346281200 7200 0 EET}
    {1364767200 10800 1 EEST}
    {1377730800 7200 0 EET}
    {1396303200 10800 1 EEST}
    {1409180400 7200 0 EET}
    {1427839200 10800 1 EEST}
    {1440630000 7200 0 EET}
    {1459461600 10800 1 EEST}
    {1472079600 7200 0 EET}
    {1490997600 10800 1 EEST}
    {1504134000 7200 0 EET}
    {1522533600 10800 1 EEST}
    {1535583600 7200 0 EET}
    {1554069600 10800 1 EEST}
    {1567033200 7200 0 EET}
    {1585692000 10800 1 EEST}
    {1598482800 7200 0 EET}
    {1617228000 10800 1 EEST}
    {1629932400 7200 0 EET}
    {1648764000 10800 1 EEST}
    {1661382000 7200 0 EET}
    {1680300000 10800 1 EEST}
    {1693436400 7200 0 EET}
    {1711922400 10800 1 EEST}
    {1724886000 7200 0 EET}
    {1743458400 10800 1 EEST}
    {1756335600 7200 0 EET}
    {1774994400 10800 1 EEST}
    {1787785200 7200 0 EET}
    {1806530400 10800 1 EEST}
    {1819234800 7200 0 EET}
    {1838152800 10800 1 EEST}
    {1851289200 7200 0 EET}
    {1869688800 10800 1 EEST}
    {1882738800 7200 0 EET}
    {1901224800 10800 1 EEST}
    {1914188400 7200 0 EET}
    {1932760800 10800 1 EEST}
    {1945638000 7200 0 EET}
    {1964383200 10800 1 EEST}
    {1977087600 7200 0 EET}
    {1995919200 10800 1 EEST}
    {2008537200 7200 0 EET}
    {2027455200 10800 1 EEST}


    {2040591600 7200 0 EET}
    {2058991200 10800 1 EEST}
    {2072041200 7200 0 EET}
    {2090613600 10800 1 EEST}
    {2103490800 7200 0 EET}
    {2122149600 10800 1 EEST}
    {2134940400 7200 0 EET}
    {2153685600 10800 1 EEST}
    {2166390000 7200 0 EET}
    {2185221600 10800 1 EEST}
    {2197839600 7200 0 EET}
    {2216844000 10800 1 EEST}
    {2229894000 7200 0 EET}
    {2248380000 10800 1 EEST}
    {2261343600 7200 0 EET}
    {2279916000 10800 1 EEST}
    {2292793200 7200 0 EET}
    {2311452000 10800 1 EEST}
    {2324242800 7200 0 EET}
    {2343074400 10800 1 EEST}
    {2355692400 7200 0 EET}
    {2374610400 10800 1 EEST}
    {2387746800 7200 0 EET}
    {2406146400 10800 1 EEST}
    {2419196400 7200 0 EET}
    {2437682400 10800 1 EEST}
    {2450646000 7200 0 EET}
    {2469304800 10800 1 EEST}
    {2482095600 7200 0 EET}
    {2500840800 10800 1 EEST}
    {2513545200 7200 0 EET}
    {2532376800 10800 1 EEST}
    {2544994800 7200 0 EET}
    {2563912800 10800 1 EEST}
    {2577049200 7200 0 EET}
    {2595535200 10800 1 EEST}
    {2608498800 7200 0 EET}
    {2627071200 10800 1 EEST}
    {2639948400 7200 0 EET}
    {2658607200 10800 1 EEST}
    {2671398000 7200 0 EET}
    {2690143200 10800 1 EEST}
    {2702847600 7200 0 EET}
    {2721765600 10800 1 EEST}


    {2734902000 7200 0 EET}
    {2753301600 10800 1 EEST}


    {2766351600 7200 0 EET}
    {2784837600 10800 1 EEST}
    {2797801200 7200 0 EET}
    {2816373600 10800 1 EEST}
    {2829250800 7200 0 EET}
    {2847996000 10800 1 EEST}
    {2860700400 7200 0 EET}
    {2879532000 10800 1 EEST}
    {2892150000 7200 0 EET}
    {2911068000 10800 1 EEST}
    {2924204400 7200 0 EET}
    {2942604000 10800 1 EEST}
    {2955654000 7200 0 EET}
    {2974226400 10800 1 EEST}
    {2987103600 7200 0 EET}
    {3005762400 10800 1 EEST}
    {3018553200 7200 0 EET}
    {3037298400 10800 1 EEST}
    {3050002800 7200 0 EET}
    {3068834400 10800 1 EEST}
    {3081452400 7200 0 EET}
    {3100456800 10800 1 EEST}
    {3113506800 7200 0 EET}
    {3131992800 10800 1 EEST}
    {3144956400 7200 0 EET}
    {3163528800 10800 1 EEST}
    {3176406000 7200 0 EET}
    {3195064800 10800 1 EEST}
    {3207855600 7200 0 EET}
    {3226687200 10800 1 EEST}
    {3239305200 7200 0 EET}
    {3258223200 10800 1 EEST}
    {3271359600 7200 0 EET}
    {3289759200 10800 1 EEST}
    {3302809200 7200 0 EET}
    {3321295200 10800 1 EEST}
    {3334258800 7200 0 EET}
    {3352917600 10800 1 EEST}
    {3365708400 7200 0 EET}
    {3384453600 10800 1 EEST}
    {3397158000 7200 0 EET}
    {3415989600 10800 1 EEST}
    {3428607600 7200 0 EET}
    {3447525600 10800 1 EEST}
    {3460662000 7200 0 EET}
    {3479148000 10800 1 EEST}
    {3492111600 7200 0 EET}
    {3510684000 10800 1 EEST}
    {3523561200 7200 0 EET}
    {3542220000 10800 1 EEST}
    {3555010800 7200 0 EET}
    {3573756000 10800 1 EEST}
    {3586460400 7200 0 EET}
    {3605378400 10800 1 EEST}
    {3618514800 7200 0 EET}
    {3636914400 10800 1 EEST}
    {3649964400 7200 0 EET}
    {3668450400 10800 1 EEST}
    {3681414000 7200 0 EET}
    {3699986400 10800 1 EEST}
    {3712863600 7200 0 EET}
    {3731608800 10800 1 EEST}
    {3744313200 7200 0 EET}
    {3763144800 10800 1 EEST}
    {3775762800 7200 0 EET}
    {3794680800 10800 1 EEST}
    {3807817200 7200 0 EET}
    {3826216800 10800 1 EEST}
    {3839266800 7200 0 EET}
    {3857839200 10800 1 EEST}
    {3870716400 7200 0 EET}
    {3889375200 10800 1 EEST}
    {3902166000 7200 0 EET}
    {3920911200 10800 1 EEST}
    {3933615600 7200 0 EET}
    {3952447200 10800 1 EEST}
    {3965065200 7200 0 EET}
    {3984069600 10800 1 EEST}
    {3997119600 7200 0 EET}
    {4015605600 10800 1 EEST}
    {4028569200 7200 0 EET}
    {4047141600 10800 1 EEST}
    {4060018800 7200 0 EET}
    {4078677600 10800 1 EEST}
    {4091468400 7200 0 EET}
}







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|
|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<

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
    {1113516000 10800 1 EEST}
    {1128380400 7200 0 EET}
    {1143842400 10800 1 EEST}
    {1158872400 7200 0 EET}
    {1175378400 10800 1 EEST}
    {1189638000 7200 0 EET}
    {1207000800 10800 1 EEST}
    {1219964400 7200 0 EET}
    {1238104800 10800 1 EEST}
    {1254092400 7200 0 EET}
    {1269554400 10800 1 EEST}
    {1285542000 7200 0 EET}
    {1301004000 10800 1 EEST}
    {1316991600 7200 0 EET}
    {1333058400 10800 1 EEST}
    {1348441200 7200 0 EET}
    {1364508000 10800 1 EEST}
    {1380495600 7200 0 EET}
    {1395957600 10800 1 EEST}
    {1411945200 7200 0 EET}
    {1427407200 10800 1 EEST}
    {1443394800 7200 0 EET}
    {1458856800 10800 1 EEST}
    {1474844400 7200 0 EET}
    {1490911200 10800 1 EEST}
    {1506294000 7200 0 EET}
    {1522360800 10800 1 EEST}
    {1537743600 7200 0 EET}


    {1553810400 10800 1 EEST}
    {1569798000 7200 0 EET}
    {1585260000 10800 1 EEST}
    {1601247600 7200 0 EET}
    {1616709600 10800 1 EEST}
    {1632697200 7200 0 EET}
    {1648159200 10800 1 EEST}
    {1664146800 7200 0 EET}
    {1680213600 10800 1 EEST}
    {1695596400 7200 0 EET}
    {1711663200 10800 1 EEST}
    {1727650800 7200 0 EET}
    {1743112800 10800 1 EEST}
    {1759100400 7200 0 EET}
    {1774562400 10800 1 EEST}
    {1790550000 7200 0 EET}
    {1806012000 10800 1 EEST}
    {1821999600 7200 0 EET}
    {1838066400 10800 1 EEST}
    {1853449200 7200 0 EET}
    {1869516000 10800 1 EEST}
    {1884898800 7200 0 EET}
    {1900965600 10800 1 EEST}
    {1916953200 7200 0 EET}
    {1932415200 10800 1 EEST}
    {1948402800 7200 0 EET}
    {1963864800 10800 1 EEST}
    {1979852400 7200 0 EET}
    {1995314400 10800 1 EEST}
    {2011302000 7200 0 EET}
    {2027368800 10800 1 EEST}
    {2042751600 7200 0 EET}
    {2058818400 10800 1 EEST}
    {2074201200 7200 0 EET}
    {2090268000 10800 1 EEST}
    {2106255600 7200 0 EET}
    {2121717600 10800 1 EEST}
    {2137705200 7200 0 EET}
    {2153167200 10800 1 EEST}
    {2169154800 7200 0 EET}
    {2184616800 10800 1 EEST}
    {2200604400 7200 0 EET}
    {2216671200 10800 1 EEST}
    {2232054000 7200 0 EET}
    {2248120800 10800 1 EEST}
    {2264108400 7200 0 EET}
    {2279570400 10800 1 EEST}
    {2295558000 7200 0 EET}
    {2311020000 10800 1 EEST}
    {2327007600 7200 0 EET}
    {2342469600 10800 1 EEST}
    {2358457200 7200 0 EET}
    {2374524000 10800 1 EEST}
    {2389906800 7200 0 EET}
    {2405973600 10800 1 EEST}
    {2421356400 7200 0 EET}
    {2437423200 10800 1 EEST}
    {2453410800 7200 0 EET}
    {2468872800 10800 1 EEST}
    {2484860400 7200 0 EET}
    {2500322400 10800 1 EEST}
    {2516310000 7200 0 EET}
    {2531772000 10800 1 EEST}
    {2547759600 7200 0 EET}
    {2563826400 10800 1 EEST}
    {2579209200 7200 0 EET}
    {2595276000 10800 1 EEST}
    {2611263600 7200 0 EET}
    {2626725600 10800 1 EEST}
    {2642713200 7200 0 EET}
    {2658175200 10800 1 EEST}
    {2674162800 7200 0 EET}
    {2689624800 10800 1 EEST}
    {2705612400 7200 0 EET}
    {2721679200 10800 1 EEST}
    {2737062000 7200 0 EET}
    {2753128800 10800 1 EEST}
    {2768511600 7200 0 EET}
    {2784578400 10800 1 EEST}
    {2800566000 7200 0 EET}
    {2816028000 10800 1 EEST}
    {2832015600 7200 0 EET}
    {2847477600 10800 1 EEST}
    {2863465200 7200 0 EET}
    {2878927200 10800 1 EEST}
    {2894914800 7200 0 EET}
    {2910981600 10800 1 EEST}
    {2926364400 7200 0 EET}
    {2942431200 10800 1 EEST}
    {2957814000 7200 0 EET}
    {2973880800 10800 1 EEST}
    {2989868400 7200 0 EET}
    {3005330400 10800 1 EEST}
    {3021318000 7200 0 EET}
    {3036780000 10800 1 EEST}
    {3052767600 7200 0 EET}
    {3068229600 10800 1 EEST}
    {3084217200 7200 0 EET}
    {3100284000 10800 1 EEST}
    {3115666800 7200 0 EET}
    {3131733600 10800 1 EEST}
    {3147721200 7200 0 EET}
    {3163183200 10800 1 EEST}
    {3179170800 7200 0 EET}
    {3194632800 10800 1 EEST}
    {3210620400 7200 0 EET}
    {3226082400 10800 1 EEST}
    {3242070000 7200 0 EET}
    {3258136800 10800 1 EEST}
    {3273519600 7200 0 EET}
    {3289586400 10800 1 EEST}
    {3304969200 7200 0 EET}
    {3321036000 10800 1 EEST}
    {3337023600 7200 0 EET}
    {3352485600 10800 1 EEST}
    {3368473200 7200 0 EET}
    {3383935200 10800 1 EEST}
    {3399922800 7200 0 EET}
    {3415384800 10800 1 EEST}
    {3431372400 7200 0 EET}
    {3447439200 10800 1 EEST}
    {3462822000 7200 0 EET}
    {3478888800 10800 1 EEST}
    {3494876400 7200 0 EET}
    {3510338400 10800 1 EEST}
    {3526326000 7200 0 EET}
    {3541788000 10800 1 EEST}
    {3557775600 7200 0 EET}
    {3573237600 10800 1 EEST}
    {3589225200 7200 0 EET}
    {3605292000 10800 1 EEST}
    {3620674800 7200 0 EET}
    {3636741600 10800 1 EEST}
    {3652124400 7200 0 EET}
    {3668191200 10800 1 EEST}
    {3684178800 7200 0 EET}
    {3699640800 10800 1 EEST}
    {3715628400 7200 0 EET}
    {3731090400 10800 1 EEST}
    {3747078000 7200 0 EET}
    {3762540000 10800 1 EEST}
    {3778527600 7200 0 EET}
    {3794594400 10800 1 EEST}
    {3809977200 7200 0 EET}
    {3826044000 10800 1 EEST}
    {3841426800 7200 0 EET}
    {3857493600 10800 1 EEST}
    {3873481200 7200 0 EET}
    {3888943200 10800 1 EEST}
    {3904930800 7200 0 EET}
    {3920392800 10800 1 EEST}
    {3936380400 7200 0 EET}
    {3951842400 10800 1 EEST}
    {3967830000 7200 0 EET}
    {3983896800 10800 1 EEST}
    {3999279600 7200 0 EET}
    {4015346400 10800 1 EEST}
    {4031334000 7200 0 EET}
    {4046796000 10800 1 EEST}
    {4062783600 7200 0 EET}
    {4078245600 10800 1 EEST}
    {4094233200 7200 0 EET}




}
Added library/tzdata/Asia/Kathmandu.














>
>
>
>
>
>
>
1
2
3
4
5
6
7
# created by tools/tclZIC.tcl - do not edit

set TZData(:Asia/Kathmandu) {
    {-9223372036854775808 20476 0 LMT}
    {-1577943676 19800 0 IST}
    {504901800 20700 0 NPT}
}
Changes to library/tzdata/Asia/Katmandu.
1


2
3
4
5
6
7
# created by tools/tclZIC.tcl - do not edit



set TZData(:Asia/Katmandu) {
    {-9223372036854775808 20476 0 LMT}
    {-1577943676 19800 0 IST}
    {504901800 20700 0 NPT}
}

>
>
|
|
<
<
<
<
1
2
3
4
5




# created by tools/tclZIC.tcl - do not edit
if {![info exists TZData(Asia/Kathmandu)]} {
    LoadTimeZoneFile Asia/Kathmandu
}
set TZData(:Asia/Katmandu) $TZData(:Asia/Kathmandu)




Changes to library/tzdata/Europe/Zurich.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# created by tools/tclZIC.tcl - do not edit

set TZData(:Europe/Zurich) {
    {-9223372036854775808 2048 0 LMT}
    {-3827954048 1784 0 BMT}
    {-2385246584 3600 0 CET}
    {-920336400 7200 1 CEST}
    {-915242400 3600 0 CET}
    {-904518000 7200 1 CEST}
    {-891223200 3600 0 CET}
    {-873068400 7200 1 CEST}
    {-859773600 3600 0 CET}
    {347151600 3600 0 CET}
    {354675600 7200 1 CEST}
    {370400400 3600 0 CET}
    {386125200 7200 1 CEST}
    {401850000 3600 0 CET}
    {417574800 7200 1 CEST}
    {433299600 3600 0 CET}






|
|
|
|
<
<







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
# created by tools/tclZIC.tcl - do not edit

set TZData(:Europe/Zurich) {
    {-9223372036854775808 2048 0 LMT}
    {-3827954048 1784 0 BMT}
    {-2385246584 3600 0 CET}
    {-904435200 7200 1 CEST}
    {-891129600 3600 0 CET}
    {-872985600 7200 1 CEST}
    {-859680000 3600 0 CET}


    {347151600 3600 0 CET}
    {354675600 7200 1 CEST}
    {370400400 3600 0 CET}
    {386125200 7200 1 CEST}
    {401850000 3600 0 CET}
    {417574800 7200 1 CEST}
    {433299600 3600 0 CET}
Changes to macosx/tclMacOSXBundle.c.
44
45
46
47
48
49
50
51
52
53
54
55
56
57



































58















59
60
61
62
63
64
65
 *	software shall be classified as "Commercial Computer Software" and the
 *	Government shall have only "Restricted Rights" as defined in Clause
 *	252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
 *	authors grant the U.S. Government and others acting in its behalf
 *	permission to use and distribute the software in accordance with the
 *	terms specified in this license.
 *
 * RCS: @(#) $Id: tclMacOSXBundle.c,v 1.5.2.7 2008/12/10 13:52:04 dgp Exp $
 */

#include "tclPort.h"

#ifdef HAVE_COREFOUNDATION
#include <CoreFoundation/CoreFoundation.h>



































#include <mach-o/dyld.h>















#endif /* HAVE_COREFOUNDATION */

/*
 *----------------------------------------------------------------------
 *
 * Tcl_MacOSXOpenBundleResources --
 *







|






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

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







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
 *	software shall be classified as "Commercial Computer Software" and the
 *	Government shall have only "Restricted Rights" as defined in Clause
 *	252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
 *	authors grant the U.S. Government and others acting in its behalf
 *	permission to use and distribute the software in accordance with the
 *	terms specified in this license.
 *
 * RCS: @(#) $Id: tclMacOSXBundle.c,v 1.5.2.8 2009/04/10 18:09:30 dgp Exp $
 */

#include "tclPort.h"

#ifdef HAVE_COREFOUNDATION
#include <CoreFoundation/CoreFoundation.h>

#ifndef TCL_DYLD_USE_DLFCN
/*
 * Use preferred dlfcn API on 10.4 and later
 */
#   if !defined(NO_DLFCN_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
#	define TCL_DYLD_USE_DLFCN 1
#   else
#	define TCL_DYLD_USE_DLFCN 0
#   endif
#endif

#ifndef TCL_DYLD_USE_NSMODULE
/*
 * Use deprecated NSModule API only to support 10.3 and earlier:
 */
#   if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
#	define TCL_DYLD_USE_NSMODULE 1
#   else
#	define TCL_DYLD_USE_NSMODULE 0
#   endif
#endif

#if TCL_DYLD_USE_DLFCN
#include <dlfcn.h>
#if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
/*
 * Support for weakly importing dlfcn API.
 */
extern void *dlsym(void *handle, const char *symbol) WEAK_IMPORT_ATTRIBUTE;
extern char *dlerror(void) WEAK_IMPORT_ATTRIBUTE;
#endif
#endif

#if TCL_DYLD_USE_NSMODULE
#include <mach-o/dyld.h>
#endif

#if TCL_DYLD_USE_DLFCN && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
MODULE_SCOPE long tclMacOSXDarwinRelease;
#endif

#ifdef TCL_DEBUG_LOAD
#define TclLoadDbgMsg(m, ...) do { \
	    fprintf(stderr, "%s:%d: %s(): " m ".\n", \
	    strrchr(__FILE__, '/')+1, __LINE__, __func__, ##__VA_ARGS__); \
	} while (0)
#else
#define TclLoadDbgMsg(m, ...)
#endif

#endif /* HAVE_COREFOUNDATION */

/*
 *----------------------------------------------------------------------
 *
 * Tcl_MacOSXOpenBundleResources --
 *
188
189
190
191
192
193
194

















195
196
197

198
199

200
201
202


203
204
205
206
207
208
209
	     * OS X and not in CFLite on pure Darwin.
	     */

	    static int initialized = FALSE;
	    static short (*openresourcemap)(CFBundleRef) = NULL;

	    if (!initialized) {

















		NSSymbol nsSymbol = NULL;
		if (NSIsSymbolNameDefinedWithHint(
			"_CFBundleOpenBundleResourceMap", "CoreFoundation")) {

		    nsSymbol = NSLookupAndBindSymbolWithHint(
			    "_CFBundleOpenBundleResourceMap","CoreFoundation");

		    if (nsSymbol) {
			openresourcemap = NSAddressOfSymbol(nsSymbol);
		    }


		}
		initialized = TRUE;
	    }

	    if (openresourcemap) {
		short refNum;








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







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
	     * OS X and not in CFLite on pure Darwin.
	     */

	    static int initialized = FALSE;
	    static short (*openresourcemap)(CFBundleRef) = NULL;

	    if (!initialized) {
#if TCL_DYLD_USE_DLFCN
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		if (tclMacOSXDarwinRelease >= 8)
#endif
		{
		    const char *errMsg = nil;
		    openresourcemap = dlsym(RTLD_NEXT,
			    "CFBundleOpenBundleResourceMap");
		    if (!openresourcemap) {
			errMsg = dlerror();
			TclLoadDbgMsg("dlsym() failed: %s", errMsg);
		    }
		}
		if (!openresourcemap)
#endif
		{
#if TCL_DYLD_USE_NSMODULE
		    NSSymbol nsSymbol = NULL;
		    if (NSIsSymbolNameDefinedWithHint(
			    "_CFBundleOpenBundleResourceMap",
			    "CoreFoundation")) {
			nsSymbol = NSLookupAndBindSymbolWithHint(
				"_CFBundleOpenBundleResourceMap",
				"CoreFoundation");
			if (nsSymbol) {
			    openresourcemap = NSAddressOfSymbol(nsSymbol);
			}
		    }
#endif
		}
		initialized = TRUE;
	    }

	    if (openresourcemap) {
		short refNum;

Changes to macosx/tclMacOSXNotify.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
/*
 * tclMacOSXNotify.c --
 *
 *	This file contains the implementation of a merged CFRunLoop/select()
 *	based notifier, which is the lowest-level part of the Tcl event loop.
 *	This file works together with generic/tclNotify.c.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 * Copyright (c) 2005-2008 Daniel A. Steffen <das@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: tclMacOSXNotify.c,v 1.1.4.16 2009/01/09 14:17:15 dgp Exp $
 */

#include "tclInt.h"
#ifdef HAVE_COREFOUNDATION	/* Traditional unix select-based notifier is
				 * in tclUnixNotfy.c */
#include <CoreFoundation/CoreFoundation.h>
#include <pthread.h>

/*
 * This structure is used to keep track of the notifier info for a registered
 * file.
 */

typedef struct FileHandler {
    int fd;
    int mask;			/* Mask of desired events: TCL_READABLE,
				 * etc. */
    int readyMask;		/* Mask of events that have been seen since
				 * the last time file handlers were invoked
				 * for this file. */
    Tcl_FileProc *proc;		/* Function to call, in the style of
				 * Tcl_CreateFileHandler. */
    ClientData clientData;	/* Argument to pass to proc. */
    struct FileHandler *nextPtr;/* Next in list of all files we care about. */
} FileHandler;

/*
 * The following structure is what is added to the Tcl event queue when file
 * handlers are ready to fire.
 */

typedef struct FileHandlerEvent {
    Tcl_Event header;		/* Information that is standard for all
				 * events. */
    int fd;			/* File descriptor that is ready. Used to find
				 * the FileHandler structure for the file
				 * (can't point directly to the FileHandler
				 * structure because it could go away while
				 * the event is queued). */
} FileHandlerEvent;

/*
 * The following structure contains a set of select() masks to track readable,
 * writable, and exceptional conditions.
 */

typedef struct SelectMasks {
    fd_set readable;
    fd_set writable;
    fd_set exceptional;
} SelectMasks;

/*
 * The following static structure contains the state information for the
 * select based implementation of the Tcl notifier. One of these structures is
 * created for each thread that is using the notifier.
 */

typedef struct ThreadSpecificData {
    FileHandler *firstFileHandlerPtr;
				/* Pointer to head of file handler list. */
    SelectMasks checkMasks;	/* This structure is used to build up the
				 * masks to be used in the next call to
				 * select. Bits are set in response to calls
				 * to Tcl_CreateFileHandler. */
    SelectMasks readyMasks;	/* This array reflects the readable/writable
				 * conditions that were found to exist by the
				 * last call to select. */
    int numFdBits;		/* Number of valid bits in checkMasks (one
				 * more than highest fd for which
				 * Tcl_WatchFile has been called). */
    int onList;			/* True if it is in this list */
    unsigned int pollState;	/* pollState is used to implement a polling
				 * handshake between each thread and the
				 * notifier thread. Bits defined below. */
    struct ThreadSpecificData *nextPtr, *prevPtr;
				/* All threads that are currently waiting on
				 * an event have their ThreadSpecificData
				 * structure on a doubly-linked listed formed
				 * from these pointers. You must hold the
				 * notifierLock before accessing these
				 * fields. */
    CFRunLoopSourceRef runLoopSource;
				/* Any other thread alerts a notifier that an
				 * event is ready to be processed by signaling
				 * this CFRunLoopSource. */
    CFRunLoopRef runLoop;	/* This thread's CFRunLoop, needs to be woken
				 * up whenever the runLoopSource is
				 * signaled. */
    int eventReady;		/* True if an event is ready to be
				 * processed. */
} ThreadSpecificData;

static Tcl_ThreadDataKey dataKey;

/*
 * The following static indicates the number of threads that have initialized
 * notifiers.
 *
 * You must hold the notifierInitLock before accessing this variable.
 */

static int notifierCount = 0;

/*
 * The following variable points to the head of a doubly-linked list of
 * ThreadSpecificData structures for all threads that are currently waiting on
 * an event.
 *
 * You must hold the notifierLock before accessing this list.
 */

static ThreadSpecificData *waitingListPtr = NULL;

/*
 * The notifier thread spends all its time in select() waiting for a file
 * descriptor associated with one of the threads on the waitingListPtr list to
 * do something interesting. But if the contents of the waitingListPtr list
 * ever changes, we need to wake up and restart the select() system call. You
 * can wake up the notifier thread by writing a single byte to the file
 * descriptor defined below. This file descriptor is the input-end of a pipe
 * and the notifier thread is listening for data on the output-end of the same
 * pipe. Hence writing to this file descriptor will cause the select() system
 * call to return and wake up the notifier thread.
 *
 * You must hold the notifierLock lock before writing to the pipe.
 */

static int triggerPipe = -1;
static int receivePipe = -1; /* Output end of triggerPipe */

/*
 * We use the Darwin-native spinlock API rather than pthread mutexes for
 * notifier locking: this radically simplifies the implementation and lowers
 * overhead. Note that these are not pure spinlocks, they employ various
 * strategies to back off and relinquish the processor, making them immune to
 * most priority-inversion livelocks (c.f. 'man 3 OSSpinLockLock' and Darwin









|




|








<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
/*
 * tclMacOSXNotify.c --
 *
 *	This file contains the implementation of a merged CFRunLoop/select()
 *	based notifier, which is the lowest-level part of the Tcl event loop.
 *	This file works together with generic/tclNotify.c.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 * Copyright (c) 2005-2009 Daniel A. Steffen <das@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: tclMacOSXNotify.c,v 1.1.4.17 2009/04/10 18:09:30 dgp Exp $
 */

#include "tclInt.h"
#ifdef HAVE_COREFOUNDATION	/* Traditional unix select-based notifier is
				 * in tclUnixNotfy.c */
#include <CoreFoundation/CoreFoundation.h>
#include <pthread.h>





/* #define TCL_MAC_DEBUG_NOTIFIER 1 */






















































































































/*
 * We use the Darwin-native spinlock API rather than pthread mutexes for
 * notifier locking: this radically simplifies the implementation and lowers
 * overhead. Note that these are not pure spinlocks, they employ various
 * strategies to back off and relinquish the processor, making them immune to
 * most priority-inversion livelocks (c.f. 'man 3 OSSpinLockLock' and Darwin
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
 * Macros abstracting notifier locking/unlocking
 */

#define LOCK_NOTIFIER_INIT	SpinLockLock(&notifierInitLock)
#define UNLOCK_NOTIFIER_INIT	SpinLockUnlock(&notifierInitLock)
#define LOCK_NOTIFIER		SpinLockLock(&notifierLock)
#define UNLOCK_NOTIFIER		SpinLockUnlock(&notifierLock)



#ifdef TCL_MAC_DEBUG_NOTIFIER







/*
 * Debug version of SpinLockLock that logs the time spent waiting for the lock
 */

#define SpinLockLockDbg(p)	if (!SpinLockTry(p)) { \
				    Tcl_WideInt s = TclpGetWideClicks(), e; \
				    SpinLockLock(p); e = TclpGetWideClicks(); \
				    fprintf(notifierLog, "tclMacOSXNotify.c:" \
				    "%4d: thread %10p waited on %s for " \
				    "%8llu ns\n", __LINE__, pthread_self(), \
				    #p, TclpWideClicksToNanoseconds(e-s)); \
				    fflush(notifierLog); \
				}
#undef LOCK_NOTIFIER_INIT
#define LOCK_NOTIFIER_INIT	SpinLockLockDbg(&notifierInitLock)
#undef LOCK_NOTIFIER
#define LOCK_NOTIFIER		SpinLockLockDbg(&notifierLock)



static FILE *notifierLog = stderr;
#ifndef NOTIFIER_LOG
#define NOTIFIER_LOG "/tmp/tclMacOSXNotify.log"
#endif
#define OPEN_NOTIFIER_LOG	if (notifierLog == stderr) { \
				    notifierLog = fopen(NOTIFIER_LOG, "a"); \





				}
#define CLOSE_NOTIFIER_LOG	if (notifierLog != stderr) { \



				    fclose(notifierLog); \
				    notifierLog = stderr; \
				}





















#endif /* TCL_MAC_DEBUG_NOTIFIER */

/*



 * The pollState bits












 *	POLL_WANT is set by each thread before it waits on its condition




 *		variable. It is checked by the notifier before it does select.









 *	POLL_DONE is set by the notifier if it goes into select after seeing




 *		POLL_WANT. The idea is to ensure it tries a select with the





 *		same bits the initial thread had set.








































































































 */

#define POLL_WANT	0x1
#define POLL_DONE	0x2

/*
 * This is the thread ID of the notifier thread that does select.



 */

static pthread_t notifierThread;

/*
 * Custom run loop mode containing only the run loop source for the
 * notifier thread.
 */

#ifndef TCL_EVENTS_ONLY_RUN_LOOP_MODE
#define TCL_EVENTS_ONLY_RUN_LOOP_MODE "com.tcltk.tclEventsOnlyRunLoopMode"
#endif
#ifdef __CONSTANT_CFSTRINGS__
#define tclEventsOnlyRunLoopMode CFSTR(TCL_EVENTS_ONLY_RUN_LOOP_MODE)
#else
static CFStringRef tclEventsOnlyRunLoopMode = NULL;
#endif







/*
 * Static routines defined in this file.
 */


static void	NotifierThreadProc(ClientData clientData)
	__attribute__ ((__noreturn__));
static int	FileHandlerEventProc(Tcl_Event *evPtr, int flags);







#ifdef HAVE_PTHREAD_ATFORK
static int	atForkInit = 0;
static void	AtForkPrepare(void);
static void	AtForkParent(void);
static void	AtForkChild(void);
#if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040







>
>


>
>
>
>
>
>
>







<
|
<

<





>
>
>
|



|

>
>
>
>
>

|
>
>
>

|

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



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


|
<



>
>
>





|
|



|


|




>
>
>
>
>
>




>

|

>
>
>
>
>
>







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
 * Macros abstracting notifier locking/unlocking
 */

#define LOCK_NOTIFIER_INIT	SpinLockLock(&notifierInitLock)
#define UNLOCK_NOTIFIER_INIT	SpinLockUnlock(&notifierInitLock)
#define LOCK_NOTIFIER		SpinLockLock(&notifierLock)
#define UNLOCK_NOTIFIER		SpinLockUnlock(&notifierLock)
#define LOCK_NOTIFIER_TSD	SpinLockLock(&tsdPtr->tsdLock)
#define UNLOCK_NOTIFIER_TSD	SpinLockUnlock(&tsdPtr->tsdLock)

#ifdef TCL_MAC_DEBUG_NOTIFIER
#define TclMacOSXNotifierDbgMsg(m, ...) do { \
	    fprintf(notifierLog?notifierLog:stderr, "tclMacOSXNotify.c:%d: " \
	    "%s() pid %5d thread %10p: " m "\n", __LINE__, __func__, \
	    getpid(), pthread_self(), ##__VA_ARGS__); \
	    fflush(notifierLog?notifierLog:stderr); \
	} while (0)

/*
 * Debug version of SpinLockLock that logs the time spent waiting for the lock
 */

#define SpinLockLockDbg(p)	if (!SpinLockTry(p)) { \
				    Tcl_WideInt s = TclpGetWideClicks(), e; \
				    SpinLockLock(p); e = TclpGetWideClicks(); \

				    TclMacOSXNotifierDbgMsg("waited on %s for %8.0f ns", \

				    #p, TclpWideClicksToNanoseconds(e-s)); \

				}
#undef LOCK_NOTIFIER_INIT
#define LOCK_NOTIFIER_INIT	SpinLockLockDbg(&notifierInitLock)
#undef LOCK_NOTIFIER
#define LOCK_NOTIFIER		SpinLockLockDbg(&notifierLock)
#undef LOCK_NOTIFIER_TSD
#define LOCK_NOTIFIER_TSD	SpinLockLockDbg(&tsdPtr->tsdLock)
#include <asl.h>
static FILE *notifierLog = NULL;
#ifndef NOTIFIER_LOG
#define NOTIFIER_LOG "/tmp/tclMacOSXNotify.log"
#endif
#define OPEN_NOTIFIER_LOG	if (!notifierLog) { \
				    notifierLog = fopen(NOTIFIER_LOG, "a"); \
				    /*TclMacOSXNotifierDbgMsg("open log"); \
				    asl_set_filter(NULL, \
				    ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG)); \
				    asl_add_log_file(NULL, \
					    fileno(notifierLog));*/ \
				}
#define CLOSE_NOTIFIER_LOG	if (notifierLog) { \
				    /*asl_remove_log_file(NULL, \
					    fileno(notifierLog)); \
				    TclMacOSXNotifierDbgMsg("close log");*/ \
				    fclose(notifierLog); \
				    notifierLog = NULL; \
				}
#define ENABLE_ASL		if (notifierLog) { \
				    /*tsdPtr->asl = asl_open(NULL, "com.apple.console", ASL_OPT_NO_REMOTE); \
				    asl_set_filter(tsdPtr->asl, \
				    ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG)); \
				    asl_add_log_file(tsdPtr->asl, \
					    fileno(notifierLog));*/ \
				}
#define DISABLE_ASL		/*if (tsdPtr->asl) { \
				    if (notifierLog) { \
					asl_remove_log_file(tsdPtr->asl, \
						fileno(notifierLog)); \
				    } \
				    asl_close(tsdPtr->asl); \
				}*/
#define ASLCLIENT		/*aslclient asl*/
#else
#define TclMacOSXNotifierDbgMsg(m, ...)
#define OPEN_NOTIFIER_LOG
#define CLOSE_NOTIFIER_LOG
#define ENABLE_ASL
#define DISABLE_ASL
#endif /* TCL_MAC_DEBUG_NOTIFIER */

/*
 * This structure is used to keep track of the notifier info for a registered
 * file.
 */

typedef struct FileHandler {
    int fd;
    int mask;			/* Mask of desired events: TCL_READABLE,
				 * etc. */
    int readyMask;		/* Mask of events that have been seen since
				 * the last time file handlers were invoked
				 * for this file. */
    Tcl_FileProc *proc;		/* Function to call, in the style of
				 * Tcl_CreateFileHandler. */
    ClientData clientData;	/* Argument to pass to proc. */
    struct FileHandler *nextPtr;/* Next in list of all files we care about. */
} FileHandler;

/*
 * The following structure is what is added to the Tcl event queue when file
 * handlers are ready to fire.
 */

typedef struct FileHandlerEvent {
    Tcl_Event header;		/* Information that is standard for all
				 * events. */
    int fd;			/* File descriptor that is ready. Used to find
				 * the FileHandler structure for the file
				 * (can't point directly to the FileHandler
				 * structure because it could go away while
				 * the event is queued). */
} FileHandlerEvent;

/*
 * The following structure contains a set of select() masks to track readable,
 * writable, and exceptional conditions.
 */

typedef struct SelectMasks {
    fd_set readable;
    fd_set writable;
    fd_set exceptional;
} SelectMasks;

/*
 * The following static structure contains the state information for the
 * select based implementation of the Tcl notifier. One of these structures is
 * created for each thread that is using the notifier.
 */

typedef struct ThreadSpecificData {
    FileHandler *firstFileHandlerPtr;
				/* Pointer to head of file handler list. */
    int polled;			/* True if the notifier thread has polled for
				 * this thread.
				 */
    int sleeping;		/* True if runloop is inside Tcl_Sleep. */
    int runLoopSourcePerformed;	/* True after the runLoopSource callack was
				 * performed. */
    int runLoopRunning;		/* True if this thread's Tcl runLoop is running */
    int runLoopNestingLevel;	/* Level of nested runLoop invocations */
    /* Must hold the notifierLock before accessing the following fields: */
    /* Start notifierLock section */
    int onList;			/* True if this thread is on the waitingList */
    struct ThreadSpecificData *nextPtr, *prevPtr;
				/* All threads that are currently waiting on
				 * an event have their ThreadSpecificData
				 * structure on a doubly-linked listed formed
				 * from these pointers.
				 */
    /* End notifierLock section */
    OSSpinLock tsdLock;		/* Must hold this lock before acessing the
				 * following fields from more than one thread.
				 */
    /* Start tsdLock section */
    SelectMasks checkMasks;	/* This structure is used to build up the
				 * masks to be used in the next call to
				 * select. Bits are set in response to calls
				 * to Tcl_CreateFileHandler. */
    SelectMasks readyMasks;	/* This array reflects the readable/writable
				 * conditions that were found to exist by the
				 * last call to select. */
    int numFdBits;		/* Number of valid bits in checkMasks (one
				 * more than highest fd for which
				 * Tcl_WatchFile has been called). */
    int polling;		/* True if this thread is polling for events */
    CFRunLoopRef runLoop;	/* This thread's CFRunLoop, needs to be woken
				 * up whenever the runLoopSource is signaled */
    CFRunLoopSourceRef runLoopSource;
				/* Any other thread alerts a notifier that an
				 * event is ready to be processed by signaling
				 * this CFRunLoopSource. */
    CFRunLoopObserverRef runLoopObserver;
				/* Adds/removes this thread from waitingList
				 * when the CFRunLoop starts/stops. */
    CFRunLoopTimerRef runLoopTimer;
				/* Wakes up CFRunLoop after given timeout when
				 * running embedded. */
    /* End tsdLock section */
    CFTimeInterval waitTime;	/* runLoopTimer wait time when running
				 * embedded. */
#ifdef TCL_MAC_DEBUG_NOTIFIER
    ASLCLIENT;
#endif
} ThreadSpecificData;

static Tcl_ThreadDataKey dataKey;

/*
 * The following static indicates the number of threads that have initialized
 * notifiers.
 *
 * You must hold the notifierInitLock before accessing this variable.
 */

static int notifierCount = 0;

/*
 * The following variable points to the head of a doubly-linked list of
 * ThreadSpecificData structures for all threads that are currently waiting on
 * an event.
 *
 * You must hold the notifierLock before accessing this list.
 */

static ThreadSpecificData *waitingListPtr = NULL;

/*
 * The notifier thread spends all its time in select() waiting for a file
 * descriptor associated with one of the threads on the waitingListPtr list to
 * do something interesting. But if the contents of the waitingListPtr list
 * ever changes, we need to wake up and restart the select() system call. You
 * can wake up the notifier thread by writing a single byte to the file
 * descriptor defined below. This file descriptor is the input-end of a pipe
 * and the notifier thread is listening for data on the output-end of the same
 * pipe. Hence writing to this file descriptor will cause the select() system
 * call to return and wake up the notifier thread.
 *
 * You must hold the notifierLock lock before writing to the pipe.
 */

static int triggerPipe = -1;
static int receivePipe = -1; /* Output end of triggerPipe */

/*
 * The following static indicates if the notifier thread is running.
 *
 * You must hold the notifierInitLock before accessing this variable.
 */

static int notifierThreadRunning;


/*
 * This is the thread ID of the notifier thread that does select.
 * Only valid when notifierThreadRunning is non-zero.
 *
 * You must hold the notifierInitLock before accessing this variable.
 */

static pthread_t notifierThread;

/*
 * Custom runloop mode for running with only the runloop source for the
 * notifier thread
 */

#ifndef TCL_EVENTS_ONLY_RUN_LOOP_MODE
#define TCL_EVENTS_ONLY_RUN_LOOP_MODE	"com.tcltk.tclEventsOnlyRunLoopMode"
#endif
#ifdef __CONSTANT_CFSTRINGS__
#define tclEventsOnlyRunLoopMode	CFSTR(TCL_EVENTS_ONLY_RUN_LOOP_MODE)
#else
static CFStringRef tclEventsOnlyRunLoopMode = NULL;
#endif

/*
 * CFTimeInterval to wait forever.
 */

#define CF_TIMEINTERVAL_FOREVER 5.05e8

/*
 * Static routines defined in this file.
 */

static void	StartNotifierThread(void);
static void	NotifierThreadProc(ClientData clientData)
			__attribute__ ((__noreturn__));
static int	FileHandlerEventProc(Tcl_Event *evPtr, int flags);
static void	TimerWakeUp(CFRunLoopTimerRef timer, void *info);
static void	QueueFileEvents(void *info);
static void	UpdateWaitingListAndServiceEvents(CFRunLoopObserverRef observer,
			CFRunLoopActivity activity, void *info);
static int	OnOffWaitingList(ThreadSpecificData *tsdPtr, int onList,
			int signalNotifier);

#ifdef HAVE_PTHREAD_ATFORK
static int	atForkInit = 0;
static void	AtForkPrepare(void);
static void	AtForkParent(void);
static void	AtForkChild(void);
#if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.initNotifierProc) {
	return tclNotifierHooks.initNotifierProc();
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);
    tsdPtr->eventReady = 0;

#ifdef WEAK_IMPORT_SPINLOCKLOCK
    /*
     * Initialize support for weakly imported spinlock API.
     */

    if (pthread_once(&spinLockLockInitControl, SpinLockLockInit)) {







<







424
425
426
427
428
429
430

431
432
433
434
435
436
437
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.initNotifierProc) {
	return tclNotifierHooks.initNotifierProc();
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);


#ifdef WEAK_IMPORT_SPINLOCKLOCK
    /*
     * Initialize support for weakly imported spinlock API.
     */

    if (pthread_once(&spinLockLockInitControl, SpinLockLockInit)) {
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
     * Initialize CFRunLoopSource and add it to CFRunLoop of this thread.
     */

    if (!tsdPtr->runLoop) {
	CFRunLoopRef runLoop = CFRunLoopGetCurrent();
	CFRunLoopSourceRef runLoopSource;
	CFRunLoopSourceContext runLoopSourceContext;



	bzero(&runLoopSourceContext, sizeof(CFRunLoopSourceContext));
	runLoopSourceContext.info = tsdPtr;

	runLoopSource = CFRunLoopSourceCreate(NULL, 0, &runLoopSourceContext);

	if (!runLoopSource) {
	    Tcl_Panic("Tcl_InitNotifier: could not create CFRunLoopSource");
	}
	CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopCommonModes);
	CFRunLoopAddSource(runLoop, runLoopSource, tclEventsOnlyRunLoopMode);
















	tsdPtr->runLoopSource = runLoopSource;

	tsdPtr->runLoop = runLoop;


    }

    LOCK_NOTIFIER_INIT;
#ifdef HAVE_PTHREAD_ATFORK
    /*
     * Install pthread_atfork handlers to reinitialize the notifier in the
     * child of a fork.







>
>



>
|
>





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

>
|
>
>







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
     * Initialize CFRunLoopSource and add it to CFRunLoop of this thread.
     */

    if (!tsdPtr->runLoop) {
	CFRunLoopRef runLoop = CFRunLoopGetCurrent();
	CFRunLoopSourceRef runLoopSource;
	CFRunLoopSourceContext runLoopSourceContext;
	CFRunLoopObserverContext runLoopObserverContext;
	CFRunLoopObserverRef runLoopObserver;

	bzero(&runLoopSourceContext, sizeof(CFRunLoopSourceContext));
	runLoopSourceContext.info = tsdPtr;
	runLoopSourceContext.perform = QueueFileEvents;
	runLoopSource = CFRunLoopSourceCreate(NULL, LONG_MIN,
		&runLoopSourceContext);
	if (!runLoopSource) {
	    Tcl_Panic("Tcl_InitNotifier: could not create CFRunLoopSource");
	}
	CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopCommonModes);
	CFRunLoopAddSource(runLoop, runLoopSource, tclEventsOnlyRunLoopMode);

	bzero(&runLoopObserverContext, sizeof(CFRunLoopObserverContext));
	runLoopObserverContext.info = tsdPtr;
	runLoopObserver = CFRunLoopObserverCreate(NULL,
		kCFRunLoopEntry|kCFRunLoopExit|kCFRunLoopBeforeWaiting, TRUE,
		LONG_MIN, UpdateWaitingListAndServiceEvents,
		&runLoopObserverContext);
	if (!runLoopObserver) {
	    Tcl_Panic("Tcl_InitNotifier: could not create "
		    "CFRunLoopObserver");
	}
	CFRunLoopAddObserver(runLoop, runLoopObserver, kCFRunLoopCommonModes);
	CFRunLoopAddObserver(runLoop, runLoopObserver,
		tclEventsOnlyRunLoopMode);

	tsdPtr->runLoop = runLoop;
	tsdPtr->runLoopSource = runLoopSource;
	tsdPtr->runLoopObserver = runLoopObserver;
	tsdPtr->runLoopTimer = NULL;
	tsdPtr->waitTime = CF_TIMEINTERVAL_FOREVER;
	tsdPtr->tsdLock = SPINLOCK_INIT;
    }

    LOCK_NOTIFIER_INIT;
#ifdef HAVE_PTHREAD_ATFORK
    /*
     * Install pthread_atfork handlers to reinitialize the notifier in the
     * child of a fork.
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
	if (pipe(fds) != 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not create trigger pipe");
	}

	status = fcntl(fds[0], F_GETFL);
	status |= O_NONBLOCK;
	if (fcntl(fds[0], F_SETFL, status) < 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not make receive pipe non blocking");

	}
	status = fcntl(fds[1], F_GETFL);
	status |= O_NONBLOCK;
	if (fcntl(fds[1], F_SETFL, status) < 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not make trigger pipe non blocking");

	}

	receivePipe = fds[0];
	triggerPipe = fds[1];

	/*
	 * Create notifier thread lazily in Tcl_WaitForEvent() to avoid
	 * interfering with fork() followed immediately by execve() (we cannot
	 * execve() when more than one thread is present).
	 */

	notifierThread = 0;
#ifdef TCL_MAC_DEBUG_NOTIFIER
	OPEN_NOTIFIER_LOG;
#endif
    }

    notifierCount++;
    UNLOCK_NOTIFIER_INIT;

    return (ClientData) tsdPtr;
}













































































/*
 *----------------------------------------------------------------------
 *
 * Tcl_FinalizeNotifier --
 *
 *	This function is called to cleanup the notifier state before a thread







|
>




|
>











|
<

<

>





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







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
	if (pipe(fds) != 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not create trigger pipe");
	}

	status = fcntl(fds[0], F_GETFL);
	status |= O_NONBLOCK;
	if (fcntl(fds[0], F_SETFL, status) < 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not make receive pipe non "
		    "blocking");
	}
	status = fcntl(fds[1], F_GETFL);
	status |= O_NONBLOCK;
	if (fcntl(fds[1], F_SETFL, status) < 0) {
	    Tcl_Panic("Tcl_InitNotifier: could not make trigger pipe non "
		    "blocking");
	}

	receivePipe = fds[0];
	triggerPipe = fds[1];

	/*
	 * Create notifier thread lazily in Tcl_WaitForEvent() to avoid
	 * interfering with fork() followed immediately by execve() (we cannot
	 * execve() when more than one thread is present).
	 */

	notifierThreadRunning = 0;

	OPEN_NOTIFIER_LOG;

    }
    ENABLE_ASL;
    notifierCount++;
    UNLOCK_NOTIFIER_INIT;

    return (ClientData) tsdPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * TclMacOSXNotifierAddRunLoopMode --
 *
 *	Add the tcl notifier RunLoop source, observer and timer (if any)
 *	to the given RunLoop mode.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

void
TclMacOSXNotifierAddRunLoopMode(
    const void *runLoopMode)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    CFStringRef mode = (CFStringRef) runLoopMode;

    if (tsdPtr->runLoop) {
	CFRunLoopAddSource(tsdPtr->runLoop, tsdPtr->runLoopSource, mode);
	CFRunLoopAddObserver(tsdPtr->runLoop, tsdPtr->runLoopObserver, mode);
	if (tsdPtr->runLoopTimer) {
	    CFRunLoopAddTimer(tsdPtr->runLoop, tsdPtr->runLoopTimer, mode);
	}
    }
}

/*
 *----------------------------------------------------------------------
 *
 * StartNotifierThread --
 *
 *	Start notifier thread if necessary.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static void
StartNotifierThread(void)
{
    LOCK_NOTIFIER_INIT;
    if (!notifierCount) {
	Tcl_Panic("StartNotifierThread: notifier not initialized");
    }
    if (!notifierThreadRunning) {
	int result;
	pthread_attr_t attr;

	pthread_attr_init(&attr);
	pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	pthread_attr_setstacksize(&attr, 60 * 1024);
	result = pthread_create(&notifierThread, &attr,
		(void * (*)(void *))NotifierThreadProc, NULL);
	pthread_attr_destroy(&attr);
	if (result) {
	    Tcl_Panic("StartNotifierThread: unable to start notifier thread");
	}
	notifierThreadRunning = 1;
    }
    UNLOCK_NOTIFIER_INIT;
}


/*
 *----------------------------------------------------------------------
 *
 * Tcl_FinalizeNotifier --
 *
 *	This function is called to cleanup the notifier state before a thread
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

    if (tclNotifierHooks.finalizeNotifierProc) {
	tclNotifierHooks.finalizeNotifierProc(clientData);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);

    LOCK_NOTIFIER_INIT;
    notifierCount--;


    /*
     * If this is the last thread to use the notifier, close the notifier pipe
     * and wait for the background thread to terminate.
     */

    if (notifierCount == 0) {
	int result;

	if (triggerPipe < 0) {
	    Tcl_Panic("Tcl_FinalizeNotifier: notifier pipe not initialized");
	}

	/*
	 * Send "q" message to the notifier thread so that it will terminate.
	 * The notifier will return from its call to select() and notice that
	 * a "q" message has arrived, it will then close its side of the pipe
	 * and terminate its thread. Note the we can not just close the pipe
	 * and check for EOF in the notifier thread because if a background
	 * child process was created with exec, select() would not register
	 * the EOF on the pipe until the child processes had terminated. [Bug:
	 * 4139] [Bug: 1222872]
	 */

	write(triggerPipe, "q", 1);
	close(triggerPipe);

	if (notifierThread) {
	    result = pthread_join(notifierThread, NULL);

	    if (result) {
		Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier thread");

	    }
	    notifierThread = 0;
	}

	close(receivePipe);
	triggerPipe = -1;
#ifdef TCL_MAC_DEBUG_NOTIFIER

	CLOSE_NOTIFIER_LOG;
#endif
    }
    UNLOCK_NOTIFIER_INIT;

    LOCK_NOTIFIER;		/* For concurrency with Tcl_AlertNotifier */
    if (tsdPtr->runLoop) {
	tsdPtr->runLoop = NULL;

	/*
	 * Remove runLoopSource from all CFRunLoops and release it.

	 */

	CFRunLoopSourceInvalidate(tsdPtr->runLoopSource);
	CFRelease(tsdPtr->runLoopSource);
	tsdPtr->runLoopSource = NULL;







    }

    UNLOCK_NOTIFIER;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AlertNotifier --
 *







>


>







<
<
|
<
<
<
|
|
|
|
|
|
|
|
|
|

|
|

|
|
>
|
|
>
|
|
|

|
|
<
>

<



|




|
>





>
>
>
>
>
>
>
|
>
|







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

    if (tclNotifierHooks.finalizeNotifierProc) {
	tclNotifierHooks.finalizeNotifierProc(clientData);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);

    LOCK_NOTIFIER_INIT;
    notifierCount--;
    DISABLE_ASL;

    /*
     * If this is the last thread to use the notifier, close the notifier pipe
     * and wait for the background thread to terminate.
     */

    if (notifierCount == 0) {


	if (triggerPipe != -1) {



	    /*
	     * Send "q" message to the notifier thread so that it will
	     * terminate. The notifier will return from its call to select()
	     * and notice that a "q" message has arrived, it will then close
	     * its side of the pipe and terminate its thread. Note the we can
	     * not just close the pipe and check for EOF in the notifier thread
	     * because if a background child process was created with exec,
	     * select() would not register the EOF on the pipe until the child
	     * processes had terminated. [Bug: 4139] [Bug: 1222872]
	     */

	    write(triggerPipe, "q", 1);
	    close(triggerPipe);

	    if (notifierThreadRunning) {
		int result = pthread_join(notifierThread, NULL);

		if (result) {
		    Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier "
			    "thread");
		}
		notifierThreadRunning = 0;
	    }

	    close(receivePipe);
	    triggerPipe = -1;

	}
	CLOSE_NOTIFIER_LOG;

    }
    UNLOCK_NOTIFIER_INIT;

    LOCK_NOTIFIER_TSD;		/* For concurrency with Tcl_AlertNotifier */
    if (tsdPtr->runLoop) {
	tsdPtr->runLoop = NULL;

	/*
	 * Remove runLoopSource, runLoopObserver and runLoopTimer from all
	 * CFRunLoops.
	 */

	CFRunLoopSourceInvalidate(tsdPtr->runLoopSource);
	CFRelease(tsdPtr->runLoopSource);
	tsdPtr->runLoopSource = NULL;
	CFRunLoopObserverInvalidate(tsdPtr->runLoopObserver);
	CFRelease(tsdPtr->runLoopObserver);
	tsdPtr->runLoopObserver = NULL;
	if (tsdPtr->runLoopTimer) {
	    CFRunLoopTimerInvalidate(tsdPtr->runLoopTimer);
	    CFRelease(tsdPtr->runLoopTimer);
	    tsdPtr->runLoopTimer = NULL;
	}
    }
    UNLOCK_NOTIFIER_TSD;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AlertNotifier --
 *
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
    ThreadSpecificData *tsdPtr = clientData;

    if (tclNotifierHooks.alertNotifierProc) {
	tclNotifierHooks.alertNotifierProc(clientData);
	return;
    }

    LOCK_NOTIFIER;
    if (tsdPtr->runLoop) {
	tsdPtr->eventReady = 1;
	CFRunLoopSourceSignal(tsdPtr->runLoopSource);
	CFRunLoopWakeUp(tsdPtr->runLoop);
    }
    UNLOCK_NOTIFIER;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_SetTimer --
 *
 *	This function sets the current notifier timer value. This interface is
 *	not implemented in this notifier because we are always running inside
 *	of Tcl_DoOneEvent.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_SetTimer(
    const Tcl_Time *timePtr)		/* Timeout value, may be NULL. */
{




    if (tclNotifierHooks.setTimerProc) {
	tclNotifierHooks.setTimerProc(timePtr);
	return;
    }























    /*




     * The interval timer doesn't do anything in this implementation, because
     * the only event loop is via Tcl_DoOneEvent, which passes timeout values

     * to Tcl_WaitForEvent.






     */






}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_ServiceModeHook --
 *







|

<



|







|
<
<





|








>
>
>
>





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
<
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>







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
    ThreadSpecificData *tsdPtr = clientData;

    if (tclNotifierHooks.alertNotifierProc) {
	tclNotifierHooks.alertNotifierProc(clientData);
	return;
    }

    LOCK_NOTIFIER_TSD;
    if (tsdPtr->runLoop) {

	CFRunLoopSourceSignal(tsdPtr->runLoopSource);
	CFRunLoopWakeUp(tsdPtr->runLoop);
    }
    UNLOCK_NOTIFIER_TSD;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_SetTimer --
 *
 *	This function sets the current notifier timer value.


 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Replaces any previous timer.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_SetTimer(
    const Tcl_Time *timePtr)		/* Timeout value, may be NULL. */
{
    ThreadSpecificData *tsdPtr;
    CFRunLoopTimerRef runLoopTimer;
    CFTimeInterval waitTime;

    if (tclNotifierHooks.setTimerProc) {
	tclNotifierHooks.setTimerProc(timePtr);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);
    runLoopTimer = tsdPtr->runLoopTimer;
    if (!runLoopTimer) {
	return;
    }
    if (timePtr) {
	Tcl_Time vTime  = *timePtr;

	if (vTime.sec != 0 || vTime.usec != 0) {
	    tclScaleTimeProcPtr(&vTime, tclTimeClientData);
	    waitTime = vTime.sec + 1.0e-6 * vTime.usec;
	} else {
	    waitTime = 0;
	}
    } else {
	waitTime = CF_TIMEINTERVAL_FOREVER;
    }
    tsdPtr->waitTime = waitTime;
    CFRunLoopTimerSetNextFireDate(runLoopTimer,
	    CFAbsoluteTimeGetCurrent() + waitTime);
}

/*
 *----------------------------------------------------------------------
 *
 * TimerWakeUp --
 *
 *	CFRunLoopTimer callback.

 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static void
TimerWakeUp(
    CFRunLoopTimerRef timer,
    void *info)
{
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_ServiceModeHook --
 *
636
637
638
639
640
641
642


643
644
645

646

647












648
649
650
651
652
653
654
 */

void
Tcl_ServiceModeHook(
    int mode)			/* Either TCL_SERVICE_ALL, or
				 * TCL_SERVICE_NONE. */
{


    if (tclNotifierHooks.serviceModeHookProc) {
	tclNotifierHooks.serviceModeHookProc(mode);
	return;

    } else {

	/* Does nothing in this implementation. */












    }
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_CreateFileHandler --







>
>



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







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
 */

void
Tcl_ServiceModeHook(
    int mode)			/* Either TCL_SERVICE_ALL, or
				 * TCL_SERVICE_NONE. */
{
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.serviceModeHookProc) {
	tclNotifierHooks.serviceModeHookProc(mode);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);

    if (mode == TCL_SERVICE_ALL && !tsdPtr->runLoopTimer) {
	if (!tsdPtr->runLoop) {
	    Tcl_Panic("Tcl_ServiceModeHook: Notifier not initialized");
	}
	tsdPtr->runLoopTimer = CFRunLoopTimerCreate(NULL,
		CFAbsoluteTimeGetCurrent() + CF_TIMEINTERVAL_FOREVER,
		CF_TIMEINTERVAL_FOREVER, 0, 0, TimerWakeUp, NULL);
	if (tsdPtr->runLoopTimer) {
	    CFRunLoopAddTimer(tsdPtr->runLoop, tsdPtr->runLoopTimer,
		    kCFRunLoopCommonModes);
	    StartNotifierThread();
	}
    }
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_CreateFileHandler --
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
    filePtr->clientData = clientData;
    filePtr->mask = mask;

    /*
     * Update the check masks for this file.
     */


    if (mask & TCL_READABLE) {
	FD_SET(fd, &(tsdPtr->checkMasks.readable));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.readable));
    }
    if (mask & TCL_WRITABLE) {
	FD_SET(fd, &(tsdPtr->checkMasks.writable));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.writable));
    }
    if (mask & TCL_EXCEPTION) {
	FD_SET(fd, &(tsdPtr->checkMasks.exceptional));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.exceptional));
    }
    if (tsdPtr->numFdBits <= fd) {
	tsdPtr->numFdBits = fd+1;
    }

}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_DeleteFileHandler --
 *







>


















>







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
    filePtr->clientData = clientData;
    filePtr->mask = mask;

    /*
     * Update the check masks for this file.
     */

    LOCK_NOTIFIER_TSD;
    if (mask & TCL_READABLE) {
	FD_SET(fd, &(tsdPtr->checkMasks.readable));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.readable));
    }
    if (mask & TCL_WRITABLE) {
	FD_SET(fd, &(tsdPtr->checkMasks.writable));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.writable));
    }
    if (mask & TCL_EXCEPTION) {
	FD_SET(fd, &(tsdPtr->checkMasks.exceptional));
    } else {
	FD_CLR(fd, &(tsdPtr->checkMasks.exceptional));
    }
    if (tsdPtr->numFdBits <= fd) {
	tsdPtr->numFdBits = fd+1;
    }
    UNLOCK_NOTIFIER_TSD;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_DeleteFileHandler --
 *
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

void
Tcl_DeleteFileHandler(
    int fd)			/* Stream id for which to remove callback
				 * function. */
{
    FileHandler *filePtr, *prevPtr;
    int i;
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.deleteFileHandlerProc) {
	tclNotifierHooks.deleteFileHandlerProc(fd);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);


    /*
     * Find the entry for the given file (and return if there isn't one).
     */

    for (prevPtr = NULL, filePtr = tsdPtr->firstFileHandlerPtr; ;
	    prevPtr = filePtr, filePtr = filePtr->nextPtr) {
	if (filePtr == NULL) {
	    return;
	}
	if (filePtr->fd == fd) {
	    break;
	}
    }






















    /*
     * Update the check masks for this file.
     */

    if (filePtr->mask & TCL_READABLE) {
	FD_CLR(fd, &(tsdPtr->checkMasks.readable));
    }
    if (filePtr->mask & TCL_WRITABLE) {
	FD_CLR(fd, &(tsdPtr->checkMasks.writable));
    }
    if (filePtr->mask & TCL_EXCEPTION) {
	FD_CLR(fd, &(tsdPtr->checkMasks.exceptional));
    }

    /*
     * Find current max fd.
     */

    if (fd+1 == tsdPtr->numFdBits) {
	tsdPtr->numFdBits = 0;
	for (i = fd-1; i >= 0; i--) {
	    if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
		    || FD_ISSET(i, &(tsdPtr->checkMasks.writable))
		    || FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		tsdPtr->numFdBits = i+1;
		break;
	    }
	}
    }

    /*
     * Clean up information in the callback record.
     */

    if (prevPtr == NULL) {
	tsdPtr->firstFileHandlerPtr = filePtr->nextPtr;







|








>














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














|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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

void
Tcl_DeleteFileHandler(
    int fd)			/* Stream id for which to remove callback
				 * function. */
{
    FileHandler *filePtr, *prevPtr;
    int i, numFdBits;
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.deleteFileHandlerProc) {
	tclNotifierHooks.deleteFileHandlerProc(fd);
	return;
    }

    tsdPtr = TCL_TSD_INIT(&dataKey);
    numFdBits = -1;

    /*
     * Find the entry for the given file (and return if there isn't one).
     */

    for (prevPtr = NULL, filePtr = tsdPtr->firstFileHandlerPtr; ;
	    prevPtr = filePtr, filePtr = filePtr->nextPtr) {
	if (filePtr == NULL) {
	    return;
	}
	if (filePtr->fd == fd) {
	    break;
	}
    }

    /*
     * Find current max fd.
     */

    if (fd+1 == tsdPtr->numFdBits) {
	numFdBits = 0;
	for (i = fd-1; i >= 0; i--) {
	    if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
		    || FD_ISSET(i, &(tsdPtr->checkMasks.writable))
		    || FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		numFdBits = i+1;
		break;
	    }
	}
    }

    LOCK_NOTIFIER_TSD;
    if (numFdBits != -1) {
	tsdPtr->numFdBits = numFdBits;
    }

    /*
     * Update the check masks for this file.
     */

    if (filePtr->mask & TCL_READABLE) {
	FD_CLR(fd, &(tsdPtr->checkMasks.readable));
    }
    if (filePtr->mask & TCL_WRITABLE) {
	FD_CLR(fd, &(tsdPtr->checkMasks.writable));
    }
    if (filePtr->mask & TCL_EXCEPTION) {
	FD_CLR(fd, &(tsdPtr->checkMasks.exceptional));
    }
    UNLOCK_NOTIFIER_TSD;
















    /*
     * Clean up information in the callback record.
     */

    if (prevPtr == NULL) {
	tsdPtr->firstFileHandlerPtr = filePtr->nextPtr;
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
	 *    zeroed when a new file handler is created for the newly opened
	 *    file.
	 */

	mask = filePtr->readyMask & filePtr->mask;
	filePtr->readyMask = 0;
	if (mask != 0) {











	    filePtr->proc(filePtr->clientData, mask);
	}
	break;
    }
    return 1;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_WaitForEvent --
 *
 *	This function is called by Tcl_DoOneEvent to wait for new events on
 *	the message queue. If the block time is 0, then Tcl_WaitForEvent just
 *	polls without blocking.
 *
 * Results:
 *	Returns -1 if the select would block forever, otherwise returns 0.

 *
 * Side effects:
 *	Queues file events that are detected by the select.

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

int
Tcl_WaitForEvent(
    const Tcl_Time *timePtr)		/* Maximum block time, or NULL. */
{
    FileHandler *filePtr;
    FileHandlerEvent *fileEvPtr;
    int mask, waitForFiles;

    Tcl_Time myTime, *myTimePtr;
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.waitForEventProc) {
	return tclNotifierHooks.waitForEventProc(timePtr);
    }



    tsdPtr = TCL_TSD_INIT(&dataKey);

    /*
     * Set up the timeout structure. Note that if there are no events to check
     * for, we return with a negative result rather than blocking forever.
     */



    if (timePtr != NULL) {


	/*
	 * TIP #233 (Virtualized Time). Is virtual time in effect? And do we
	 * actually have something to scale? If yes to both then we call the
	 * handler to do this scaling.
	 */

	myTime.sec = timePtr->sec;
	myTime.usec = timePtr->usec;

	if (myTime.sec != 0 || myTime.usec != 0) {
	    tclScaleTimeProcPtr(&myTime, tclTimeClientData);








	}


	myTimePtr = &myTime;
    } else {
	myTimePtr = NULL;
    }

    /*
     * Start notifier thread if necessary.
     */

    LOCK_NOTIFIER_INIT;
    if (!notifierCount) {
	Tcl_Panic("Tcl_WaitForEvent: notifier not initialized");


    }
    if (!notifierThread) {
	int result;
	pthread_attr_t attr;







	pthread_attr_init(&attr);
	pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	pthread_attr_setstacksize(&attr, 60 * 1024);
	result = pthread_create(&notifierThread, &attr,
		(void * (*)(void *))NotifierThreadProc, NULL);
	pthread_attr_destroy(&attr);





	if (result || !notifierThread) {
	    Tcl_Panic("Tcl_WaitForEvent: unable to start notifier thread");

	}
    }


    UNLOCK_NOTIFIER_INIT;

    /*
     * Place this thread on the list of interested threads, signal the
     * notifier thread, and wait for a response or a timeout.
     */












    LOCK_NOTIFIER;
    if (!tsdPtr->runLoop) {
	Tcl_Panic("Tcl_WaitForEvent: CFRunLoop not initialized");

    }
    waitForFiles = (tsdPtr->numFdBits > 0);
    if (myTimePtr != NULL && myTimePtr->sec == 0 && myTimePtr->usec == 0) {
	/*
	 * Cannot emulate a polling select with a polling condition variable.
	 * Instead, pretend to wait for files and tell the notifier thread
	 * what we are doing. The notifier thread makes sure it goes through
	 * select with its select mask in the same state as ours currently is.
	 * We block until that happens.
	 */


	waitForFiles = 1;



	tsdPtr->pollState = POLL_WANT;
	myTimePtr = NULL;
    } else {
	tsdPtr->pollState = 0;
    }

    if (waitForFiles) {
	/*
	 * Add the ThreadSpecificData structure of this thread to the list of
	 * ThreadSpecificData structures of all threads that are waiting on
	 * file events.


	 */

	tsdPtr->nextPtr = waitingListPtr;
	if (waitingListPtr) {
	    waitingListPtr->prevPtr = tsdPtr;
	}
	tsdPtr->prevPtr = 0;
	waitingListPtr = tsdPtr;
	tsdPtr->onList = 1;

	write(triggerPipe, "", 1);



    }








    FD_ZERO(&(tsdPtr->readyMasks.readable));
    FD_ZERO(&(tsdPtr->readyMasks.writable));
    FD_ZERO(&(tsdPtr->readyMasks.exceptional));

    if (!tsdPtr->eventReady) {
	CFTimeInterval waitTime;
	CFStringRef runLoopMode;

	if (myTimePtr == NULL) {
	    waitTime = 1.0e10;	/* Wait forever, as per CFRunLoop.c */
	} else {
	    waitTime = myTimePtr->sec + 1.0e-6 * myTimePtr->usec;
	}

	/*
	 * If the run loop is already running (e.g. if Tcl_WaitForEvent was
	 * called recursively), re-run it in a custom run loop mode containing
	 * only the source for the notifier thread, otherwise wakeups from
	 * other sources added to the common run loop modes might get lost.
	 */

	if ((runLoopMode = CFRunLoopCopyCurrentMode(tsdPtr->runLoop))) {
	    CFRelease(runLoopMode);
	    runLoopMode = tclEventsOnlyRunLoopMode;
	} else {
	    runLoopMode = kCFRunLoopDefaultMode;
	}
	UNLOCK_NOTIFIER;
	CFRunLoopRunInMode(runLoopMode, waitTime, TRUE);
	LOCK_NOTIFIER;
    }
    tsdPtr->eventReady = 0;

    if (waitForFiles && tsdPtr->onList) {
	/*
	 * Remove the ThreadSpecificData structure of this thread from the
	 * waiting list. Alert the notifier thread to recompute its select
	 * masks; skipping this caused a hang when trying to close a pipe
	 * which the notifier thread was still doing a select on.
	 */

	if (tsdPtr->prevPtr) {
	    tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
	} else {
	    waitingListPtr = tsdPtr->nextPtr;
	}
	if (tsdPtr->nextPtr) {
	    tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr;
	}
	tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
	tsdPtr->onList = 0;
	write(triggerPipe, "", 1);
    }

    /*
     * Queue all detected file events before returning.
     */

    for (filePtr = tsdPtr->firstFileHandlerPtr; (filePtr != NULL);
	    filePtr = filePtr->nextPtr) {
	mask = 0;

	if (FD_ISSET(filePtr->fd, &(tsdPtr->readyMasks.readable))) {
	    mask |= TCL_READABLE;
	}
	if (FD_ISSET(filePtr->fd, &(tsdPtr->readyMasks.writable))) {
	    mask |= TCL_WRITABLE;
	}
	if (FD_ISSET(filePtr->fd, &(tsdPtr->readyMasks.exceptional))) {
	    mask |= TCL_EXCEPTION;
	}

	if (!mask) {
	    continue;
	}

	/*
	 * Don't bother to queue an event if the mask was previously non-zero
	 * since an event must still be on the queue.
	 */

	if (filePtr->readyMask == 0) {
	    fileEvPtr = (FileHandlerEvent *)
		    ckalloc(sizeof(FileHandlerEvent));
	    fileEvPtr->header.proc = FileHandlerEventProc;
	    fileEvPtr->fd = filePtr->fd;
	    Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL);
	}
	filePtr->readyMask = mask;
    }


































    UNLOCK_NOTIFIER;






































































































































































































































































































































    return 0;
}

/*
 *----------------------------------------------------------------------
 *
 * NotifierThreadProc --
 *







>
>
>
>
>
>
>
>
>
>
>

















|
>


<
>








<
|
|
>
|





|
>
>


<
<
|
<
>
|
>
|
>
>






<
<
<
|
|
>
>
>
>
>
>
>
>
|
>
|
<
<
<


<
|
<

|
<
|
>
>
|
<
<
<
>
>
>
>
>
>

<
<
<
<
<
|
|
>
>
>
>
>
|
<
>
|
|
>
>
|
|
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
|
|
<
<
>
|
|
<
|
<
<
<
<
<
<
>
|
|
>
>
>
|
<
|
<
<
|
<
|
<
<
|
>
>
|

<
|
<
<
|
|
<
|
<
>
>
>
|
>
>
>

>
>
>
>



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
<
<
<

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


|
>
|


|


|


<










|







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







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
	 *    zeroed when a new file handler is created for the newly opened
	 *    file.
	 */

	mask = filePtr->readyMask & filePtr->mask;
	filePtr->readyMask = 0;
	if (mask != 0) {
	    LOCK_NOTIFIER_TSD;
	    if (mask & TCL_READABLE) {
		FD_CLR(filePtr->fd, &(tsdPtr->readyMasks.readable));
	    }
	    if (mask & TCL_WRITABLE) {
		FD_CLR(filePtr->fd, &(tsdPtr->readyMasks.writable));
	    }
	    if (mask & TCL_EXCEPTION) {
		FD_CLR(filePtr->fd, &(tsdPtr->readyMasks.exceptional));
	    }
	    UNLOCK_NOTIFIER_TSD;
	    filePtr->proc(filePtr->clientData, mask);
	}
	break;
    }
    return 1;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_WaitForEvent --
 *
 *	This function is called by Tcl_DoOneEvent to wait for new events on
 *	the message queue. If the block time is 0, then Tcl_WaitForEvent just
 *	polls without blocking.
 *
 * Results:
 *	Returns 0 if a tcl event or timeout ocurred and 1 if a non-tcl
 *	CFRunLoop source was processed.
 *
 * Side effects:

 *	None.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_WaitForEvent(
    const Tcl_Time *timePtr)		/* Maximum block time, or NULL. */
{

    int result, polling;
    CFTimeInterval waitTime;
    CFStringRef runLoopMode;
    SInt32 runLoopStatus;
    ThreadSpecificData *tsdPtr;

    if (tclNotifierHooks.waitForEventProc) {
	return tclNotifierHooks.waitForEventProc(timePtr);
    }
    result = -1;
    polling = 0;
    waitTime = CF_TIMEINTERVAL_FOREVER;
    tsdPtr = TCL_TSD_INIT(&dataKey);



    if (!tsdPtr->runLoop) {

	Tcl_Panic("Tcl_WaitForEvent: Notifier not initialized");
    }

    if (timePtr) {
	Tcl_Time vTime  = *timePtr;

	/*
	 * TIP #233 (Virtualized Time). Is virtual time in effect? And do we
	 * actually have something to scale? If yes to both then we call the
	 * handler to do this scaling.
	 */




	if (vTime.sec != 0 || vTime.usec != 0) {
	    tclScaleTimeProcPtr(&vTime, tclTimeClientData);
	    waitTime = vTime.sec + 1.0e-6 * vTime.usec;
	} else {
	    /*
	     * Polling: pretend to wait for files and tell the notifier thread
	     * what we are doing. The notifier thread makes sure it goes
	     * through select with its select mask in the same state as ours
	     * currently is. We block until that happens.
	     */

	    polling = 1;
	}



    }


    StartNotifierThread();


    LOCK_NOTIFIER_TSD;

    tsdPtr->polling = polling;
    UNLOCK_NOTIFIER_TSD;
    tsdPtr->runLoopSourcePerformed = 0;




    /*
     * If the Tcl run loop is already running (e.g. if Tcl_WaitForEvent was
     * called recursively), re-run it in a custom run loop mode containing only
     * the source for the notifier thread, otherwise wakeups from other sources
     * added to the common run loop modes might get lost.
     */






    if (tsdPtr->runLoopRunning) {
	runLoopMode = tclEventsOnlyRunLoopMode;
    } else {
	runLoopMode = kCFRunLoopDefaultMode;
	tsdPtr->runLoopRunning = 1;
    }
    runLoopStatus = CFRunLoopRunInMode(runLoopMode, waitTime, TRUE);
    if (runLoopMode == kCFRunLoopDefaultMode) {

	tsdPtr->runLoopRunning = 0;
    }

    LOCK_NOTIFIER_TSD;
    tsdPtr->polling = 0;
    UNLOCK_NOTIFIER_TSD;
    switch (runLoopStatus) {




    case kCFRunLoopRunFinished:
       Tcl_Panic("Tcl_WaitForEvent: CFRunLoop finished");
	break;
    case kCFRunLoopRunTimedOut:
	QueueFileEvents(tsdPtr);
	result = 0;
	break;
    case kCFRunLoopRunStopped:
    case kCFRunLoopRunHandledSource:
	result = tsdPtr->runLoopSourcePerformed ? 0 : 1;
	break;
    }



    return result;
}


/*






 *----------------------------------------------------------------------
 *
 * QueueFileEvents --
 *
 *	CFRunLoopSource callback for queueing file events.
 *
 * Results:

 *	None.


 *

 * Side effects:


 *	Queues file events that are detected by the select.
 *
 *----------------------------------------------------------------------
 */


static void


QueueFileEvents(
    void *info)

{

    SelectMasks readyMasks;
    FileHandler *filePtr;
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) info;

    /*
     * Queue all detected file events.
     */

    LOCK_NOTIFIER_TSD;
    FD_COPY(&(tsdPtr->readyMasks.readable), &readyMasks.readable);
    FD_COPY(&(tsdPtr->readyMasks.writable), &readyMasks.writable);
    FD_COPY(&(tsdPtr->readyMasks.exceptional), &readyMasks.exceptional);
    FD_ZERO(&(tsdPtr->readyMasks.readable));
    FD_ZERO(&(tsdPtr->readyMasks.writable));
    FD_ZERO(&(tsdPtr->readyMasks.exceptional));
























    UNLOCK_NOTIFIER_TSD;




    tsdPtr->runLoopSourcePerformed = 1;

























    for (filePtr = tsdPtr->firstFileHandlerPtr; (filePtr != NULL);
	    filePtr = filePtr->nextPtr) {
	int mask = 0;

	if (FD_ISSET(filePtr->fd, &readyMasks.readable)) {
	    mask |= TCL_READABLE;
	}
	if (FD_ISSET(filePtr->fd, &readyMasks.writable)) {
	    mask |= TCL_WRITABLE;
	}
	if (FD_ISSET(filePtr->fd, &readyMasks.exceptional)) {
	    mask |= TCL_EXCEPTION;
	}

	if (!mask) {
	    continue;
	}

	/*
	 * Don't bother to queue an event if the mask was previously non-zero
	 * since an event must still be on the queue.
	 */

	if (filePtr->readyMask == 0) {
	    FileHandlerEvent *fileEvPtr = (FileHandlerEvent *)
		    ckalloc(sizeof(FileHandlerEvent));
	    fileEvPtr->header.proc = FileHandlerEventProc;
	    fileEvPtr->fd = filePtr->fd;
	    Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL);
	}
	filePtr->readyMask = mask;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * UpdateWaitingListAndServiceEvents --
 *
 *	CFRunLoopObserver callback for updating waitingList and
 *	servicing Tcl events.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static void
UpdateWaitingListAndServiceEvents(
    CFRunLoopObserverRef observer,
    CFRunLoopActivity activity,
    void *info)
{
    ThreadSpecificData *tsdPtr = (ThreadSpecificData*) info;

    switch (activity) {
    case kCFRunLoopEntry:
	tsdPtr->runLoopNestingLevel++;
	if (tsdPtr->runLoopNestingLevel == 1 && !tsdPtr->sleeping &&
		(tsdPtr->numFdBits > 0 || tsdPtr->polling)) {
	    LOCK_NOTIFIER;
	    OnOffWaitingList(tsdPtr, 1, 1);
	    UNLOCK_NOTIFIER;
	}
	break;
    case kCFRunLoopExit:
	if (tsdPtr->runLoopNestingLevel == 1 && !tsdPtr->sleeping &&
		(tsdPtr->numFdBits > 0 || tsdPtr->polling)) {
	    LOCK_NOTIFIER;
	    OnOffWaitingList(tsdPtr, 0, 1);
	    UNLOCK_NOTIFIER;
	}
	tsdPtr->runLoopNestingLevel--;
	break;
    case kCFRunLoopBeforeWaiting:
	if (!tsdPtr->sleeping && tsdPtr->runLoopTimer &&
		(tsdPtr->runLoopNestingLevel > 1 || !tsdPtr->runLoopRunning)) {
	    while (Tcl_ServiceAll() && tsdPtr->waitTime == 0) {}
	}
	break;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * OnOffWaitingList --
 *
 *	Add/remove the specified thread to/from the global waitingList
 *	and optionally signal the notifier.
 *
 *	!!! Requires notifierLock to be held !!!
 *
 * Results:
 *	Boolean indicating whether the waitingList was changed.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static int
OnOffWaitingList(
    ThreadSpecificData *tsdPtr,
    int onList,
    int signalNotifier)
{
    int changeWaitingList;
#ifdef TCL_MAC_DEBUG_NOTIFIER
    if(SpinLockTry(&notifierLock)) {
	Tcl_Panic("OnOffWaitingList: notifierLock unlocked");
    }
#endif
    changeWaitingList = (!onList ^ !tsdPtr->onList);
    if (changeWaitingList) {
	if (onList) {
	    tsdPtr->nextPtr = waitingListPtr;
	    if (waitingListPtr) {
		waitingListPtr->prevPtr = tsdPtr;
	    }
	    tsdPtr->prevPtr = NULL;
	    waitingListPtr = tsdPtr;
	    tsdPtr->onList = 1;
	} else {
	    if (tsdPtr->prevPtr) {
		tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
	    } else {
		waitingListPtr = tsdPtr->nextPtr;
	    }
	    if (tsdPtr->nextPtr) {
		tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr;
	    }
	    tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
	    tsdPtr->onList = 0;
	}
	if (signalNotifier) {
	   write(triggerPipe, "", 1);
	}
    }

    return changeWaitingList;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_Sleep --
 *
 *	Delay execution for the specified number of milliseconds.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Time passes.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_Sleep(
    int ms)			/* Number of milliseconds to sleep. */
{
    Tcl_Time vdelay;
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    if (ms <= 0) {
	return;
    }

    /*
     * TIP #233: Scale from virtual time to real-time.
     */

    vdelay.sec  = ms / 1000;
    vdelay.usec = (ms % 1000) * 1000;
    tclScaleTimeProcPtr(&vdelay, tclTimeClientData);


    if (tsdPtr->runLoop) {
	CFTimeInterval waitTime;
	CFRunLoopTimerRef runLoopTimer = tsdPtr->runLoopTimer;
	CFAbsoluteTime nextTimerFire = 0, waitEnd, now;
	SInt32 runLoopStatus;

	waitTime = vdelay.sec + 1.0e-6 * vdelay.usec;
 	now = CFAbsoluteTimeGetCurrent();
	waitEnd = now + waitTime;

	if (runLoopTimer) {
	    nextTimerFire = CFRunLoopTimerGetNextFireDate(runLoopTimer);
	    if (nextTimerFire < waitEnd) {
		CFRunLoopTimerSetNextFireDate(runLoopTimer, now +
			CF_TIMEINTERVAL_FOREVER);
	    } else {
		runLoopTimer = NULL;
	    }
	}
	tsdPtr->sleeping = 1;
	do {
	    runLoopStatus = CFRunLoopRunInMode(kCFRunLoopDefaultMode, waitTime,
		    FALSE);
	    switch (runLoopStatus) {
	    case kCFRunLoopRunFinished:
		Tcl_Panic("Tcl_Sleep: CFRunLoop finished");
		break;
	    case kCFRunLoopRunStopped:
		TclMacOSXNotifierDbgMsg("CFRunLoop stopped");
		waitTime = waitEnd - CFAbsoluteTimeGetCurrent();
		break;
	    case kCFRunLoopRunTimedOut:
		waitTime = 0;
		break;
	    }
	} while (waitTime > 0);
	tsdPtr->sleeping = 0;
 	if (runLoopTimer) {
	    CFRunLoopTimerSetNextFireDate(runLoopTimer, nextTimerFire);
	}
    } else {
	struct timespec waitTime;

	waitTime.tv_sec = vdelay.sec;
	waitTime.tv_nsec = vdelay.usec * 1000;
	while (nanosleep(&waitTime, &waitTime));
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TclUnixWaitForFile --
 *
 *	This function waits synchronously for a file to become readable or
 *	writable, with an optional timeout.
 *
 * Results:
 *	The return value is an OR'ed combination of TCL_READABLE,
 *	TCL_WRITABLE, and TCL_EXCEPTION, indicating the conditions that are
 *	present on file at the time of the return. This function will not
 *	return until either "timeout" milliseconds have elapsed or at least
 *	one of the conditions given by mask has occurred for file (a return
 *	value of 0 means that a timeout occurred). No normal events will be
 *	serviced during the execution of this function.
 *
 * Side effects:
 *	Time passes.
 *
 *----------------------------------------------------------------------
 */

int
TclUnixWaitForFile(
    int fd,			/* Handle for file on which to wait. */
    int mask,			/* What to wait for: OR'ed combination of
				 * TCL_READABLE, TCL_WRITABLE, and
				 * TCL_EXCEPTION. */
    int timeout)		/* Maximum amount of time to wait for one of
				 * the conditions in mask to occur, in
				 * milliseconds. A value of 0 means don't wait
				 * at all, and a value of -1 means wait
				 * forever. */
{
    Tcl_Time abortTime = {0, 0}, now; /* silence gcc 4 warning */
    struct timeval blockTime, *timeoutPtr;
    int index, numFound, result = 0;
    fd_mask bit;
    fd_mask readyMasks[3*MASK_SIZE];
    fd_mask *maskp[3];		/* This array reflects the readable/writable
				 * conditions that were found to exist by the
				 * last call to select. */

#define SET_BITS(var, bits)	((var) |= (bits))
#define CLEAR_BITS(var, bits)	((var) &= ~(bits))

    /*
     * If there is a non-zero finite timeout, compute the time when we give
     * up.
     */

    if (timeout > 0) {
	Tcl_GetTime(&now);
	abortTime.sec = now.sec + timeout/1000;
	abortTime.usec = now.usec + (timeout%1000)*1000;
	if (abortTime.usec >= 1000000) {
	    abortTime.usec -= 1000000;
	    abortTime.sec += 1;
	}
	timeoutPtr = &blockTime;
    } else if (timeout == 0) {
	timeoutPtr = &blockTime;
	blockTime.tv_sec = 0;
	blockTime.tv_usec = 0;
    } else {
	timeoutPtr = NULL;
    }

    /*
     * Initialize the ready masks and compute the mask offsets.
     */

    if (fd >= FD_SETSIZE) {
	Tcl_Panic("TclWaitForFile can't handle file id %d", fd);
	/* must never get here, or readyMasks overrun will occur below */
    }
    memset(readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
    index = fd / (NBBY*sizeof(fd_mask));
    bit = ((fd_mask)1) << (fd % (NBBY*sizeof(fd_mask)));

    /*
     * Loop in a mini-event loop of our own, waiting for either the file to
     * become ready or a timeout to occur.
     */

    while (1) {
	if (timeout > 0) {
	    blockTime.tv_sec = abortTime.sec - now.sec;
	    blockTime.tv_usec = abortTime.usec - now.usec;
	    if (blockTime.tv_usec < 0) {
		blockTime.tv_sec -= 1;
		blockTime.tv_usec += 1000000;
	    }
	    if (blockTime.tv_sec < 0) {
		blockTime.tv_sec = 0;
		blockTime.tv_usec = 0;
	    }
	}

	/*
	 * Set the appropriate bit in the ready masks for the fd.
	 */

	if (mask & TCL_READABLE) {
	    readyMasks[index] |= bit;
	}
	if (mask & TCL_WRITABLE) {
	    (readyMasks+MASK_SIZE)[index] |= bit;
	}
	if (mask & TCL_EXCEPTION) {
	    (readyMasks+2*(MASK_SIZE))[index] |= bit;
	}

	/*
	 * Wait for the event or a timeout.
	 */

	/*
	 * This is needed to satisfy GCC 3.3's strict aliasing rules.
	 */

	maskp[0] = &readyMasks[0];
	maskp[1] = &readyMasks[MASK_SIZE];
	maskp[2] = &readyMasks[2*MASK_SIZE];
	numFound = select(fd+1, (SELECT_MASK *) maskp[0],
		(SELECT_MASK *) maskp[1],
		(SELECT_MASK *) maskp[2], timeoutPtr);
	if (numFound == 1) {
	    if (readyMasks[index] & bit) {
		SET_BITS(result, TCL_READABLE);
	    }
	    if ((readyMasks+MASK_SIZE)[index] & bit) {
		SET_BITS(result, TCL_WRITABLE);
	    }
	    if ((readyMasks+2*(MASK_SIZE))[index] & bit) {
		SET_BITS(result, TCL_EXCEPTION);
	    }
	    result &= mask;
	    if (result) {
		break;
	    }
	}
	if (timeout == 0) {
	    break;
	}
	if (timeout < 0) {
	    continue;
	}

	/*
	 * The select returned early, so we need to recompute the timeout.
	 */

	Tcl_GetTime(&now);
	if ((abortTime.sec < now.sec)
		|| (abortTime.sec==now.sec && abortTime.usec<=now.usec)) {
	    break;
	}
    }
    return result;
}

/*
 *----------------------------------------------------------------------
 *
 * NotifierThreadProc --
 *
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
 */

static void
NotifierThreadProc(
    ClientData clientData)	/* Not used. */
{
    ThreadSpecificData *tsdPtr;
    fd_set readableMask;
    fd_set writableMask;
    fd_set exceptionalMask;
    int i, numFdBits = 0;
    long found;
    struct timeval poll = {0., 0.}, *timePtr;
    char buf[2];

    /*
     * Look for file events and report them to interested threads.
     */

    while (1) {
	FD_ZERO(&readableMask);
	FD_ZERO(&writableMask);
	FD_ZERO(&exceptionalMask);

	/*
	 * Compute the logical OR of the select masks from all the waiting
	 * notifiers.
	 */

	LOCK_NOTIFIER;
	timePtr = NULL;

	for (tsdPtr = waitingListPtr; tsdPtr; tsdPtr = tsdPtr->nextPtr) {

	    for (i = tsdPtr->numFdBits-1; i >= 0; --i) {
		if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))) {
		    FD_SET(i, &readableMask);
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.writable))) {
		    FD_SET(i, &writableMask);
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		    FD_SET(i, &exceptionalMask);
		}
	    }
	    if (tsdPtr->numFdBits > numFdBits) {
		numFdBits = tsdPtr->numFdBits;
	    }
	    if (tsdPtr->pollState & POLL_WANT) {
		/*
		 * Here we make sure we go through select() with the same mask
		 * bits that were present when the thread tried to poll.
		 */

		tsdPtr->pollState |= POLL_DONE;
		timePtr = &poll;
	    }
	}
	UNLOCK_NOTIFIER;

	/*
	 * Set up the select mask to include the receive pipe.







|
<
<
|
<

















<

>

>














|
<
<
<
<
|
|







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
 */

static void
NotifierThreadProc(
    ClientData clientData)	/* Not used. */
{
    ThreadSpecificData *tsdPtr;
    fd_set readableMask, writableMask, exceptionalMask;


    int i, numFdBits = 0, polling;

    struct timeval poll = {0., 0.}, *timePtr;
    char buf[2];

    /*
     * Look for file events and report them to interested threads.
     */

    while (1) {
	FD_ZERO(&readableMask);
	FD_ZERO(&writableMask);
	FD_ZERO(&exceptionalMask);

	/*
	 * Compute the logical OR of the select masks from all the waiting
	 * notifiers.
	 */


	timePtr = NULL;
	LOCK_NOTIFIER;
	for (tsdPtr = waitingListPtr; tsdPtr; tsdPtr = tsdPtr->nextPtr) {
	    LOCK_NOTIFIER_TSD;
	    for (i = tsdPtr->numFdBits-1; i >= 0; --i) {
		if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))) {
		    FD_SET(i, &readableMask);
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.writable))) {
		    FD_SET(i, &writableMask);
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		    FD_SET(i, &exceptionalMask);
		}
	    }
	    if (tsdPtr->numFdBits > numFdBits) {
		numFdBits = tsdPtr->numFdBits;
	    }
	    polling = tsdPtr->polling;




	    UNLOCK_NOTIFIER_TSD;
	    if ((tsdPtr->polled = polling)) {
		timePtr = &poll;
	    }
	}
	UNLOCK_NOTIFIER;

	/*
	 * Set up the select mask to include the receive pipe.
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

	/*
	 * Alert any threads that are waiting on a ready file descriptor.
	 */

	LOCK_NOTIFIER;
	for (tsdPtr = waitingListPtr; tsdPtr; tsdPtr = tsdPtr->nextPtr) {
	    found = 0;












	    for (i = tsdPtr->numFdBits-1; i >= 0; --i) {
		if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
			&& FD_ISSET(i, &readableMask)) {
		    FD_SET(i, &(tsdPtr->readyMasks.readable));
		    found = 1;
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.writable))
			&& FD_ISSET(i, &writableMask)) {
		    FD_SET(i, &(tsdPtr->readyMasks.writable));
		    found = 1;
		}
		if (FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))
			&& FD_ISSET(i, &exceptionalMask)) {
		    FD_SET(i, &(tsdPtr->readyMasks.exceptional));
		    found = 1;
		}
	    }




	    if (found || (tsdPtr->pollState & POLL_DONE)) {


		tsdPtr->eventReady = 1;
		if (tsdPtr->onList) {
		    /*
		     * Remove the ThreadSpecificData structure of this thread
		     * from the waiting list. This prevents us from spinning
		     * continuously on select until the other threads runs and
		     * services the file event.
		     */

		    if (tsdPtr->prevPtr) {
			tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
		    } else {
			waitingListPtr = tsdPtr->nextPtr;
		    }

		    if (tsdPtr->nextPtr) {
			tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr;
		    }
		    tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
		    tsdPtr->onList = 0;

		    tsdPtr->pollState = 0;
		}
		if (tsdPtr->runLoop) {
		    CFRunLoopSourceSignal(tsdPtr->runLoopSource);
		    CFRunLoopWakeUp(tsdPtr->runLoop);
		}
	    }
	}
	UNLOCK_NOTIFIER;







|
>

>
>
>
>
>
>
>
>
>
>

|

|


|

|

<
<
<
<
<
<
<
|
>
>
>
|
>
>
|
|
|
|
|
|
|
|

<
<
<
|
|
>
|
|
<
<
|
>
|
<







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

	/*
	 * Alert any threads that are waiting on a ready file descriptor.
	 */

	LOCK_NOTIFIER;
	for (tsdPtr = waitingListPtr; tsdPtr; tsdPtr = tsdPtr->nextPtr) {
	    int found = 0;
	    SelectMasks readyMasks, checkMasks;

	    LOCK_NOTIFIER_TSD;
	    FD_COPY(&(tsdPtr->checkMasks.readable), &checkMasks.readable);
	    FD_COPY(&(tsdPtr->checkMasks.writable), &checkMasks.writable);
	    FD_COPY(&(tsdPtr->checkMasks.exceptional), &checkMasks.exceptional);
	    UNLOCK_NOTIFIER_TSD;
	    found = tsdPtr->polled;
	    FD_ZERO(&readyMasks.readable);
	    FD_ZERO(&readyMasks.writable);
	    FD_ZERO(&readyMasks.exceptional);

	    for (i = tsdPtr->numFdBits-1; i >= 0; --i) {
		if (FD_ISSET(i, &checkMasks.readable)
			&& FD_ISSET(i, &readableMask)) {
		    FD_SET(i, &readyMasks.readable);
		    found = 1;
		}
		if (FD_ISSET(i, &checkMasks.writable)
			&& FD_ISSET(i, &writableMask)) {
		    FD_SET(i, &readyMasks.writable);
		    found = 1;







		}
		if (FD_ISSET(i, &checkMasks.exceptional)
			&& FD_ISSET(i, &exceptionalMask)) {
		    FD_SET(i, &readyMasks.exceptional);
		    found = 1;
		}
	    }

	    if (found) {
		/*
		 * Remove the ThreadSpecificData structure of this thread from
		 * the waiting list. This prevents us from spinning
		 * continuously on select until the other threads runs and
		 * services the file event.
		 */




		OnOffWaitingList(tsdPtr, 0, 0);

		LOCK_NOTIFIER_TSD;
		FD_COPY(&readyMasks.readable, &(tsdPtr->readyMasks.readable));
		FD_COPY(&readyMasks.writable, &(tsdPtr->readyMasks.writable));


		FD_COPY(&readyMasks.exceptional, &(tsdPtr->readyMasks.exceptional));
		UNLOCK_NOTIFIER_TSD;
		tsdPtr->polled = 0;

		if (tsdPtr->runLoop) {
		    CFRunLoopSourceSignal(tsdPtr->runLoopSource);
		    CFRunLoopWakeUp(tsdPtr->runLoop);
		}
	    }
	}
	UNLOCK_NOTIFIER;
1300
1301
1302
1303
1304
1305
1306


1307
1308

1309
1310
1311
1312
1313
1314
1315
 *
 *----------------------------------------------------------------------
 */

static void
AtForkPrepare(void)
{


    LOCK_NOTIFIER_INIT;
    LOCK_NOTIFIER;

}

/*
 *----------------------------------------------------------------------
 *
 * AtForkParent --
 *







>
>


>







1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
 *
 *----------------------------------------------------------------------
 */

static void
AtForkPrepare(void)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    LOCK_NOTIFIER_INIT;
    LOCK_NOTIFIER;
    LOCK_NOTIFIER_TSD;
}

/*
 *----------------------------------------------------------------------
 *
 * AtForkParent --
 *
1323
1324
1325
1326
1327
1328
1329



1330
1331
1332
1333
1334
1335
1336
 *
 *----------------------------------------------------------------------
 */

static void
AtForkParent(void)
{



    UNLOCK_NOTIFIER;
    UNLOCK_NOTIFIER_INIT;
}

/*
 *----------------------------------------------------------------------
 *







>
>
>







1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
 *
 *----------------------------------------------------------------------
 */

static void
AtForkParent(void)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    UNLOCK_NOTIFIER_TSD;
    UNLOCK_NOTIFIER;
    UNLOCK_NOTIFIER_INIT;
}

/*
 *----------------------------------------------------------------------
 *
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
 */

static void
AtForkChild(void)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);


    UNLOCK_NOTIFIER;
    UNLOCK_NOTIFIER_INIT;
    if (tsdPtr->runLoop) {
	tsdPtr->runLoop = NULL;
	if (!noCFafterFork) {
	    CFRunLoopSourceInvalidate(tsdPtr->runLoopSource);




	}

	CFRelease(tsdPtr->runLoopSource);
	tsdPtr->runLoopSource = NULL;
    }
    if (notifierCount > 0) {
	notifierCount = 0;


	/*
	 * Assume that the return value of Tcl_InitNotifier in the child will
	 * be identical to the one stored as clientData in tclNotify.c's
	 * ThreadSpecificData by the parent's TclInitNotifier, so discard the
	 * return value here. This assumption may require the fork() to be
	 * executed in the main thread of the parent, otherwise
	 * Tcl_AlertNotifier may break in the child.
	 */

	if (!noCFafterFork) {
	    Tcl_InitNotifier();
	}
    }
}
#endif /* HAVE_PTHREAD_ATFORK */











#endif /* HAVE_COREFOUNDATION */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */







>






>
>
>
>
|
>
|
|


|
>
















>
>
>
>
>
>
>
>
>
>










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
 */

static void
AtForkChild(void)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    UNLOCK_NOTIFIER_TSD;
    UNLOCK_NOTIFIER;
    UNLOCK_NOTIFIER_INIT;
    if (tsdPtr->runLoop) {
	tsdPtr->runLoop = NULL;
	if (!noCFafterFork) {
	    CFRunLoopSourceInvalidate(tsdPtr->runLoopSource);
	    CFRelease(tsdPtr->runLoopSource);
	    if (tsdPtr->runLoopTimer) {
		CFRunLoopTimerInvalidate(tsdPtr->runLoopTimer);
		CFRelease(tsdPtr->runLoopTimer);
	    }
	}
	tsdPtr->runLoopSource = NULL;
	tsdPtr->runLoopTimer = NULL;
    }
    if (notifierCount > 0) {
	notifierCount = 1;
	notifierThreadRunning = 0;

	/*
	 * Assume that the return value of Tcl_InitNotifier in the child will
	 * be identical to the one stored as clientData in tclNotify.c's
	 * ThreadSpecificData by the parent's TclInitNotifier, so discard the
	 * return value here. This assumption may require the fork() to be
	 * executed in the main thread of the parent, otherwise
	 * Tcl_AlertNotifier may break in the child.
	 */

	if (!noCFafterFork) {
	    Tcl_InitNotifier();
	}
    }
}
#endif /* HAVE_PTHREAD_ATFORK */

#else /* HAVE_COREFOUNDATION */

void
TclMacOSXNotifierAddRunLoopMode(
    CONST void *runLoopMode)
{
    Tcl_Panic("TclMacOSXNotifierAddRunLoopMode: "
	    "Tcl not built with CoreFoundation support");
}

#endif /* HAVE_COREFOUNDATION */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
Changes to tests/http.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Ajuba Solutions.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#
# RCS: @(#) $Id: http.test,v 1.33.4.11 2008/12/10 13:52:04 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if {[catch {package require http 2} version]} {







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-2000 by Ajuba Solutions.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#
# RCS: @(#) $Id: http.test,v 1.33.4.12 2009/04/10 18:09:30 dgp Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if {[catch {package require http 2} version]} {
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
	return
    } else {
	set port [lindex [fconfigure $listen -sockname] 2]
    }
}

test http-1.1 {http::config} {

    http::config
} [list -accept */* -proxyfilter http::ProxyRequired -proxyhost {} -proxyport {} -urlencoding utf-8 -useragent "Tcl http client package $version"]
test http-1.2 {http::config} {
    http::config -proxyfilter
} http::ProxyRequired
test http-1.3 {http::config} {
    catch {http::config -junk}
} 1
test http-1.4 {http::config} {







>

|







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
	return
    } else {
	set port [lindex [fconfigure $listen -sockname] 2]
    }
}

test http-1.1 {http::config} {
    http::config -useragent UserAgent
    http::config
} [list -accept */* -proxyfilter http::ProxyRequired -proxyhost {} -proxyport {} -urlencoding utf-8 -useragent "UserAgent"]
test http-1.2 {http::config} {
    http::config -proxyfilter
} http::ProxyRequired
test http-1.3 {http::config} {
    catch {http::config -junk}
} 1
test http-1.4 {http::config} {
326
327
328
329
330
331
332










333
334
335
336
337
338
339
} -returnCodes error -result {Illegal encoding character usage "%pa" in URL path}
test http-3.23 {http::geturl parse failures} -body {
    http::geturl http://somewhere/path?{query}
} -returnCodes error -result {Illegal characters in URL path}
test http-3.24 {http::geturl parse failures} -body {
    http::geturl http://somewhere/path?%query
} -returnCodes error -result {Illegal encoding character usage "%qu" in URL path}











test http-4.1 {http::Event} {
    set token [http::geturl $url -keepalive 0]
    upvar #0 $token data
    array set meta $data(meta)
    expr {($data(totalsize) == $meta(Content-Length))}
} 1







>
>
>
>
>
>
>
>
>
>







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
} -returnCodes error -result {Illegal encoding character usage "%pa" in URL path}
test http-3.23 {http::geturl parse failures} -body {
    http::geturl http://somewhere/path?{query}
} -returnCodes error -result {Illegal characters in URL path}
test http-3.24 {http::geturl parse failures} -body {
    http::geturl http://somewhere/path?%query
} -returnCodes error -result {Illegal encoding character usage "%qu" in URL path}
test http-3.25 {http::meta} {
    set token [http::geturl $url -timeout 2000]
    array set m [http::meta $token]
    lsort [array names m]
} {Content-Length Content-Type Date}
test http-3.26 {http::meta} {
    set token [http::geturl $url -headers {X-Check 1} -timeout 2000]
    array set m [http::meta $token]
    lsort [array names m]
} {Content-Length Content-Type Date X-Check}

test http-4.1 {http::Event} {
    set token [http::geturl $url -keepalive 0]
    upvar #0 $token data
    array set meta $data(meta)
    expr {($data(totalsize) == $meta(Content-Length))}
} 1
527
528
529
530
531
532
533





if {[info exists removeHttpd]} {
    removeFile $httpdFile
}

rename bgerror {}
::tcltest::cleanupTests











>
>
>
>
538
539
540
541
542
543
544
545
546
547
548

if {[info exists removeHttpd]} {
    removeFile $httpdFile
}

rename bgerror {}
::tcltest::cleanupTests

# Local variables:
# mode: tcl
# End:
Added tests/http11.test.






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# http11.test --                                                -*- tcl-*-
#
#	Test HTTP/1.1 features.
#
# Copyright (C) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

package require tcltest 2
namespace import -force ::tcltest::*

package require http 2.8

# start the server
variable httpd_output
proc create_httpd {} {
    proc httpd_read {chan} {
        variable httpd_output
        if {[gets $chan line] != -1} {
            #puts stderr "read '$line'"
            set httpd_output $line
        }
        if {[eof $chan]} {
            puts stderr "eof from httpd"
            fileevent $chan readable {}
            close $chan
        }
    }
    variable httpd_output
    set httpd_script [file join [pwd] [file dirname [info script]] httpd11.tcl]
    set httpd [open "|[list [interpreter] -encoding utf-8 $httpd_script]" r+]
    fconfigure $httpd -buffering line -blocking 0
    fileevent $httpd readable [list httpd_read $httpd]
    vwait httpd_output
    variable httpd_port [lindex $httpd_output 2]
    return $httpd
}

proc halt_httpd {} {
    variable httpd_output
    variable httpd
    if {[info exists httpd]} {
        puts $httpd "quit"
        vwait httpd_output
        close $httpd
    }
    unset -nocomplain httpd_output httpd
}

proc meta {tok {key ""}} {
    set meta [http::meta $tok]
    if {$key ne ""} {
        if {[dict exists $meta $key]} {
            return [dict get $meta $key]
        } else {
            return ""
        }
    }
    return $meta
}

proc check_crc {tok args} {
    set crc [meta $tok x-crc32]
    if {[llength $args]} {set data [lindex $args 0]} else {set data [http::data $tok]}
    set chk [format %x [zlib crc32 $data]]
    if {$crc ne $chk} {
        return  "crc32 mismatch: $crc ne $chk"
    }
    return "ok"
}

makeFile "<html><head><title>test</title></head>\
<body><p>this is a test</p>\n\
[string repeat {<p>This is a tcl test file.</p>} 4192]\n\
</body></html>" testdoc.html

# -------------------------------------------------------------------------

test http-1.0 "normal request for document " -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html -timeout 10000]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] [meta $tok connection]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close}

test http-1.1 "normal,gzip,non-chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -headers {accept-encoding gzip}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok gzip {}}

test http-1.2 "normal,deflated,non-chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -headers {accept-encoding deflate}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok deflate {}}

test http-1.3 "normal,compressed,non-chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -headers {accept-encoding compress}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok compress {}}

test http-1.4 "normal,identity,non-chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -headers {accept-encoding identity}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {} {}}

test http-1.5 "normal request for document, unsupported coding" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -headers {accept-encoding unsupported}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {}}

test http-1.6 "normal, specify 1.1 " -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -protocol 1.1 -timeout 10000]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok connection] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close chunked}

test http-1.7 "normal, 1.1 and keepalive " -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -protocol 1.1 -keepalive 1 -timeout 10000]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok connection] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {} chunked}

test http-1.8 "normal, 1.1 and keepalive, server close" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -protocol 1.1 -keepalive 1 -timeout 10000]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok connection] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close {}}

test http-1.9 "normal,gzip,chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -headers {accept-encoding gzip}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok gzip chunked}

test http-1.10 "normal,deflate,chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -headers {accept-encoding deflate}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok deflate chunked}

test http-1.11 "normal,compress,chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -headers {accept-encoding compress}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok compress chunked}

test http-1.11 "normal,identity,chunked" -setup {
    variable httpd [create_httpd]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -headers {accept-encoding identity}]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok] \
        [meta $tok content-encoding] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {} chunked}

# -------------------------------------------------------------------------

test http-2.0 "-channel" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close chunked}

test http-2.1 "-channel, encoding gzip" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan -headers {accept-encoding gzip}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close gzip chunked}

test http-2.2 "-channel, encoding deflate" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan -headers {accept-encoding deflate}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close deflate chunked}

test http-2.3 "-channel,encoding compress" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan \
                 -headers {accept-encoding compress}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close compress chunked}

test http-2.4 "-channel,encoding identity" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan \
                 -headers {accept-encoding identity}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close {} chunked}

test http-2.5 "-channel,encoding unsupported" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan \
                 -headers {accept-encoding unsupported}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close {} chunked}

test http-2.6 "-channel,encoding gzip,non-chunked" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 5000 -channel $chan -headers {accept-encoding gzip}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]\
        [expr {[file size testdoc.html]-[file size testfile.tmp]}]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close gzip {} 0}

test http-2.7 "-channel,encoding deflate,non-chunked" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 5000 -channel $chan -headers {accept-encoding deflate}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]\
        [expr {[file size testdoc.html]-[file size testfile.tmp]}]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close deflate {} 0}

test http-2.8 "-channel,encoding compress,non-chunked" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 5000 -channel $chan -headers {accept-encoding compress}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]\
        [expr {[file size testdoc.html]-[file size testfile.tmp]}]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close compress {} 0}

test http-2.9 "-channel,encoding identity,non-chunked" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 5000 -channel $chan -headers {accept-encoding identity}]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]\
        [expr {[file size testdoc.html]-[file size testfile.tmp]}]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok close {} {} 0}

test http-2.10 "-channel,deflate,keepalive" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 5000 -channel $chan -keepalive 1]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]\
        [expr {[file size testdoc.html]-[file size testfile.tmp]}]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {} deflate chunked 0}

test http-2.11 "-channel,identity,keepalive" -setup {
    variable httpd [create_httpd]
    set chan [open [makeFile {} testfile.tmp] wb+]
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -headers {accept-encoding identity} \
                 -timeout 5000 -channel $chan -keepalive 1]
    http::wait $tok
    seek $chan 0
    set data [read $chan]
    list [http::status $tok] [http::code $tok] [check_crc $tok $data]\
        [meta $tok connection] [meta $tok content-encoding]\
        [meta $tok transfer-encoding]
} -cleanup {
    http::cleanup $tok
    close $chan
    removeFile testfile.tmp
    halt_httpd
} -result {ok {HTTP/1.1 200 OK} ok {} {} chunked}

# -------------------------------------------------------------------------
#
# The following tests for the -handler option will require changes in
# the future. At the moment we cannot handler chunked data with this
# option. Therefore we currently force HTTP/1.0 protocol version.
#
# Once this is solved, these tests should be fixed to assume chunked
# returns in 3.2 and 3.3 and HTTP/1.1 in all but test 3.1

proc handler {var sock token} {
    upvar #0 $var data
    set chunk [read $sock]
    append data $chunk
    #::http::Log "handler read [string length $chunk] ([chan configure $sock -buffersize])"
    if {[eof $sock]} {
        #::http::Log "handler eof $sock"
	chan event $sock readable {}
    }
}

test http-3.0 "-handler,close,identity" -setup {
    variable httpd [create_httpd]
    set testdata ""
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -handler [namespace code [list handler testdata]]]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\
        [meta $tok connection] [meta $tok content-encoding] \
        [meta $tok transfer-encoding] \
        [expr {[file size testdoc.html]-[string length $testdata]}]
} -cleanup {
    http::cleanup $tok
    unset -nocomplain testdata
    halt_httpd
} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0}

test http-3.1 "-handler,protocol1.0" -setup {
    variable httpd [create_httpd]
    set testdata ""
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html?close=1 \
                 -timeout 10000 -protocol 1.0 \
                 -handler [namespace code [list handler testdata]]]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\
        [meta $tok connection] [meta $tok content-encoding] \
        [meta $tok transfer-encoding] \
        [expr {[file size testdoc.html]-[string length $testdata]}]
} -cleanup {
    http::cleanup $tok
    unset -nocomplain testdata
    halt_httpd
} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0}

test http-3.2 "-handler,close,chunked" -setup {
    variable httpd [create_httpd]
    set testdata ""
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -keepalive 0 -binary 1\
                 -handler [namespace code [list handler testdata]]]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\
        [meta $tok connection] [meta $tok content-encoding] \
        [meta $tok transfer-encoding] \
        [expr {[file size testdoc.html]-[string length $testdata]}]
} -cleanup {
    http::cleanup $tok
    unset -nocomplain testdata
    halt_httpd
} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0}

test http-3.3 "-handler,keepalive,chunked" -setup {
    variable httpd [create_httpd]
    set testdata ""
} -body {
    set tok [http::geturl http://localhost:$httpd_port/testdoc.html \
                 -timeout 10000 -keepalive 1 -binary 1\
                 -handler [namespace code [list handler testdata]]]
    http::wait $tok
    list [http::status $tok] [http::code $tok] [check_crc $tok $testdata]\
        [meta $tok connection] [meta $tok content-encoding] \
        [meta $tok transfer-encoding] \
        [expr {[file size testdoc.html]-[string length $testdata]}]
} -cleanup {
    http::cleanup $tok
    unset -nocomplain testdata
    halt_httpd
} -result {ok {HTTP/1.0 200 OK} ok close {} {} 0}

# -------------------------------------------------------------------------

unset -nocomplain httpd_port
::tcltest::cleanupTests
Changes to tests/httpd.
68
69
70
71
72
73
74




75
76
77
78
79
80
81
	}
	return
    } elseif {$data(state) == "mime"} {

	# Read the HTTP headers

	set readCount [gets $sock line]




    } elseif {$data(state) == "query"} {

	# Read the query data

	if {![info exists data(length_orig)]} {
	    set data(length_orig) $data(length)
	}







>
>
>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	}
	return
    } elseif {$data(state) == "mime"} {

	# Read the HTTP headers

	set readCount [gets $sock line]
        if {[regexp {^([^:]+):(.*)$} $line -> key val]} {
            lappend data(meta) $key [string trim $val]
        }

    } elseif {$data(state) == "query"} {

	# Read the query data

	if {![info exists data(length_orig)]} {
	    set data(length_orig) $data(length)
	}
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
		append html </dl>\n
	    }
	    append html </body></html>
	}
    }

    # Catch errors from premature client closes

    catch {
	if {$data(proto) == "HEAD"} {
	    puts $sock "HTTP/1.0 200 OK"
	} else {



	    puts $sock "HTTP/1.0 200 Data follows"
	}
	puts $sock "Date: [clock format [clock seconds] \
                              -format {%a, %d %b %Y %H:%M:%S %Z}]"
	puts $sock "Content-Type: $type"
	puts $sock "Content-Length: [string length $html]"





	puts $sock ""
	flush $sock
	if {$data(proto) != "HEAD"} {
	    fconfigure $sock -translation binary
	    puts -nonewline $sock $html
	}
    }
    httpd_log $sock Done ""
    httpdSockDone $sock
}







|




>
>
>
|





>
>
>
>
>










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
		append html </dl>\n
	    }
	    append html </body></html>
	}
    }

    # Catch errors from premature client closes
    
    catch {
	if {$data(proto) == "HEAD"} {
	    puts $sock "HTTP/1.0 200 OK"
	} else {
            # Split the response to test for [Bug 26245326]
	    puts -nonewline $sock "HT"
            flush $sock
            puts $sock "TP/1.0 200 Data follows"
	}
	puts $sock "Date: [clock format [clock seconds] \
                              -format {%a, %d %b %Y %H:%M:%S %Z}]"
	puts $sock "Content-Type: $type"
	puts $sock "Content-Length: [string length $html]"
        foreach {key val} $data(meta) {
            if {[string match "X-*" $key]} {
                puts $sock "$key: $val"
            }
        }
	puts $sock ""
	flush $sock
	if {$data(proto) != "HEAD"} {
	    fconfigure $sock -translation binary
	    puts -nonewline $sock $html
	}
    }
    httpd_log $sock Done ""
    httpdSockDone $sock
}
Added tests/httpd11.tcl.


































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# httpd11.tcl --                                                -*- tcl -*-
#
#	A simple httpd for testing HTTP/1.1 client features.
#	Not suitable for use on a internet connected port.
#
# Copyright (C) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

package require Tcl 8.6

proc ::tcl::dict::get? {dict key} {
    if {[dict exists $dict $key]} {
        return [dict get $dict $key]
    }
    return
}
namespace ensemble configure dict \
    -map [linsert [namespace ensemble configure dict -map] end get? ::tcl::dict::get?]

proc make-chunk-generator {data {size 4096}} {
    variable _chunk_gen_uid
    if {![info exists _chunk_gen_uid]} {set _chunk_gen_uid 0}
    set lambda {{data size} {
        set pos 0
        yield
        while {1} {
            set payload [string range $data $pos [expr {$pos + $size - 1}]]
            incr pos $size
            set chunk [format %x [string length $payload]]\r\n$payload\r\n
            yield $chunk
            if {![string length $payload]} {return}
        }
    }}
    set name chunker[incr _chunk_gen_uid]
    coroutine $name ::apply $lambda $data $size
    return $name
}

proc get-chunks {data {compression gzip}} {
    switch -exact -- $compression {
        gzip     { set data [zlib gzip $data] }
        deflate  { set data [zlib deflate $data] }
        compress { set data [zlib compress $data] }
    }
    
    set data ""
    set chunker [make-chunk-generator $data 512]
    while {[string length [set chunk [$chunker]]]} {
        append data $chunk
    }
    return $data
}

proc blow-chunks {data {ochan stdout} {compression gzip}} {
    switch -exact -- $compression {
        gzip     { set data [zlib gzip $data] }
        deflate  { set data [zlib deflate $data] }
        compress { set data [zlib compress $data] }
    }
    
    set chunker [make-chunk-generator $data 512]
    while {[string length [set chunk [$chunker]]]} {
        puts -nonewline $ochan $chunk
    }
    return
}

proc mime-type {filename} {
    switch -exact -- [file extension $filename] {
        .htm - .html { return {text text/html}}
        .png { return {binary image/png} }
        .jpg { return {binary image/jpeg} }
        .gif { return {binary image/gif} }
        .css { return {text   text/css} }
        .xml { return {text   text/xml} }
        .xhtml {return {text  application/xml+html} }
        .svg { return {text image/svg+xml} }
        .txt - .tcl - .c - .h { return {text text/plain}}
    }
    return {binary text/plain}
}

proc Puts {chan s} {puts $chan $s; puts $s}

proc Service {chan addr port} {
    chan event $chan readable [info coroutine]
    while {1} {
        set meta {}
        chan configure $chan -buffering line -encoding iso8859-1 -translation crlf
        yield
        while {[gets $chan line] < 0} {
            if {[eof $chan]} {chan event $chan readable {}; close $chan; return}
            yield
        }
        if {[eof $chan]} {chan event $chan readable {}; close $chan; return}
        foreach {req url protocol} {GET {} HTTP/1.1} break
        regexp {^(\S+)\s+(.*)\s(\S+)?$} $line -> req url protocol

        puts $line
        while {[gets $chan line] > 0} {
            if {[regexp {^([^:]+):(.*)$} $line -> key val]} {
                #puts "$key $val"
                lappend meta [string tolower $key] [string trim $val]
            }
            yield
        }

        if {[scan $url {%[^?]?%s} path query] < 2} {
            set query ""
        }
            
        set encoding identity
        set transfer ""
        set close 1
        set type text/html
        set code "404 Not Found"
        set data "<html><head><title>Error 404</title></head>"
        append data "<body><h1>Not Found</h1><p>Try again.</p></body></html>"

        set path [string trimleft $path /]
        set path [file join [pwd] $path]
        if {[file exists $path] && [file isfile $path]} {
            foreach {what type} [mime-type $path] break
            set f [open $path r]
            if {$what eq "binary"} {chan configure $f -translation binary}
            set data [read $f]
            close $f
            set code "200 OK"
            set close [expr {[dict get? $meta connection] eq "close"}]
        }
        
        if {$protocol eq "HTTP/1.1"} {
            if {[string match "*deflate*" [dict get? $meta accept-encoding]]} {
                set encoding deflate
            } elseif {[string match "*gzip*" [dict get? $meta accept-encoding]]} {
                set encoding gzip
            } elseif {[string match "*compress*" [dict get? $meta accept-encoding]]} {
                set encoding compress
            }
            set transfer chunked
        } else {
            set close 1
        }
        
        foreach pair [split $query &] {
            if {[scan $pair {%[^=]=%s} key val] != 2} {set val ""}
            switch -exact -- $key {
                close        {set close 1 ; set transfer 0}
                transfer     {set transfer $val}
                content-type {set type $val}
            }
        }

        chan configure $chan -translation crlf
        Puts $chan "$protocol $code"
        Puts $chan "content-type: $type"
        Puts $chan [format "x-crc32: %x" [zlib crc32 $data]]
        if {$close} {
            Puts $chan "connection: close"
        }
        if {$encoding eq "identity"} {
            Puts $chan "content-length: [string length $data]"
        } else {
            Puts $chan "content-encoding: $encoding"
        }
        if {$transfer eq "chunked"} {
            Puts $chan "transfer-encoding: chunked"
        }
        puts $chan ""
        flush $chan

        chan configure $chan -translation binary
        if {$transfer eq "chunked"} {
            blow-chunks $data $chan $encoding
        } elseif {$encoding ne "identity"} {
            puts -nonewline $chan [zlib $encoding $data]
        } else {
            puts -nonewline $chan $data
        }
        
        if {$close} {
            chan event $chan readable {}
            close $chan
            puts "close $chan"
            return
        } else {
            flush $chan
        }
        puts "pipeline $chan"
    }
}

proc Accept {chan addr port} {
    coroutine client$chan Service $chan $addr $port
    return
}

proc Control {chan} {
    if {[gets $chan line] != -1} {
        if {[string trim $line] eq "quit"} {
            set ::forever 1
        }
    }
    if {[eof $chan]} {
        chan event $chan readable {}
    }
}

proc Main {{port 0}} {
    set server [socket -server Accept -myaddr localhost $port]
    puts [chan configure $server -sockname]
    flush stdout
    chan event stdin readable [list Control stdin]
    vwait ::forever
    close $server
    return "done"
}

if {!$tcl_interactive} {
    set r [catch [linsert $argv 0 Main] err]
    if {$r} {puts stderr $errorInfo} elseif {[string length $err]} {puts $err}
    exit $r
}
Changes to tools/tclZIC.tcl.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
#----------------------------------------------------------------------
#
# 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: tclZIC.tcl,v 1.2.2.6 2007/04/08 15:00:47 dgp Exp $
#
#----------------------------------------------------------------------

package require Tcl 8.5

# Define the names of the Olson files that we need to load.
# We avoid the solar time files and the leap seconds.







|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
#----------------------------------------------------------------------
#
# 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: tclZIC.tcl,v 1.2.2.7 2009/04/10 18:09:30 dgp Exp $
#
#----------------------------------------------------------------------

package require Tcl 8.5

# Define the names of the Olson files that we need to load.
# We avoid the solar time files and the leap seconds.
1261
1262
1263
1264
1265
1266
1267

1268
1269
1270
1271
1272
1273
1274
	    append data "\n    " [list [list $time $offset $dst $name]]
	}
	append data \n

	# Write the data to the information file

	set f [open $fileName w]

	puts $f "\# created by $::argv0 - do not edit"
	puts $f ""
	puts $f [list set TZData(:$zoneName) $data]
	close $f
    }

    return







>







1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
	    append data "\n    " [list [list $time $offset $dst $name]]
	}
	append data \n

	# Write the data to the information file

	set f [open $fileName w]
	fconfigure $f -translation lf
	puts $f "\# created by $::argv0 - do not edit"
	puts $f ""
	puts $f [list set TZData(:$zoneName) $data]
	close $f
    }

    return
1313
1314
1315
1316
1317
1318
1319

1320
1321
1322
1323
1324
1325
1326
	set sourceCmd "\n    [list LoadTimeZoneFile $linkTo]\n"
	set ifCmd [list if "!\[info exists TZData($linkTo)\]" $sourceCmd]
	set setCmd "set TZData(:$zoneName) \$TZData(:$linkTo)"

	# Write the file

	set f [open $fileName w]

	puts $f "\# created by $::argv0 - do not edit"
	puts $f $ifCmd
	puts $f $setCmd
	close $f
    }

    return







>







1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
	set sourceCmd "\n    [list LoadTimeZoneFile $linkTo]\n"
	set ifCmd [list if "!\[info exists TZData($linkTo)\]" $sourceCmd]
	set setCmd "set TZData(:$zoneName) \$TZData(:$linkTo)"

	# Write the file

	set f [open $fileName w]
	fconfigure $f -translation lf
	puts $f "\# created by $::argv0 - do not edit"
	puts $f $ifCmd
	puts $f $setCmd
	close $f
    }

    return
Changes to unix/Makefile.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#
# 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.127.2.69 2009/03/16 15:29:51 dgp Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#--------------------------------------------------------------------------






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#
# 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.127.2.70 2009/04/10 18:09:30 dgp Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#--------------------------------------------------------------------------
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
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"; \
	    done;
	@echo "Installing library http1.0 directory";
	@for i in $(TOP_DIR)/library/http1.0/*.tcl ; \
	    do \
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/http1.0; \
	    done;
	@echo "Installing package http 2.7.3 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/http-2.7.3.tm;
	@echo "Installing library opt0.4 directory";
	@for i in $(TOP_DIR)/library/opt/*.tcl ; \
	    do \
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \
	    done;
	@echo "Installing package msgcat 1.4.2 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.4.2.tm;
	@echo "Installing package tcltest 2.3.0 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.3.0.tm;

	@echo "Installing package platform 1.0.3 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.3.tm;
	@echo "Installing package platform::shell 1.1.4 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/platform/shell.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform/shell-1.1.4.tm;

	@echo "Installing library encoding directory";
	@for i in $(TOP_DIR)/library/encoding/*.enc ; do \
		$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/encoding; \
	done;







|
|







|
|

|
|







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
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"; \
	    done;
	@echo "Installing library http1.0 directory";
	@for i in $(TOP_DIR)/library/http1.0/*.tcl ; \
	    do \
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/http1.0; \
	    done;
	@echo "Installing package http 2.8.0 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.0.tm;
	@echo "Installing library opt0.4 directory";
	@for i in $(TOP_DIR)/library/opt/*.tcl ; \
	    do \
	    $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \
	    done;
	@echo "Installing package msgcat 1.4.2 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.4.2.tm;
	@echo "Installing package tcltest 2.3.1 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.3.1.tm;

	@echo "Installing package platform 1.0.4 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.4.tm;
	@echo "Installing package platform::shell 1.1.4 as a Tcl Module";
	@$(INSTALL_DATA) $(TOP_DIR)/library/platform/shell.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform/shell-1.1.4.tm;

	@echo "Installing library encoding directory";
	@for i in $(TOP_DIR)/library/encoding/*.enc ; do \
		$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/encoding; \
	done;
Changes to unix/configure.
17903
17904
17905
17906
17907
17908
17909









































































17910
17911
17912
17913
17914
17915
17916
echo "${ECHO_T}$tcl_cv_cc_weak_import" >&6
	if test $tcl_cv_cc_weak_import = yes; then

cat >>confdefs.h <<\_ACEOF
#define HAVE_WEAK_IMPORT 1
_ACEOF










































































	fi
    fi
    # Build .bundle dltest binaries in addition to .dylib
    DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
    DLTEST_SUFFIX=".bundle"
else
    DLTEST_LD='${SHLIB_LD}'







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







17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
echo "${ECHO_T}$tcl_cv_cc_weak_import" >&6
	if test $tcl_cv_cc_weak_import = yes; then

cat >>confdefs.h <<\_ACEOF
#define HAVE_WEAK_IMPORT 1
_ACEOF

	fi
	echo "$as_me:$LINENO: checking if Darwin SUSv3 extensions are available" >&5
echo $ECHO_N "checking if Darwin SUSv3 extensions are available... $ECHO_C" >&6
if test "${tcl_cv_cc_darwin_c_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
	    cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */

		    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
		    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
		    #error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
		    #endif
		    #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1050
		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1050
		    #endif
		    #define _DARWIN_C_SOURCE 1
		    #include <sys/cdefs.h>

int
main ()
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>conftest.er1
  ac_status=$?
  grep -v '^ *+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); } &&
	 { ac_try='test -z "$ac_c_werror_flag"
			 || test ! -s conftest.err'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; } &&
	 { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  tcl_cv_cc_darwin_c_source=yes
else
  echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

tcl_cv_cc_darwin_c_source=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
	    CFLAGS=$hold_cflags
fi
echo "$as_me:$LINENO: result: $tcl_cv_cc_darwin_c_source" >&5
echo "${ECHO_T}$tcl_cv_cc_darwin_c_source" >&6
	if test $tcl_cv_cc_darwin_c_source = yes; then

cat >>confdefs.h <<\_ACEOF
#define _DARWIN_C_SOURCE 1
_ACEOF

	fi
    fi
    # Build .bundle dltest binaries in addition to .dylib
    DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
    DLTEST_SUFFIX=".bundle"
else
    DLTEST_LD='${SHLIB_LD}'
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
#	gives a list of directories that may contain packages.  The list
#	consists of one directory for machine-dependent binaries and
#	another for platform-independent scripts.
#--------------------------------------------------------------------

if test "$FRAMEWORK_BUILD" = "1" ; then
    test -z "$TCL_PACKAGE_PATH" && \
	TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks"
    test -z "$TCL_MODULE_PATH"  && \
	TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl"
elif test "$prefix/lib" != "$libdir"; then
    TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
    TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi

#--------------------------------------------------------------------







|

|







18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
#	gives a list of directories that may contain packages.  The list
#	consists of one directory for machine-dependent binaries and
#	another for platform-independent scripts.
#--------------------------------------------------------------------

if test "$FRAMEWORK_BUILD" = "1" ; then
    test -z "$TCL_PACKAGE_PATH" && \
	TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks"
    test -z "$TCL_MODULE_PATH"  && \
	TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl"
elif test "$prefix/lib" != "$libdir"; then
    TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
    TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi

#--------------------------------------------------------------------
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951







                              ac_config_files="$ac_config_files Makefile:../unix/Makefile.in dltest/Makefile:../unix/dltest/Makefile.in tclConfig.sh:../unix/tclConfig.sh.in tcl.pc:../unix/tcl.pc.in"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems.  If it contains results you don't
# want to keep, you may remove or edit it.







|







19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024







                                        ac_config_files="$ac_config_files Makefile:../unix/Makefile.in dltest/Makefile:../unix/dltest/Makefile.in tclConfig.sh:../unix/tclConfig.sh.in tcl.pc:../unix/tcl.pc.in"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems.  If it contains results you don't
# want to keep, you may remove or edit it.
Changes to unix/configure.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
#! /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.109.2.64 2009/03/16 15:29:54 dgp Exp $

AC_INIT([tcl],[8.6])
AC_PREREQ(2.59)

dnl This is only used when included from macosx/configure.ac
m4_ifdef([SC_USE_CONFIG_HEADERS], [
    AC_CONFIG_HEADERS([tclConfig.h:../unix/tclConfig.h.in])





|







1
2
3
4
5
6
7
8
9
10
11
12
13
#! /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.109.2.65 2009/04/10 18:09:32 dgp Exp $

AC_INIT([tcl],[8.6])
AC_PREREQ(2.59)

dnl This is only used when included from macosx/configure.ac
m4_ifdef([SC_USE_CONFIG_HEADERS], [
    AC_CONFIG_HEADERS([tclConfig.h:../unix/tclConfig.h.in])
572
573
574
575
576
577
578



















579
580
581
582
583
584
585
		    int rand(void) __attribute__((weak_import));
		], [rand();],
		tcl_cv_cc_weak_import=yes, tcl_cv_cc_weak_import=no)
	    CFLAGS=$hold_cflags])
	if test $tcl_cv_cc_weak_import = yes; then
	    AC_DEFINE(HAVE_WEAK_IMPORT, 1, [Is weak import available?])
	fi



















    fi
    # Build .bundle dltest binaries in addition to .dylib
    DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
    DLTEST_SUFFIX=".bundle"
else
    DLTEST_LD='${SHLIB_LD}'
    DLTEST_SUFFIX=""







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







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
		    int rand(void) __attribute__((weak_import));
		], [rand();],
		tcl_cv_cc_weak_import=yes, tcl_cv_cc_weak_import=no)
	    CFLAGS=$hold_cflags])
	if test $tcl_cv_cc_weak_import = yes; then
	    AC_DEFINE(HAVE_WEAK_IMPORT, 1, [Is weak import available?])
	fi
	AC_CACHE_CHECK([if Darwin SUSv3 extensions are available],
	    tcl_cv_cc_darwin_c_source, [
	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
	    AC_TRY_COMPILE([
		    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
		    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
		    #error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
		    #endif
		    #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1050
		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1050
		    #endif
		    #define _DARWIN_C_SOURCE 1
		    #include <sys/cdefs.h>
		],,tcl_cv_cc_darwin_c_source=yes, tcl_cv_cc_darwin_c_source=no)
	    CFLAGS=$hold_cflags])
	if test $tcl_cv_cc_darwin_c_source = yes; then
	    AC_DEFINE(_DARWIN_C_SOURCE, 1,
		    [Are Darwin SUSv3 extensions available?])
	fi
    fi
    # Build .bundle dltest binaries in addition to .dylib
    DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
    DLTEST_SUFFIX=".bundle"
else
    DLTEST_LD='${SHLIB_LD}'
    DLTEST_SUFFIX=""
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
#	gives a list of directories that may contain packages.  The list
#	consists of one directory for machine-dependent binaries and
#	another for platform-independent scripts.
#--------------------------------------------------------------------

if test "$FRAMEWORK_BUILD" = "1" ; then
    test -z "$TCL_PACKAGE_PATH" && \
	TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks"
    test -z "$TCL_MODULE_PATH"  && \
	TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl"
elif test "$prefix/lib" != "$libdir"; then
    TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
    TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi

#--------------------------------------------------------------------







|

|







844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
#	gives a list of directories that may contain packages.  The list
#	consists of one directory for machine-dependent binaries and
#	another for platform-independent scripts.
#--------------------------------------------------------------------

if test "$FRAMEWORK_BUILD" = "1" ; then
    test -z "$TCL_PACKAGE_PATH" && \
	TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /System/Library/Frameworks"
    test -z "$TCL_MODULE_PATH"  && \
	TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl"
elif test "$prefix/lib" != "$libdir"; then
    TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
    TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi

#--------------------------------------------------------------------
Changes to unix/tclConfig.h.in.
426
427
428
429
430
431
432



433
434
435
436
437
438
439

/* Should we use vfork() instead of fork()? */
#undef USE_VFORK

/* Define to 1 if your processor stores words with the most significant byte
   first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN




/* Add the _ISOC99_SOURCE flag when building */
#undef _ISOC99_SOURCE

/* Add the _LARGEFILE64_SOURCE flag when building */
#undef _LARGEFILE64_SOURCE








>
>
>







426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442

/* Should we use vfork() instead of fork()? */
#undef USE_VFORK

/* Define to 1 if your processor stores words with the most significant byte
   first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN

/* Are Darwin SUSv3 extensions available? */
#undef _DARWIN_C_SOURCE

/* Add the _ISOC99_SOURCE flag when building */
#undef _ISOC99_SOURCE

/* Add the _LARGEFILE64_SOURCE flag when building */
#undef _LARGEFILE64_SOURCE

Changes to unix/tclUnixChan.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * tclUnixChan.c
 *
 *	Common channel driver for Unix channels based on files, command pipes
 *	and TCP sockets.
 *
 * Copyright (c) 1995-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: tclUnixChan.c,v 1.42.4.35 2008/12/18 04:36:24 dgp Exp $
 */

#include "tclInt.h"	/* Internal definitions for Tcl. */
#include "tclIO.h"	/* To get Channel type declaration. */

#define SUPPORTS_TTY













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * tclUnixChan.c
 *
 *	Common channel driver for Unix channels based on files, command pipes
 *	and TCP sockets.
 *
 * Copyright (c) 1995-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: tclUnixChan.c,v 1.42.4.36 2009/04/10 18:09:32 dgp Exp $
 */

#include "tclInt.h"	/* Internal definitions for Tcl. */
#include "tclIO.h"	/* To get Channel type declaration. */

#define SUPPORTS_TTY

3008
3009
3010
3011
3012
3013
3014


3015
3016
3017
3018
3019
3020
3021
    }

    Tcl_AppendResult(interp, "\"", chanID,
	    "\" cannot be used to get a FILE *", NULL);
    return TCL_ERROR;
}



/*
 *----------------------------------------------------------------------
 *
 * TclUnixWaitForFile --
 *
 *	This function waits synchronously for a file to become readable or
 *	writable, with an optional timeout.







>
>







3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
    }

    Tcl_AppendResult(interp, "\"", chanID,
	    "\" cannot be used to get a FILE *", NULL);
    return TCL_ERROR;
}

#ifndef HAVE_COREFOUNDATION	/* Darwin/Mac OS X CoreFoundation notifier is
				 * in tclMacOSXNotify.c */
/*
 *----------------------------------------------------------------------
 *
 * TclUnixWaitForFile --
 *
 *	This function waits synchronously for a file to become readable or
 *	writable, with an optional timeout.
3167
3168
3169
3170
3171
3172
3173

3174
3175
3176
3177
3178
3179
3180
	if ((abortTime.sec < now.sec)
		|| (abortTime.sec==now.sec && abortTime.usec<=now.usec)) {
	    break;
	}
    }
    return result;
}


/*
 *----------------------------------------------------------------------
 *
 * FileTruncateProc --
 *
 *	Truncates a file to a given length.







>







3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
	if ((abortTime.sec < now.sec)
		|| (abortTime.sec==now.sec && abortTime.usec<=now.usec)) {
	    break;
	}
    }
    return result;
}
#endif /* HAVE_COREFOUNDATION */

/*
 *----------------------------------------------------------------------
 *
 * FileTruncateProc --
 *
 *	Truncates a file to a given length.
Changes to unix/tclUnixEvent.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14


15
16
17
18
19
20
21
/*
 * tclUnixEvent.c --
 *
 *	This file implements Unix specific event related routines.
 *
 * Copyright (c) 1997 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: tclUnixEvent.c,v 1.4.6.5 2008/11/10 02:18:42 dgp Exp $
 */

#include "tclInt.h"



/*
 *----------------------------------------------------------------------
 *
 * Tcl_Sleep --
 *
 *	Delay execution for the specified number of milliseconds.










|



>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * tclUnixEvent.c --
 *
 *	This file implements Unix specific event related routines.
 *
 * Copyright (c) 1997 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: tclUnixEvent.c,v 1.4.6.6 2009/04/10 18:09:33 dgp Exp $
 */

#include "tclInt.h"
#ifndef HAVE_COREFOUNDATION	/* Darwin/Mac OS X CoreFoundation notifier is
				 * in tclMacOSXNotify.c */

/*
 *----------------------------------------------------------------------
 *
 * Tcl_Sleep --
 *
 *	Delay execution for the specified number of milliseconds.
81
82
83
84
85
86
87

88
89
90
91
92
93
94
	}
	(void) select(0, (SELECT_MASK *) 0, (SELECT_MASK *) 0,
		(SELECT_MASK *) 0, &delay);
	Tcl_GetTime(&before);
    }
}


/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */







>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
	}
	(void) select(0, (SELECT_MASK *) 0, (SELECT_MASK *) 0,
		(SELECT_MASK *) 0, &delay);
	Tcl_GetTime(&before);
    }
}

#endif /* HAVE_COREFOUNDATION */
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
Changes to unix/tclUnixNotfy.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * tclUnixNotify.c --
 *
 *	This file contains the implementation of the select()-based
 *	Unix-specific notifier, which is the lowest-level part of the Tcl
 *	event loop. This file works together with generic/tclNotify.c.
 *
 * 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: tclUnixNotfy.c,v 1.12.2.21 2008/12/13 19:29:54 dgp Exp $
 */

#include "tclInt.h"
#ifndef HAVE_COREFOUNDATION	/* Darwin/Mac OS X CoreFoundation notifier is
				 * in tclMacOSXNotify.c */
#include <signal.h>













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * tclUnixNotify.c --
 *
 *	This file contains the implementation of the select()-based
 *	Unix-specific notifier, which is the lowest-level part of the Tcl
 *	event loop. This file works together with generic/tclNotify.c.
 *
 * 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: tclUnixNotfy.c,v 1.12.2.22 2009/04/10 18:09:33 dgp Exp $
 */

#include "tclInt.h"
#ifndef HAVE_COREFOUNDATION	/* Darwin/Mac OS X CoreFoundation notifier is
				 * in tclMacOSXNotify.c */
#include <signal.h>

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 * ever changes, we need to wake up and restart the select() system call. You
 * can wake up the notifier thread by writing a single byte to the file
 * descriptor defined below. This file descriptor is the input-end of a pipe
 * and the notifier thread is listening for data on the output-end of the same
 * pipe. Hence writing to this file descriptor will cause the select() system
 * call to return and wake up the notifier thread.
 *
 * You must hold the notifierMutex lock before accessing this list.
 */

static int triggerPipe = -1;

/*
 * The notifierMutex locks access to all of the global notifier state.
 */







|







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 * ever changes, we need to wake up and restart the select() system call. You
 * can wake up the notifier thread by writing a single byte to the file
 * descriptor defined below. This file descriptor is the input-end of a pipe
 * and the notifier thread is listening for data on the output-end of the same
 * pipe. Hence writing to this file descriptor will cause the select() system
 * call to return and wake up the notifier thread.
 *
 * You must hold the notifierMutex lock before writing to the pipe.
 */

static int triggerPipe = -1;

/*
 * The notifierMutex locks access to all of the global notifier state.
 */
548
549
550
551
552
553
554
555

556
557
558
559
560
561
562
563

564
565
566
567
568
569
570
	}

	/*
	 * Find current max fd.
	 */

	if (fd+1 == tsdPtr->numFdBits) {
	    tsdPtr->numFdBits = 0;

	    for (i = fd-1; i >= 0; i--) {
		if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
			|| FD_ISSET(i, &(tsdPtr->checkMasks.writable))
			|| FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		    tsdPtr->numFdBits = i+1;
		    break;
		}
	    }

	}

	/*
	 * Clean up information in the callback record.
	 */

	if (prevPtr == NULL) {







|
>




|



>







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
	}

	/*
	 * Find current max fd.
	 */

	if (fd+1 == tsdPtr->numFdBits) {
	    int numFdBits = 0;

	    for (i = fd-1; i >= 0; i--) {
		if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
			|| FD_ISSET(i, &(tsdPtr->checkMasks.writable))
			|| FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
		    numFdBits = i+1;
		    break;
		}
	    }
	    tsdPtr->numFdBits = numFdBits;
	}

	/*
	 * Clean up information in the callback record.
	 */

	if (prevPtr == NULL) {
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
{
    if (tclNotifierHooks.waitForEventProc) {
	return tclNotifierHooks.waitForEventProc(timePtr);
    } else {
	FileHandler *filePtr;
	FileHandlerEvent *fileEvPtr;
	int mask;
	Tcl_Time myTime;
#ifdef TCL_THREADS
	int waitForFiles;
	Tcl_Time *myTimePtr;
#else
	/*
	 * Impl. notes: timeout & timeoutPtr are used if, and only if threads
	 * are not enabled. They are the arguments for the regular select()
	 * used when the core is not thread-enabled.
	 */








|


<







675
676
677
678
679
680
681
682
683
684

685
686
687
688
689
690
691
{
    if (tclNotifierHooks.waitForEventProc) {
	return tclNotifierHooks.waitForEventProc(timePtr);
    } else {
	FileHandler *filePtr;
	FileHandlerEvent *fileEvPtr;
	int mask;
	Tcl_Time vTime;
#ifdef TCL_THREADS
	int waitForFiles;

#else
	/*
	 * Impl. notes: timeout & timeoutPtr are used if, and only if threads
	 * are not enabled. They are the arguments for the regular select()
	 * used when the core is not thread-enabled.
	 */

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
	if (timePtr != NULL) {
	    /*
	     * TIP #233 (Virtualized Time). Is virtual time in effect? And do
	     * we actually have something to scale? If yes to both then we call
	     * the handler to do this scaling.
	     */

	    myTime.sec  = timePtr->sec;
	    myTime.usec = timePtr->usec;

	    if (myTime.sec != 0 || myTime.usec != 0) {
		tclScaleTimeProcPtr(&myTime, tclTimeClientData);
	    }

#ifdef TCL_THREADS
	    myTimePtr = &myTime;
#else
	    timeout.tv_sec = myTime.sec;
	    timeout.tv_usec = myTime.usec;
	    timeoutPtr = &timeout;
#endif /* TCL_THREADS */

#ifndef TCL_THREADS
	} else if (tsdPtr->numFdBits == 0) {
	    /*
	     * If there are no threads, no timeout, and no fds registered, then
	     * there are no events possible and we must avoid deadlock. Note
	     * that this is not entirely correct because there might be a
	     * signal that could interrupt the select call, but we don't handle
	     * that case if we aren't using threads.
	     */

	    return -1;
#endif /* !TCL_THREADS */
	} else {
#ifdef TCL_THREADS
	    myTimePtr = NULL;
#else
	    timeoutPtr = NULL;
#endif /* TCL_THREADS */
	}

#ifdef TCL_THREADS
	/*
	 * Place this thread on the list of interested threads, signal the
	 * notifier thread, and wait for a response or a timeout.
	 */

	Tcl_MutexLock(&notifierMutex);

	waitForFiles = (tsdPtr->numFdBits > 0);
	if (myTimePtr != NULL && myTimePtr->sec == 0 && (myTimePtr->usec == 0
#if defined(__APPLE__) && defined(__LP64__)
		/*
		 * On 64-bit Darwin, pthread_cond_timedwait() appears to have a
		 * bug that causes it to wait forever when passed an absolute
		 * time which has already been exceeded by the system time; as
		 * a workaround, when given a very brief timeout, just do a
		 * poll. [Bug 1457797]
		 */
		|| myTimePtr->usec < 10
#endif
		)) {
	    /*
	     * Cannot emulate a polling select with a polling condition
	     * variable. Instead, pretend to wait for files and tell the
	     * notifier thread what we are doing. The notifier thread makes
	     * sure it goes through select with its select mask in the same
	     * state as ours currently is. We block until that happens.
	     */

	    waitForFiles = 1;
	    tsdPtr->pollState = POLL_WANT;
	    myTimePtr = NULL;
	} else {

	    tsdPtr->pollState = 0;
	}

	if (waitForFiles) {
	    /*
	     * Add the ThreadSpecificData structure of this thread to the list
	     * of ThreadSpecificData structures of all threads that are waiting







|
|
|
|
<

<
|
<
<
|
|

<
<
<










<

<
<
<












<
|








|












|

>







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
	if (timePtr != NULL) {
	    /*
	     * TIP #233 (Virtualized Time). Is virtual time in effect? And do
	     * we actually have something to scale? If yes to both then we call
	     * the handler to do this scaling.
	     */

	    if (timePtr->sec != 0 || timePtr->usec != 0) {
		vTime = *timePtr;
		tclScaleTimeProcPtr(&vTime, tclTimeClientData);
		timePtr = &vTime;

	    }

#ifndef TCL_THREADS


	    timeout.tv_sec = timePtr->sec;
	    timeout.tv_usec = timePtr->usec;
	    timeoutPtr = &timeout;



	} else if (tsdPtr->numFdBits == 0) {
	    /*
	     * If there are no threads, no timeout, and no fds registered, then
	     * there are no events possible and we must avoid deadlock. Note
	     * that this is not entirely correct because there might be a
	     * signal that could interrupt the select call, but we don't handle
	     * that case if we aren't using threads.
	     */

	    return -1;

	} else {



	    timeoutPtr = NULL;
#endif /* TCL_THREADS */
	}

#ifdef TCL_THREADS
	/*
	 * Place this thread on the list of interested threads, signal the
	 * notifier thread, and wait for a response or a timeout.
	 */

	Tcl_MutexLock(&notifierMutex);


	if (timePtr != NULL && timePtr->sec == 0 && (timePtr->usec == 0
#if defined(__APPLE__) && defined(__LP64__)
		/*
		 * On 64-bit Darwin, pthread_cond_timedwait() appears to have a
		 * bug that causes it to wait forever when passed an absolute
		 * time which has already been exceeded by the system time; as
		 * a workaround, when given a very brief timeout, just do a
		 * poll. [Bug 1457797]
		 */
		|| timePtr->usec < 10
#endif
		)) {
	    /*
	     * Cannot emulate a polling select with a polling condition
	     * variable. Instead, pretend to wait for files and tell the
	     * notifier thread what we are doing. The notifier thread makes
	     * sure it goes through select with its select mask in the same
	     * state as ours currently is. We block until that happens.
	     */

	    waitForFiles = 1;
	    tsdPtr->pollState = POLL_WANT;
	    timePtr = NULL;
	} else {
	    waitForFiles = (tsdPtr->numFdBits > 0);
	    tsdPtr->pollState = 0;
	}

	if (waitForFiles) {
	    /*
	     * Add the ThreadSpecificData structure of this thread to the list
	     * of ThreadSpecificData structures of all threads that are waiting
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
	}

	FD_ZERO(&(tsdPtr->readyMasks.readable));
	FD_ZERO(&(tsdPtr->readyMasks.writable));
	FD_ZERO(&(tsdPtr->readyMasks.exceptional));

	if (!tsdPtr->eventReady) {
	    Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, myTimePtr);
	}
	tsdPtr->eventReady = 0;

	if (waitForFiles && tsdPtr->onList) {
	    /*
	     * Remove the ThreadSpecificData structure of this thread from the
	     * waiting list. Alert the notifier thread to recompute its select







|







786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
	}

	FD_ZERO(&(tsdPtr->readyMasks.readable));
	FD_ZERO(&(tsdPtr->readyMasks.writable));
	FD_ZERO(&(tsdPtr->readyMasks.exceptional));

	if (!tsdPtr->eventReady) {
	    Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
	}
	tsdPtr->eventReady = 0;

	if (waitForFiles && tsdPtr->onList) {
	    /*
	     * Remove the ThreadSpecificData structure of this thread from the
	     * waiting list. Alert the notifier thread to recompute its select
Changes to win/Makefile.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#
# 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.71.2.45 2009/02/25 13:50:41 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 the configuration script).






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#
# 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.71.2.46 2009/04/10 18:09:33 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 the configuration script).
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		$(MKDIR) $$i; \
		else true; \
		fi; \
	    done;
	@for i in http1.0 opt0.4 encoding ../tcl8 ../tcl8/8.2 ../tcl8/8.3 ../tcl8/8.4  ../tcl8/8.4/platform ../tcl8/8.5; \
	    do \
	    if [ ! -d $(SCRIPT_INSTALL_DIR)/$$i ] ; then \
		echo "Making directory $(SCRIPT_INSTALL_DIR)/$$i"; \
		$(MKDIR) $(SCRIPT_INSTALL_DIR)/$$i; \
		else true; \
		fi; \
	    done;







|







663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		$(MKDIR) $$i; \
		else true; \
		fi; \
	    done;
	@for i in http1.0 opt0.4 encoding ../tcl8 ../tcl8/8.2 ../tcl8/8.3 ../tcl8/8.4  ../tcl8/8.4/platform ../tcl8/8.5 ../tcl8/8.6; \
	    do \
	    if [ ! -d $(SCRIPT_INSTALL_DIR)/$$i ] ; then \
		echo "Making directory $(SCRIPT_INSTALL_DIR)/$$i"; \
		$(MKDIR) $(SCRIPT_INSTALL_DIR)/$$i; \
		else true; \
		fi; \
	    done;
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
	    $(COPY) "$$i" "$(SCRIPT_INSTALL_DIR)"; \
	    done;
	@echo "Installing library http1.0 directory";
	@for j in $(ROOT_DIR)/library/http1.0/*.tcl; \
	    do \
	    $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/http1.0"; \
	    done;
	@echo "Installing package http 2.7.3 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/http/http.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/http-2.7.3.tm;
	@echo "Installing library opt0.4 directory";
	@for j in $(ROOT_DIR)/library/opt/*.tcl; \
	    do \
	    $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \
	    done;
	@echo "Installing package msgcat 1.4.2 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.4.2.tm;
	@echo "Installing package tcltest 2.3.0 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.3.0.tm;
	@echo "Installing package platform 1.0.3 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/platform/platform.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform-1.0.3.tm;
	@echo "Installing package platform::shell 1.1.4 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/platform/shell.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform/shell-1.1.4.tm;
	@echo "Installing encodings";
	@for i in $(ROOT_DIR)/library/encoding/*.enc ; do \
		$(COPY) "$$i" "$(SCRIPT_INSTALL_DIR)/encoding"; \
	done;








|
|







|
|
|
|







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
	    $(COPY) "$$i" "$(SCRIPT_INSTALL_DIR)"; \
	    done;
	@echo "Installing library http1.0 directory";
	@for j in $(ROOT_DIR)/library/http1.0/*.tcl; \
	    do \
	    $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/http1.0"; \
	    done;
	@echo "Installing package http 2.8.0 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/http/http.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.6/http-2.8.0.tm;
	@echo "Installing library opt0.4 directory";
	@for j in $(ROOT_DIR)/library/opt/*.tcl; \
	    do \
	    $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \
	    done;
	@echo "Installing package msgcat 1.4.2 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.4.2.tm;
	@echo "Installing package tcltest 2.3.1 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.3.1.tm;
	@echo "Installing package platform 1.0.4 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/platform/platform.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform-1.0.4.tm;
	@echo "Installing package platform::shell 1.1.4 as a Tcl Module";
	@$(COPY) $(ROOT_DIR)/library/platform/shell.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform/shell-1.1.4.tm;
	@echo "Installing encodings";
	@for i in $(ROOT_DIR)/library/encoding/*.enc ; do \
		$(COPY) "$$i" "$(SCRIPT_INSTALL_DIR)/encoding"; \
	done;

Changes to win/makefile.bc.
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
	-@$(MKDIR) "$(INCLUDE_INSTALL_DIR)"
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)"
	@echo installing http1.0
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http1.0"
	-@copy "$(ROOT)\library\http1.0\http.tcl"     "$(SCRIPT_INSTALL_DIR)\http1.0"
	-@copy "$(ROOT)\library\http1.0\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http1.0"
	@echo installing http2.7
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http2.7"
	-@copy "$(ROOT)\library\http\http.tcl"     "$(SCRIPT_INSTALL_DIR)\http2.7"
	-@copy "$(ROOT)\library\http\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http2.7"
	@echo installing opt0.4
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\opt0.4"
	-@copy "$(ROOT)\library\opt\optparse.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
	-@copy "$(ROOT)\library\opt\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
	@echo installing msgcat1.4
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
	-@copy "$(ROOT)\library\msgcat\msgcat.tcl"   "$(SCRIPT_INSTALL_DIR)\msgcat1.4"







|
|
|







426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
	-@$(MKDIR) "$(INCLUDE_INSTALL_DIR)"
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)"
	@echo installing http1.0
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http1.0"
	-@copy "$(ROOT)\library\http1.0\http.tcl"     "$(SCRIPT_INSTALL_DIR)\http1.0"
	-@copy "$(ROOT)\library\http1.0\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http1.0"
	@echo installing http2.7
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\http2.8"
	-@copy "$(ROOT)\library\http\http.tcl"     "$(SCRIPT_INSTALL_DIR)\http2.8"
	-@copy "$(ROOT)\library\http\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\http2.8"
	@echo installing opt0.4
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\opt0.4"
	-@copy "$(ROOT)\library\opt\optparse.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
	-@copy "$(ROOT)\library\opt\pkgIndex.tcl" "$(SCRIPT_INSTALL_DIR)\opt0.4"
	@echo installing msgcat1.4
	-@$(MKDIR) "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
	-@copy "$(ROOT)\library\msgcat\msgcat.tcl"   "$(SCRIPT_INSTALL_DIR)\msgcat1.4"
Changes to win/makefile.vc.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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.
# Copyright (c) 2003-2008 Pat Thoyts.
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: makefile.vc,v 1.107.2.45 2009/02/02 14:24:24 dgp Exp $
#------------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
# VCINSTALLDIR instead.
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR)
MSG = ^







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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.
# Copyright (c) 2003-2008 Pat Thoyts.
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: makefile.vc,v 1.107.2.46 2009/04/10 18:09:33 dgp Exp $
#------------------------------------------------------------------------------

# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
# VCINSTALLDIR instead.
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR)
MSG = ^
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<<
!else
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ \
		$(baselibs) @<<
$**
<<
	$(_VC_MANIFEST_EMBED_DLL)
	-@del $*.exp
!endif

$(TCLSTUBLIB): $(TCLSTUBOBJS)
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TCLSTUBOBJS)

$(TCLSH): $(TCLSHOBJS) $(TCLIMPLIB)
	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**







<







590
591
592
593
594
595
596

597
598
599
600
601
602
603
<<
!else
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ \
		$(baselibs) @<<
$**
<<
	$(_VC_MANIFEST_EMBED_DLL)

!endif

$(TCLSTUBLIB): $(TCLSTUBOBJS)
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TCLSTUBOBJS)

$(TCLSH): $(TCLSHOBJS) $(TCLIMPLIB)
	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**
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
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TMP_DIR)\tclWinDde.obj
!endif
!else
$(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB)
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \
		$** $(baselibs)
	$(_VC_MANIFEST_EMBED_DLL)
	-@del $*.exp
	-@del $*.lib
!endif

!if $(STATIC_BUILD)
!if $(TCL_USE_STATIC_PACKAGES)
$(TCLREGLIB):
!else
$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TMP_DIR)\tclWinReg.obj
!endif
!else
$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB)
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \
		$** $(baselibs)
	$(_VC_MANIFEST_EMBED_DLL)
	-@del $*.exp
	-@del $*.lib
!endif

pkgs:
	@for /d %d in ($(PKGSDIR)\*) do \
	  @if exist "%~fd\win\makefile.vc" ( \
	    pushd "%~fd\win" & \
	    $(MAKE) -$(MAKEFLAGS) -f makefile.vc TCLDIR=$(ROOT) &\







<
<














<
<







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
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TMP_DIR)\tclWinDde.obj
!endif
!else
$(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB)
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \
		$** $(baselibs)
	$(_VC_MANIFEST_EMBED_DLL)


!endif

!if $(STATIC_BUILD)
!if $(TCL_USE_STATIC_PACKAGES)
$(TCLREGLIB):
!else
$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj
	$(lib32) -nologo $(LINKERFLAGS) -out:$@ $(TMP_DIR)\tclWinReg.obj
!endif
!else
$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB)
	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \
		$** $(baselibs)
	$(_VC_MANIFEST_EMBED_DLL)


!endif

pkgs:
	@for /d %d in ($(PKGSDIR)\*) do \
	  @if exist "%~fd\win\makefile.vc" ( \
	    pushd "%~fd\win" & \
	    $(MAKE) -$(MAKEFLAGS) -f makefile.vc TCLDIR=$(ROOT) &\
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
	@$(CPY) "$(ROOT)\library\http1.0\*.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\http1.0\"
	@echo Installing library opt0.4 directory
	@$(CPY) "$(ROOT)\library\opt\*.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\opt0.4\"
	@echo Installing package http $(PKG_HTTP_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\http\http.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.4\http-$(PKG_HTTP_VER).tm"
	@echo Installing package msgcat $(PKG_MSGCAT_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\msgcat\msgcat.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5\msgcat-$(PKG_MSGCAT_VER).tm"
	@echo Installing package tcltest $(PKG_TCLTEST_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\tcltest\tcltest.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5\tcltest-$(PKG_TCLTEST_VER).tm"
	@echo Installing package platform $(PKG_PLATFORM_VER) as a Tcl Module







|







1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
	@$(CPY) "$(ROOT)\library\http1.0\*.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\http1.0\"
	@echo Installing library opt0.4 directory
	@$(CPY) "$(ROOT)\library\opt\*.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\opt0.4\"
	@echo Installing package http $(PKG_HTTP_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\http\http.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.6\http-$(PKG_HTTP_VER).tm"
	@echo Installing package msgcat $(PKG_MSGCAT_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\msgcat\msgcat.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5\msgcat-$(PKG_MSGCAT_VER).tm"
	@echo Installing package tcltest $(PKG_TCLTEST_VER) as a Tcl Module
	@$(COPY) "$(ROOT)\library\tcltest\tcltest.tcl" \
	    "$(SCRIPT_INSTALL_DIR)\..\tcl8\8.5\tcltest-$(PKG_TCLTEST_VER).tm"
	@echo Installing package platform $(PKG_PLATFORM_VER) as a Tcl Module
1199
1200
1201
1202
1203
1204
1205


1206
1207
1208
1209
	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
	@echo Cleaning $(WINDIR)\vercl.x ...
	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
	@echo Cleaning $(WINDIR)\vercl.i ...
	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
	@echo Cleaning $(WINDIR)\versions.vc ...
	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc



hose:
	@echo Hosing $(OUT_DIR)\* ...
	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)







>
>




1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
	@if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
	@echo Cleaning $(WINDIR)\vercl.x ...
	@if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
	@echo Cleaning $(WINDIR)\vercl.i ...
	@if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
	@echo Cleaning $(WINDIR)\versions.vc ...
	@if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc

realclean: hose

hose:
	@echo Hosing $(OUT_DIR)\* ...
	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
Changes to win/rules.vc.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#------------------------------------------------------------------------------
# rules.vc --
#
#	Microsoft Visual C++ makefile include for decoding the commandline
#	macros.  This file does not need editing to build Tcl.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 2001-2003 David Gravereaux.
# Copyright (c) 2003-2007 Patrick Thoyts
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: rules.vc,v 1.12.2.16 2008/06/26 04:07:51 dgp Exp $
#------------------------------------------------------------------------------

!ifndef _RULES_VC
_RULES_VC = 1

cc32		= $(CC)   # built-in default.
link32		= link













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#------------------------------------------------------------------------------
# rules.vc --
#
#	Microsoft Visual C++ makefile include for decoding the commandline
#	macros.  This file does not need editing to build Tcl.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 2001-2003 David Gravereaux.
# Copyright (c) 2003-2007 Patrick Thoyts
#
#------------------------------------------------------------------------------
# RCS: @(#) $Id: rules.vc,v 1.12.2.17 2009/04/10 18:09:33 dgp Exp $
#------------------------------------------------------------------------------

!ifndef _RULES_VC
_RULES_VC = 1

cc32		= $(CC)   # built-in default.
link32		= link
212
213
214
215
216
217
218

219
220
221
222
223
224
225

!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
STATIC_BUILD	= 0
TCL_THREADS	= 0
DEBUG		= 0
SYMBOLS		= 0
PROFILE		= 0

MSVCRT		= 0
LOIMPACT	= 0
TCL_USE_STATIC_PACKAGES	= 0
USE_THREAD_ALLOC = 0
UNCHECKED	= 0
!else
!if [nmakehlp -f $(OPTS) "static"]







>







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
STATIC_BUILD	= 0
TCL_THREADS	= 0
DEBUG		= 0
SYMBOLS		= 0
PROFILE		= 0
PGO		= 0
MSVCRT		= 0
LOIMPACT	= 0
TCL_USE_STATIC_PACKAGES	= 0
USE_THREAD_ALLOC = 0
UNCHECKED	= 0
!else
!if [nmakehlp -f $(OPTS) "static"]
260
261
262
263
264
265
266









267
268
269
270
271
272
273
SYMBOLS		= 0
!endif
!if [nmakehlp -f $(OPTS) "profile"]
!message *** Doing profile
PROFILE		= 1
!else
PROFILE		= 0









!endif
!if [nmakehlp -f $(OPTS) "loimpact"]
!message *** Doing loimpact
LOIMPACT	= 1
!else
LOIMPACT	= 0
!endif







>
>
>
>
>
>
>
>
>







261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
SYMBOLS		= 0
!endif
!if [nmakehlp -f $(OPTS) "profile"]
!message *** Doing profile
PROFILE		= 1
!else
PROFILE		= 0
!endif
!if [nmakehlp -f $(OPTS) "pgi"]
!message *** Doing profile guided optimization instrumentation
PGO		= 1
!elseif [nmakehlp -f $(OPTS) "pgo"]
!message *** Doing profile guided optimization
PGO		= 2
!else
PGO		= 0
!endif
!if [nmakehlp -f $(OPTS) "loimpact"]
!message *** Doing loimpact
LOIMPACT	= 1
!else
LOIMPACT	= 0
!endif
414
415
416
417
418
419
420


















421
422
423
424
425
426
427
WARNINGS		    = -W3
!endif
!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
!message *** Doing 64bit portability warnings
WARNINGS		    = $(WARNINGS) -Wp64
!endif
!endif



















#----------------------------------------------------------
# Set our defines now armed with our options.
#----------------------------------------------------------

OPTDEFINES	= -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS








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







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
WARNINGS		    = -W3
!endif
!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
!message *** Doing 64bit portability warnings
WARNINGS		    = $(WARNINGS) -Wp64
!endif
!endif

!if $(PGO) > 1
!if [nmakehlp -l -ltcg:pgoptimize]
LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
!else
MSG=^
This compiler does not support profile guided optimization.
!error $(MSG)
!endif
!elseif $(PGO) > 0
!if [nmakehlp -l -ltcg:pginstrument]
LINKERFLAGS	= $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
!else
MSG=^
This compiler does not support profile guided optimization.
!error $(MSG)
!endif
!endif

#----------------------------------------------------------
# Set our defines now armed with our options.
#----------------------------------------------------------

OPTDEFINES	= -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS