diff options
author | jenglish@flightlab.com <jenglish> | 2008-08-19 14:47:54 (GMT) |
---|---|---|
committer | jenglish@flightlab.com <jenglish> | 2008-08-19 14:47:54 (GMT) |
commit | c280aabb1428748e32339173d5ee348885977ee0 (patch) | |
tree | c70888bfe7837c6e68b6021de9a3587db899cd04 | |
parent | 0cd7f4c646fcb1ac229543534e0fa7e6097a9ab8 (diff) | |
download | tk-c280aabb1428748e32339173d5ee348885977ee0.zip tk-c280aabb1428748e32339173d5ee348885977ee0.tar.gz tk-c280aabb1428748e32339173d5ee348885977ee0.tar.bz2 |
generic/ttk/ttkScroll.c: Don't use sprintf "%g" to format floating
point numbers in -[xy]scrollcommand callbacks or [xy]view methods.
Minor incompatibility: 0 and 1 now formatted as "0.0" resp "1.0".
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | generic/ttk/ttkScroll.c | 22 | ||||
-rw-r--r-- | tests/ttk/entry.test | 4 | ||||
-rw-r--r-- | tests/ttk/treeview.test | 4 |
4 files changed, 24 insertions, 15 deletions
@@ -1,3 +1,12 @@ +2008-08-19 Joe English <jenglish@users.sourceforge.net> + + * generic/ttk/ttkScroll.c: Don't use sprintf "%g" to + format floating point numbers in -[xy]scrollcommand callbacks + or [xy]view methods. Minor incompatibility: 0 and 1 now + formatted as "0.0" resp "1.0". + * tests/ttk/entry.test, tests/ttk/treeview.test: Updated + to account for above change. + 2008-08-19 Daniel Steffen <das@users.sourceforge.net> * macosx/tkMacOSXFont.c (SetFontFeatures): Disable antialiasing of diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c index ab1f1e7..dc9317e 100644 --- a/generic/ttk/ttkScroll.c +++ b/generic/ttk/ttkScroll.c @@ -1,4 +1,4 @@ -/* $Id: ttkScroll.c,v 1.5 2006/12/18 19:33:13 jenglish Exp $ +/* $Id: ttkScroll.c,v 1.6 2008/08/19 14:47:55 jenglish Exp $ * * Copyright 2004, Joe English * @@ -76,7 +76,8 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h) { Scrollable *s = h->scrollPtr; WidgetCore *corePtr = h->corePtr; - char args[TCL_DOUBLE_SPACE * 2]; + char arg1[TCL_DOUBLE_SPACE + 2]; + char arg2[TCL_DOUBLE_SPACE + 2]; int code; h->flags &= ~SCROLL_UPDATE_REQUIRED; @@ -85,12 +86,12 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h) return TCL_OK; } - sprintf(args, " %g %g", - (double)s->first / s->total, - (double)s->last / s->total); + arg1[0] = arg2[0] = ' '; + Tcl_PrintDouble(interp, (double)s->first / s->total, arg1+1); + Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1); Tcl_Preserve(corePtr); - code = Tcl_VarEval(interp, s->scrollCmd, args, NULL); + code = Tcl_VarEval(interp, s->scrollCmd, arg1, arg2, NULL); if (WidgetDestroyed(corePtr)) { Tcl_Release(corePtr); return TCL_ERROR; @@ -190,11 +191,10 @@ int TtkScrollviewCommand( int newFirst = s->first; if (objc == 2) { - char buf[TCL_DOUBLE_SPACE * 2]; - sprintf(buf, "%g %g", - (double)s->first / s->total, - (double)s->last / s->total); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_Obj *result[2]; + result[0] = Tcl_NewDoubleObj((double)s->first / s->total); + result[1] = Tcl_NewDoubleObj((double)s->last / s->total); + Tcl_SetObjResult(interp, Tcl_NewListObj(2, result)); return TCL_OK; } else if (objc == 3) { if (Tcl_GetIntFromObj(interp, objv[2], &newFirst) != TCL_OK) { diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index 929e856..0c2f0be 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -79,7 +79,7 @@ test entry-2.2 "Initial scroll position" -body { .e insert end "0123456789" pack .e; update set scrollInfo -} -result {0 0.5} -cleanup { destroy .e } +} -result {0.0 0.5} -cleanup { destroy .e } # NOTE: result can vary depending on font. # Bounding box / scrolling tests. @@ -105,7 +105,7 @@ test entry-3.2 "xview" -body { .e insert end [string repeat "0" 40] update idletasks set result [.e xview] -} -result {0 0.5} +} -result {0.0 0.5} test entry-3.last "Series 3 cleanup" -body { destroy .e diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 2a58444..bf5f8ec 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -1,5 +1,5 @@ # -# $Id: treeview.test,v 1.4 2008/05/23 20:20:07 jenglish Exp $ +# $Id: treeview.test,v 1.5 2008/08/19 14:47:55 jenglish Exp $ # # [7Jun2005] TO CHECK: [$tv see {}] -- shouldn't work (at least, shouldn't do # what it currently does) @@ -471,7 +471,7 @@ test treeview-9.0 "scroll callback - empty tree" -body { .tv delete [.tv children {}] update set ::scrolldata -} -result [list 0 1] +} -result [list 0.0 1.0] ### identify tests: # |