diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | generic/tclClock.c | 7 | ||||
-rw-r--r-- | generic/tclObj.c | 4 | ||||
-rw-r--r-- | tests/clock.test | 22 |
4 files changed, 38 insertions, 5 deletions
@@ -1,3 +1,13 @@ +2004-09-11 Kevin B. Kenny <kennykb@acm.org> + + * generic/tclClock.c (TclMktimeObjCmd): Corrected a bad check + for error return from 'mktime'. + * generic/tclObj.c (Tcl_GetIntFromObj): Corrected a problem where + demoting a wide to an int failed on a big-endian machine. + [Bug 1026125]. + * tests/clock.test (clock-43.1): Added regression test for + error return from 'mktime'. + 2004-09-11 Miguel Sofer <msofer@users.sf.net> * generic/tclExecute.c (INST_CONCAT1): fix for [Bug 1025834]; diff --git a/generic/tclClock.c b/generic/tclClock.c index e348d58..2f54977 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclClock.c,v 1.31 2004/09/08 15:38:33 kennykb Exp $ + * RCS: @(#) $Id: tclClock.c,v 1.32 2004/09/11 18:57:56 kennykb Exp $ */ #include "tclInt.h" @@ -224,6 +224,7 @@ TclClockMktimeObjCmd( ClientData clientData, int i; struct tm toConvert; /* Time to be converted */ time_t convertedTime; /* Time converted from mktime */ + int localErrno; /* Convert parameters */ @@ -265,12 +266,14 @@ TclClockMktimeObjCmd( ClientData clientData, TzsetIfNecessary(); Tcl_MutexLock( &clockMutex ); + errno = 0; convertedTime = mktime( &toConvert ); + localErrno = errno; Tcl_MutexUnlock( &clockMutex ); /* Return the converted time, or an error if conversion fails */ - if ( convertedTime == -1 ) { + if ( localErrno != 0 ) { Tcl_SetObjResult ( interp, Tcl_NewStringObj( "time value too large/small to represent", diff --git a/generic/tclObj.c b/generic/tclObj.c index 7c9fb47..d681a26 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclObj.c,v 1.65 2004/09/10 22:43:52 dgp Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.66 2004/09/11 18:57:56 kennykb Exp $ */ #include "tclInt.h" @@ -1961,7 +1961,7 @@ Tcl_GetIntFromObj(interp, objPtr, intPtr) } if (((long)((int)l)) == l) { - *intPtr = (int)objPtr->internalRep.longValue; + *intPtr = (int)l; return TCL_OK; } #ifndef TCL_WIDE_INT_IS_LONG diff --git a/tests/clock.test b/tests/clock.test index a83ebf0..47bd228 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.44 2004/09/10 17:50:15 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.45 2004/09/11 18:57:57 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -35281,6 +35281,26 @@ test clock-42.1 {regression test - %z in :localtime when west of Greenwich } \ } \ -result {-0500} +test clock-43.1 {regression test - mktime returning -1} \ + -setup { + if { [info exists env(TZ)] } { + set oldTZ $env(TZ) + } + set env(TZ) UTC0 + } \ + -body { + clock scan 1969-12-31T23:59:59 -format %Y-%m-%dT%T -timezone :localtime + } \ + -cleanup { + if { [info exists oldTZ] } { + set env(TZ) $oldTZ + unset oldTZ + } else { + unset env(TZ) + } + } \ + -result {-1} + # cleanup namespace delete ::testClock |