From 96b0a8952cacebf737d5a9c9cc350a0e1f031be1 Mon Sep 17 00:00:00 2001 From: rjohnson Date: Tue, 20 Apr 1999 01:04:04 +0000 Subject: Added new tests to scale and text. Fixed core dump in text serach code: Bug 1642 --- generic/tkText.c | 7 ++++--- tests/scale.test | 18 ++++++++++++++++-- tests/text.test | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index ff08140..b607917 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.5 1999/04/17 02:35:38 rjohnson Exp $ + * RCS: @(#) $Id: tkText.c,v 1.6 1999/04/20 01:04:04 rjohnson Exp $ */ #include "default.h" @@ -1716,12 +1716,13 @@ TextSearchCmd(textPtr, interp, argc, argv) /* * Check for matches within the current line. If so, and if we're * searching backwards, repeat the search to find the last match - * in the line. + * in the line. (Note: The lastByte should include the NULL char + * so we can handle searching for end of line easier.) */ matchByte = -1; firstByte = 0; - lastByte = INT_MAX; + lastByte = Tcl_DStringLength(&line) + 1; if (lineNum == startingLine) { int indexInDString; diff --git a/tests/scale.test b/tests/scale.test index f52c050..b1941f5 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: scale.test,v 1.5 1999/04/19 23:54:57 hershey Exp $ +# RCS: @(#) $Id: scale.test,v 1.6 1999/04/20 01:04:04 rjohnson Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -92,8 +92,8 @@ foreach test { .s configure $name [lindex [.s configure $name] 3] incr i } - destroy .s + test scale-2.1 {Tk_ScaleCmd procedure} { list [catch {scale} msg] $msg } {1 {wrong # args: should be "scale pathName ?options?"}} @@ -796,6 +796,20 @@ test scale-16.1 {scale widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] +test scale-17.1 {bug fix 1786} { + # Perhaps x is set to {}, depending on what other tests have run. + # If x is unset, or set to something not convertable to a double, + # then the scale try to initialize its value with the contents + # of uninitialized memory. Sometimes that causes an FPE. + + set x {} + scale .s -from 100 -to 300 + pack .s + update + .s configure -variable x ;# CRASH! -> Floating point exception + set x +} {} + catch {destroy .s} option clear diff --git a/tests/text.test b/tests/text.test index fd953d0..a3f519f 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: text.test,v 1.3 1999/04/16 01:51:40 stanton Exp $ +# RCS: @(#) $Id: text.test,v 1.4 1999/04/20 01:04:04 rjohnson Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -1279,6 +1279,19 @@ test text-23.1 {text widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] +test text-24.1 {bug fix - 1642} { + catch {destroy .t} + text .t + pack .t + .t insert end "line 1\n" + .t insert end "line 2\n" + .t insert end "line 3\n" + .t insert end "line 4\n" + .t insert end "line 5\n" + tkTextSetCursor .t 3.0 + .t search -backward -regexp "\$" insert 1.0 +} {2.6} + eval destroy [winfo child .] option clear -- cgit v0.12