Tcl Source Code

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

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

Overview
Comment:* tests/winTime.test: * win/tclWinTime.c: Fixed crash in clock command that occurred when manipulating negative time values in timezones east of GMT. [Bug: 1142, 1458]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-1-branch-old
Files: files | file ages | folders
SHA1: 0b5707f7e38a8a8194ef57433dceda9cb6a8c359
User & Date: stanton 1999-04-06 00:29:19
Context
1999-04-06
00:29
*** empty log message *** check-in: fc67f5b576 user: stanton tags: core-8-1-branch-old
00:29
* tests/winTime.test: * win/tclWinTime.c: Fixed crash in clock command that occurred when manipulati... check-in: 0b5707f7e3 user: stanton tags: core-8-1-branch-old
00:01
Fixed test that would only work with debug builds. check-in: ead92ba131 user: rjohnson tags: core-8-1-branch-old
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tests/winTime.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
# This file tests the tclWinTime.c file.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 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: winTime.test,v 1.1.2.1 1999/04/06 00:29:19 stanton Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    source [file join [pwd] [file dirname [info script]] defs.tcl]
}

# The next two tests will crash on Windows if the check for negative
# clock values is not done properly.

test winTime-1.1 {TclpGetDate} {pcOnly} {
    set ::env(TZ) JST-9
    set result [clock format -1 -format %Y]
    unset ::env(TZ)
    set result
} {1970}
test winTime-1.2 {TclpGetDate} {pcOnly} {
    set ::env(TZ) PST8
    set result [clock format 1 -format %Y]
    unset ::env(TZ)
    set result
} {1969}

# cleanup
::tcltest::cleanupTests
return












Changes to win/tclWinTime.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
265
266
267
268
269
270
271
272
273
274
275


276
277
278
279
280
281
282
 *	obtain time values from the operating system.
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinTime.c,v 1.1.2.3 1999/03/10 06:49:31 stanton Exp $
 */

#include "tclWinInt.h"

#define SECSPERDAY (60L * 60L * 24L)
#define SECSPERYEAR (SECSPERDAY * 365L)
#define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)
................................................................................

	/*
	 * If we are in the valid range, let the C run-time library
	 * handle it.  Otherwise we need to fake it.  Note that this
	 * algorithm ignores daylight savings time before the epoch.
	 */

	time = *tp - _timezone;
	if (time >= 0) {
	    return localtime(tp);
	}


	
	/*
	 * If we aren't near to overflowing the long, just add the bias and
	 * use the normal calculation.  Otherwise we will need to adjust
	 * the result at the end.
	 */







|







 







<
|


>
>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
265
266
267
268
269
270
271

272
273
274
275
276
277
278
279
280
281
282
283
 *	obtain time values from the operating system.
 *
 * Copyright 1995-1998 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinTime.c,v 1.1.2.4 1999/04/06 00:29:19 stanton Exp $
 */

#include "tclWinInt.h"

#define SECSPERDAY (60L * 60L * 24L)
#define SECSPERYEAR (SECSPERDAY * 365L)
#define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)
................................................................................

	/*
	 * If we are in the valid range, let the C run-time library
	 * handle it.  Otherwise we need to fake it.  Note that this
	 * algorithm ignores daylight savings time before the epoch.
	 */


	if (*tp >= 0) {
	    return localtime(tp);
	}

	time = *tp - _timezone;
	
	/*
	 * If we aren't near to overflowing the long, just add the bias and
	 * use the normal calculation.  Otherwise we will need to adjust
	 * the result at the end.
	 */