Re: [TCLCORE] The end for Tcl_PrintDouble in Tk?
by Jeff Hobbs other posts by this author
May 20 2009 9:15AM messages near this date
Re: [TCLCORE] The end for Tcl_PrintDouble in Tk?
|
Re: [TCLCORE] The end for Tcl_PrintDouble in Tk?
On 20/05/2009 7:26 AM, Donal K. Fellows wrote:
> Jeff Hobbs wrote:
> > In looking into the best solution for 2790615
> > https://sourceforge.net/tracker/?func=detail&atid=112997&aid=2790615&group_id=12997
> >
> > Don noted that Tcl_ObjPrintf (added in 8.5) or Tcl_AppendFormatToObj
> > would be good alternatives to the coding changes I was using.
> >
> > This would change, eg tkEntry.c:EntryUpdateScrollbar from (partial):
> >
> > EntryVisibleRange(entryPtr, &first, &last);
> > Tcl_PrintDouble(NULL, first, firstStr);
> > Tcl_PrintDouble(NULL, last, lastStr);
> > objPtr = Tcl_NewStringObj(entryPtr->scrollCmd, -1);
> > Tcl_IncrRefCount(objPtr);
> > Tcl_AppendStringsToObj(objPtr, " ", firstStr, " ", lastStr, NULL);
> > code = Tcl_EvalObjEx(interp, objPtr,
> > TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
> > ...
> >
> > to:
> >
> > EntryVisibleRange(entryPtr, &first, &last);
> > objPtr = Tcl_ObjPrintf("%s %f %f", entryPtr->scrollCmd, first,
> > last);
> > Tcl_IncrRefCount(objPtr);
> > code = Tcl_EvalObjEx(interp, objPtr,
> > TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
> > ...
>
> That sort of shortening looks good, but you might also consider using %g
> instead of %f so that very large text and canvas widgets can still scroll.
I tried that, which causes test failures of a different variety (you get
"1"/"0" instead of "1.0"/"0.0"). Don noted that that could cause issues
with expr as dividing by float 0.0 (non-error Inf) has different
behavior than int 0 (error).
Jeff
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Tcl-Core mailing list
Tcl-Core@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-core
Thread:
Jeff Hobbs
Joe English
dgp
Jeff Hobbs
Joe English
Michael Kirkham
Joe English
Jeff Hobbs
|