summaryrefslogtreecommitdiffstats
path: root/generic/ttk
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2008-08-19 14:48:00 (GMT)
committerjenglish <jenglish@flightlab.com>2008-08-19 14:48:00 (GMT)
commit8e04a7f82f31ef347a39c58d53f4b3d3d52dc323 (patch)
treeb7d2b9b4dea24ec9eac88253408fb5ff88e1fa11 /generic/ttk
parentc1764107397069155a945b26c24fd27025fd692d (diff)
downloadtk-8e04a7f82f31ef347a39c58d53f4b3d3d52dc323.zip
tk-8e04a7f82f31ef347a39c58d53f4b3d3d52dc323.tar.gz
tk-8e04a7f82f31ef347a39c58d53f4b3d3d52dc323.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')
-rw-r--r--generic/ttk/ttkScroll.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index ab1f1e7..afc1d78 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.5.4.1 2008/08/19 14:48:00 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) {