summaryrefslogtreecommitdiffstats
path: root/generic/tkListbox.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-10-03 13:13:31 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-10-03 13:13:31 (GMT)
commit8b4ecc93591895810fb1546a33a8dbd0ac0ab131 (patch)
tree5f8791b7d6fede6856ef719fbb242afe7ff5bc5f /generic/tkListbox.c
parentc235c1b9bd589c5b0d1fa2ca85f45f1521cf188c (diff)
downloadtk-8b4ecc93591895810fb1546a33a8dbd0ac0ab131.zip
tk-8b4ecc93591895810fb1546a33a8dbd0ac0ab131.tar.gz
tk-8b4ecc93591895810fb1546a33a8dbd0ac0ab131.tar.bz2
Convert %g to Tcl_PrintDouble to avoid locale trouble. [Bug 2112563]
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r--generic/tkListbox.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 5f52f64..6a61416 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.45 2008/07/23 23:24:21 nijtmans Exp $
+ * RCS: @(#) $Id: tkListbox.c,v 1.46 2008/10/03 13:13:31 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, fraction1, 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], lastStr[TCL_DOUBLE_SPACE];
double first, last;
int result;
Tcl_Interp *interp;
@@ -3256,14 +3260,15 @@ 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);
+ Tcl_PrintDouble(NULL, first, firstStr);
+ Tcl_PrintDouble(NULL, last, lastStr);
/*
* We must hold onto the interpreter from the listPtr because the data at
@@ -3271,14 +3276,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 +3311,7 @@ static void
ListboxUpdateHScrollbar(
register Listbox *listPtr) /* Information about widget. */
{
- char string[TCL_DOUBLE_SPACE * 2];
+ char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
int result, windowWidth;
double first, last;
Tcl_Interp *interp;
@@ -3326,7 +3332,8 @@ ListboxUpdateHScrollbar(
last = 1.0;
}
}
- sprintf(string, " %g %g", first, last);
+ Tcl_PrintDouble(NULL, first, firstStr);
+ Tcl_PrintDouble(NULL, last, lastStr);
/*
* We must hold onto the interpreter because the data referred to at
@@ -3334,14 +3341,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);
}
/*