diff options
author | kennykb <kennykb@noemail.net> | 2003-02-01 21:27:55 (GMT) |
---|---|---|
committer | kennykb <kennykb@noemail.net> | 2003-02-01 21:27:55 (GMT) |
commit | 25dd6784e54baf6a828e6fef5e9ae0b8c35e7e61 (patch) | |
tree | f7a72eb5e68ad525b2295b75f172ec476cd10ab5 | |
parent | 339090072f3091f90be6f86505fd90611a5508f2 (diff) | |
download | tcl-25dd6784e54baf6a828e6fef5e9ae0b8c35e7e61.zip tcl-25dd6784e54baf6a828e6fef5e9ae0b8c35e7e61.tar.gz tcl-25dd6784e54baf6a828e6fef5e9ae0b8c35e7e61.tar.bz2 |
* generic/tclClock.c: Fixed a bug that incorrectly allowed
[clock clicks {}] and [clock clicks -] to be accepted as if
they were [clock clicks -milliseconds].
* tests/clock.test: Added regression tests for the above bug.
[Bug 675356]
FossilOrigin-Name: c877b70a1bfd74488754bfa3ea60008eded1a4aa
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | generic/tclClock.c | 10 | ||||
-rw-r--r-- | tests/clock.test | 8 |
3 files changed, 22 insertions, 5 deletions
@@ -1,5 +1,14 @@ 2003-02-01 Kevin Kenny <kennykb@users.sourceforge.net> + * generic/tclClock.c: Fixed a bug that incorrectly allowed + [clock clicks {}] and [clock clicks -] to be accepted as if + they were [clock clicks -milliseconds]. + + * tests/clock.test: Added regression tests for the above bug. + [Bug 675356] + +2003-02-01 Kevin Kenny <kennykb@users.sourceforge.net> + * tests/unixNotfy.test: Added cleanup of working files [Bug 675609] diff --git a/generic/tclClock.c b/generic/tclClock.c index e98eba6..55c3bab 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.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: tclClock.c,v 1.19 2003/02/01 19:48:23 kennykb Exp $ + * RCS: @(#) $Id: tclClock.c,v 1.20 2003/02/01 21:27:55 kennykb Exp $ */ #include "tcl.h" @@ -66,6 +66,7 @@ Tcl_ClockObjCmd (client, interp, objc, objv) long zone; Tcl_Obj *baseObjPtr = NULL; char *scanStr; + int n; static CONST char *switches[] = {"clicks", "format", "scan", "seconds", (char *) NULL}; @@ -90,9 +91,10 @@ Tcl_ClockObjCmd (client, interp, objc, objv) int forceMilli = 0; if (objc == 3) { - format = Tcl_GetStringFromObj(objv[2], &index); - if (strncmp(format, "-milliseconds", - (unsigned int) index) == 0) { + format = Tcl_GetStringFromObj(objv[2], &n); + if ( ( n >= 2 ) + && ( strncmp( format, "-milliseconds", + (unsigned int) n) == 0 ) ) { forceMilli = 1; } else { Tcl_AppendStringsToObj(resultPtr, diff --git a/tests/clock.test b/tests/clock.test index cc77260..745c095 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -10,7 +10,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.21 2002/07/05 11:16:01 rmax Exp $ +# RCS: @(#) $Id: clock.test,v 1.22 2003/02/01 21:27:55 kennykb Exp $ set env(LC_TIME) POSIX @@ -51,6 +51,12 @@ test clock-2.5 {clock clicks tests, millisecond timing test} { # 60 msecs seems to be the max time slice under Windows 95/98 expr {($end > $start) && (($end - $start) <= 60)} } {1} +test clock-2.6 {clock clicks, milli with too much abbreviation} { + list [catch { clock clicks {} } msg] $msg +} {1 {bad switch "": must be -milliseconds}} +test clock-2.7 {clock clicks, milli with too much abbreviation} { + list [catch { clock clicks - } msg] $msg +} {1 {bad switch "-": must be -milliseconds}} # clock format test clock-3.1 {clock format tests} {unixOnly} { |