diff options
author | jenglish <jenglish@flightlab.com> | 2008-08-19 14:47:54 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-08-19 14:47:54 (GMT) |
commit | 03d77dae7c7add838a4b5a9e29dd3561899decc5 (patch) | |
tree | c70888bfe7837c6e68b6021de9a3587db899cd04 /generic/ttk/ttkScroll.c | |
parent | 8899e854a9fbe9bd153ceb639caab38ac6c150cb (diff) | |
download | tk-03d77dae7c7add838a4b5a9e29dd3561899decc5.zip tk-03d77dae7c7add838a4b5a9e29dd3561899decc5.tar.gz tk-03d77dae7c7add838a4b5a9e29dd3561899decc5.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".
Diffstat (limited to 'generic/ttk/ttkScroll.c')
-rw-r--r-- | generic/ttk/ttkScroll.c | 22 |
1 files changed, 11 insertions, 11 deletions
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) { |