diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-10-05 11:34:45 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-10-05 11:34:45 (GMT) |
commit | 199d4675fda94dffe00bafa804ea9f5e38f0891b (patch) | |
tree | 3902ed875b423c3eb9023c8bdd524105846cc013 /generic | |
parent | 8a44d010fe0fe2f1b6787480556519e67e5458f2 (diff) | |
download | tk-199d4675fda94dffe00bafa804ea9f5e38f0891b.zip tk-199d4675fda94dffe00bafa804ea9f5e38f0891b.tar.gz tk-199d4675fda94dffe00bafa804ea9f5e38f0891b.tar.bz2 |
Backport of fix for [Bug 2112563]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkArgv.c | 4 | ||||
-rw-r--r-- | generic/tkCanvText.c | 13 | ||||
-rw-r--r-- | generic/tkEntry.c | 22 | ||||
-rw-r--r-- | generic/tkListbox.c | 53 | ||||
-rw-r--r-- | generic/tkScrollbar.c | 6 |
5 files changed, 60 insertions, 38 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c index 1a530b2..52ee080 100644 --- a/generic/tkArgv.c +++ b/generic/tkArgv.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkArgv.c,v 1.11.2.2 2008/04/07 22:27:21 hobbs Exp $ + * RCS: @(#) $Id: tkArgv.c,v 1.11.2.3 2008/10/05 11:34:46 dkf Exp $ */ #include "tkInt.h" @@ -380,7 +380,7 @@ PrintUsage( Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL); break; case TK_ARGV_FLOAT: - sprintf(tmp, "%g", *((double *) infoPtr->dst)); + Tcl_PrintDouble(NULL, *((double *) infoPtr->dst), tmp); Tcl_AppendResult(interp, "\n\t\tDefault value: ", tmp, NULL); break; case TK_ARGV_STRING: { diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 1dfdc7f..40ca817 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvText.c,v 1.26 2007/12/13 15:24:13 dgp Exp $ + * RCS: @(#) $Id: tkCanvText.c,v 1.26.2.1 2008/10/05 11:34:46 dkf Exp $ */ #include <stdio.h> @@ -1501,9 +1501,14 @@ TextToPostscript( } Tk_GetFontMetrics(textPtr->tkfont, &fm); - sprintf(buffer, "] %d %g %g %s %s DrawText\n", - fm.linespace, x / -2.0, y / 2.0, justify, - ((stipple == None) ? "false" : "true")); + sprintf(buffer, "] %d ", fm.linespace); + Tcl_AppendResult(interp, buffer, NULL); + Tcl_PrintDouble(NULL, x / -2.0, buffer); + Tcl_AppendResult(interp, buffer, NULL); + Tcl_PrintDouble(NULL, y / 2.0, buffer); + Tcl_AppendResult(interp, " ", buffer, NULL); + sprintf(buffer, " %s %s DrawText\n", + justify, ((stipple == None) ? "false" : "true")); Tcl_AppendResult(interp, buffer, NULL); return TCL_OK; diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 62b0806..3ba727f 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkEntry.c,v 1.47 2007/12/13 15:24:14 dgp Exp $ + * RCS: @(#) $Id: tkEntry.c,v 1.47.2.1 2008/10/05 11:34:46 dkf Exp $ */ #include "tkInt.h" @@ -926,11 +926,13 @@ EntryWidgetObjCmd( if (objc == 2) { double first, last; - char buf[TCL_DOUBLE_SPACE * 2]; + char buf[TCL_DOUBLE_SPACE]; EntryVisibleRange(entryPtr, &first, &last); - sprintf(buf, "%g %g", first, last); + Tcl_PrintDouble(NULL, first, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_PrintDouble(NULL, last, buf); + Tcl_AppendResult(interp, " ", buf, NULL); goto done; } else if (objc == 3) { if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), @@ -2928,7 +2930,7 @@ static void EntryUpdateScrollbar( Entry *entryPtr) /* Information about widget. */ { - char args[TCL_DOUBLE_SPACE * 2]; + char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE]; int code; double first, last; Tcl_Interp *interp; @@ -2940,8 +2942,10 @@ EntryUpdateScrollbar( interp = entryPtr->interp; Tcl_Preserve((ClientData) interp); EntryVisibleRange(entryPtr, &first, &last); - sprintf(args, " %g %g", first, last); - code = Tcl_VarEval(interp, entryPtr->scrollCmd, args, NULL); + Tcl_PrintDouble(NULL, first, firstStr); + Tcl_PrintDouble(NULL, last, lastStr); + code = Tcl_VarEval(interp, entryPtr->scrollCmd, firstStr, " ", lastStr, + NULL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (horizontal scrolling command executed by "); @@ -4041,11 +4045,13 @@ SpinboxWidgetObjCmd( if (objc == 2) { double first, last; - char buf[TCL_DOUBLE_SPACE * 2]; + char buf[TCL_DOUBLE_SPACE]; EntryVisibleRange(entryPtr, &first, &last); - sprintf(buf, "%g %g", first, last); + Tcl_PrintDouble(NULL, first, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_PrintDouble(NULL, last, buf); + Tcl_AppendResult(interp, " ", buf, NULL); goto done; } else if (objc == 3) { if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), diff --git a/generic/tkListbox.c b/generic/tkListbox.c index f3d5c65..e970ac2 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkListbox.c,v 1.44 2007/12/13 15:24:15 dgp Exp $ + * RCS: @(#) $Id: tkListbox.c,v 1.44.2.1 2008/10/05 11:34:46 dkf Exp $ */ #include "default.h" @@ -1248,7 +1248,7 @@ ListboxXviewSubCmd( if (listPtr->maxWidth == 0) { Tcl_SetResult(interp, "0 1", TCL_STATIC); } else { - char buf[TCL_DOUBLE_SPACE * 2]; + char buf[TCL_DOUBLE_SPACE]; fraction = listPtr->xOffset/((double) listPtr->maxWidth); fraction2 = (listPtr->xOffset + windowWidth) @@ -1256,8 +1256,10 @@ ListboxXviewSubCmd( if (fraction2 > 1.0) { fraction2 = 1.0; } - sprintf(buf, "%g %g", fraction, fraction2); + Tcl_PrintDouble(NULL, fraction, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_PrintDouble(NULL, fraction2, buf); + Tcl_AppendResult(interp, " ", buf, NULL); } } else if (objc == 3) { if (Tcl_GetIntFromObj(interp, objv[2], &index) != TCL_OK) { @@ -1320,7 +1322,7 @@ ListboxYviewSubCmd( if (listPtr->nElements == 0) { Tcl_SetResult(interp, "0 1", TCL_STATIC); } else { - char buf[TCL_DOUBLE_SPACE * 2]; + char buf[TCL_DOUBLE_SPACE]; fraction = listPtr->topIndex/((double) listPtr->nElements); fraction2 = (listPtr->topIndex+listPtr->fullLines) @@ -1328,8 +1330,10 @@ ListboxYviewSubCmd( if (fraction2 > 1.0) { fraction2 = 1.0; } - sprintf(buf, "%g %g", fraction, fraction2); + Tcl_PrintDouble(NULL, fraction, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); + Tcl_PrintDouble(NULL, fraction2, buf); + Tcl_AppendResult(interp, " ", buf, NULL); } } else if (objc == 3) { if (GetListboxIndex(interp, listPtr, objv[2], 0, &index) != TCL_OK) { @@ -3244,7 +3248,7 @@ static void ListboxUpdateVScrollbar( register Listbox *listPtr) /* Information about widget. */ { - char string[TCL_DOUBLE_SPACE * 2]; + char firstStr[TCL_DOUBLE_SPACE+1], lastStr[TCL_DOUBLE_SPACE+1]; double first, last; int result; Tcl_Interp *interp; @@ -3256,14 +3260,16 @@ ListboxUpdateVScrollbar( first = 0.0; last = 1.0; } else { - first = listPtr->topIndex/((double) listPtr->nElements); - last = (listPtr->topIndex+listPtr->fullLines) - /((double) listPtr->nElements); + first = listPtr->topIndex / (double) listPtr->nElements; + last = (listPtr->topIndex + listPtr->fullLines) + / (double) listPtr->nElements; if (last > 1.0) { last = 1.0; } } - sprintf(string, " %g %g", first, last); + firstStr[0] = lastStr[0] = ' '; + Tcl_PrintDouble(NULL, first, firstStr+1); + Tcl_PrintDouble(NULL, last, lastStr+1); /* * We must hold onto the interpreter from the listPtr because the data at @@ -3271,14 +3277,15 @@ ListboxUpdateVScrollbar( */ interp = listPtr->interp; - Tcl_Preserve((ClientData) interp); - result = Tcl_VarEval(interp, listPtr->yScrollCmd, string, NULL); + Tcl_Preserve(interp); + result = Tcl_VarEval(interp, listPtr->yScrollCmd, firstStr, lastStr, + NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (vertical scrolling command executed by listbox)"); Tcl_BackgroundError(interp); } - Tcl_Release((ClientData) interp); + Tcl_Release(interp); } /* @@ -3305,7 +3312,7 @@ static void ListboxUpdateHScrollbar( register Listbox *listPtr) /* Information about widget. */ { - char string[TCL_DOUBLE_SPACE * 2]; + char firstStr[TCL_DOUBLE_SPACE+1], lastStr[TCL_DOUBLE_SPACE+1]; int result, windowWidth; double first, last; Tcl_Interp *interp; @@ -3319,14 +3326,17 @@ ListboxUpdateHScrollbar( first = 0; last = 1.0; } else { - first = listPtr->xOffset/((double) listPtr->maxWidth); - last = (listPtr->xOffset + windowWidth) - /((double) listPtr->maxWidth); + register double maxWide = (double) listPtr->maxWidth; + + first = listPtr->xOffset / maxWide; + last = (listPtr->xOffset + windowWidth) / maxWide; if (last > 1.0) { last = 1.0; } } - sprintf(string, " %g %g", first, last); + firstStr[0] = lastStr[0] = ' '; + Tcl_PrintDouble(NULL, first, firstStr+1); + Tcl_PrintDouble(NULL, last, lastStr+1); /* * We must hold onto the interpreter because the data referred to at @@ -3334,14 +3344,15 @@ ListboxUpdateHScrollbar( */ interp = listPtr->interp; - Tcl_Preserve((ClientData) interp); - result = Tcl_VarEval(interp, listPtr->xScrollCmd, string, NULL); + Tcl_Preserve(interp); + result = Tcl_VarEval(interp, listPtr->xScrollCmd, firstStr, lastStr, + NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (horizontal scrolling command executed by listbox)"); Tcl_BackgroundError(interp); } - Tcl_Release((ClientData) interp); + Tcl_Release(interp); } /* diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 52e449f..ecbe729 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScrollbar.c,v 1.12 2007/12/13 15:24:16 dgp Exp $ + * RCS: @(#) $Id: tkScrollbar.c,v 1.12.2.1 2008/10/05 11:34:46 dkf Exp $ */ #include "tkInt.h" @@ -324,7 +324,7 @@ ScrollbarWidgetCmd( } else { fraction = ((double) pixels / (double) length); } - sprintf(buf, "%g", fraction); + Tcl_PrintDouble(NULL, fraction, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) { int x, y, pos, length; @@ -359,7 +359,7 @@ ScrollbarWidgetCmd( } else if (fraction > 1.0) { fraction = 1.0; } - sprintf(buf, "%g", fraction); + Tcl_PrintDouble(NULL, fraction, buf); Tcl_SetResult(interp, buf, TCL_VOLATILE); } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { if (argc != 2) { |