diff options
author | jenglish <jenglish@flightlab.com> | 2008-08-19 14:48:00 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-08-19 14:48:00 (GMT) |
commit | 93897604fb513d30386f1ad7749a3fefb8b55be6 (patch) | |
tree | b7d2b9b4dea24ec9eac88253408fb5ff88e1fa11 /generic | |
parent | 83d4d9ee4363e56070ad0805976fdcbe59a09073 (diff) | |
download | tk-93897604fb513d30386f1ad7749a3fefb8b55be6.zip tk-93897604fb513d30386f1ad7749a3fefb8b55be6.tar.gz tk-93897604fb513d30386f1ad7749a3fefb8b55be6.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')
-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..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) { |