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 Side-by-Side Diffs Ignore Whitespace Patch

Added tests/winTime.test.

            1  +# This file tests the tclWinTime.c file.
            2  +#
            3  +# This file contains a collection of tests for one or more of the Tcl
            4  +# built-in commands.  Sourcing this file into Tcl runs the tests and
            5  +# generates output for errors.  No output means no errors were found.
            6  +#
            7  +# Copyright (c) 1997 Sun Microsystems, Inc.
            8  +# Copyright (c) 1998-1999 by Scriptics Corporation.
            9  +#
           10  +# See the file "license.terms" for information on usage and redistribution
           11  +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
           12  +#
           13  +# RCS: @(#) $Id: winTime.test,v 1.1.2.1 1999/04/06 00:29:19 stanton Exp $
           14  +
           15  +if {[lsearch [namespace children] ::tcltest] == -1} {
           16  +    source [file join [pwd] [file dirname [info script]] defs.tcl]
           17  +}
           18  +
           19  +# The next two tests will crash on Windows if the check for negative
           20  +# clock values is not done properly.
           21  +
           22  +test winTime-1.1 {TclpGetDate} {pcOnly} {
           23  +    set ::env(TZ) JST-9
           24  +    set result [clock format -1 -format %Y]
           25  +    unset ::env(TZ)
           26  +    set result
           27  +} {1970}
           28  +test winTime-1.2 {TclpGetDate} {pcOnly} {
           29  +    set ::env(TZ) PST8
           30  +    set result [clock format 1 -format %Y]
           31  +    unset ::env(TZ)
           32  +    set result
           33  +} {1969}
           34  +
           35  +# cleanup
           36  +::tcltest::cleanupTests
           37  +return
           38  +
           39  +
           40  +
           41  +
           42  +
           43  +
           44  +
           45  +
           46  +
           47  +
           48  +
           49  +

Changes to win/tclWinTime.c.

     5      5    *	obtain time values from the operating system.
     6      6    *
     7      7    * Copyright 1995-1998 by Sun Microsystems, Inc.
     8      8    *
     9      9    * See the file "license.terms" for information on usage and redistribution
    10     10    * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    11     11    *
    12         - * RCS: @(#) $Id: tclWinTime.c,v 1.1.2.3 1999/03/10 06:49:31 stanton Exp $
           12  + * RCS: @(#) $Id: tclWinTime.c,v 1.1.2.4 1999/04/06 00:29:19 stanton Exp $
    13     13    */
    14     14   
    15     15   #include "tclWinInt.h"
    16     16   
    17     17   #define SECSPERDAY (60L * 60L * 24L)
    18     18   #define SECSPERYEAR (SECSPERDAY * 365L)
    19     19   #define SECSPER4YEAR (SECSPERYEAR * 4L + SECSPERDAY)
................................................................................
   265    265   
   266    266   	/*
   267    267   	 * If we are in the valid range, let the C run-time library
   268    268   	 * handle it.  Otherwise we need to fake it.  Note that this
   269    269   	 * algorithm ignores daylight savings time before the epoch.
   270    270   	 */
   271    271   
   272         -	time = *tp - _timezone;
   273         -	if (time >= 0) {
          272  +	if (*tp >= 0) {
   274    273   	    return localtime(tp);
   275    274   	}
          275  +
          276  +	time = *tp - _timezone;
   276    277   	
   277    278   	/*
   278    279   	 * If we aren't near to overflowing the long, just add the bias and
   279    280   	 * use the normal calculation.  Otherwise we will need to adjust
   280    281   	 * the result at the end.
   281    282   	 */
   282    283