summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkArgv.c4
-rw-r--r--generic/tkCanvText.c11
-rw-r--r--generic/tkEntry.c117
-rw-r--r--generic/tkListbox.c44
-rw-r--r--generic/tkScrollbar.c10
5 files changed, 102 insertions, 84 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 039b4d1..95fbe21 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.14 2008/04/27 22:38:55 dkf Exp $
+ * RCS: @(#) $Id: tkArgv.c,v 1.15 2008/10/03 13:13:31 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 34206ea..3450633 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.27 2008/04/27 22:38:55 dkf Exp $
+ * RCS: @(#) $Id: tkCanvText.c,v 1.28 2008/10/03 13:13:31 dkf Exp $
*/
#include <stdio.h>
@@ -1501,8 +1501,13 @@ TextToPostscript(
}
Tk_GetFontMetrics(textPtr->tkfont, &fm);
- sprintf(buffer, "] %d %g %g %s %s DrawText\n",
- fm.linespace, x / -2.0, y / 2.0, justify,
+ 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);
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 26249d4..fa0c07e 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.49 2008/07/23 23:24:23 nijtmans Exp $
+ * RCS: @(#) $Id: tkEntry.c,v 1.50 2008/10/03 13:13:31 dkf Exp $
*/
#include "tkInt.h"
@@ -452,8 +452,7 @@ static Tk_ClassProcs entryClass = {
sizeof(Tk_ClassProcs), /* size */
EntryWorldChanged, /* worldChangedProc */
};
-
-
+
/*
*--------------------------------------------------------------
*
@@ -508,7 +507,7 @@ Tk_EntryObjCmd(
* initialized as memset covers the rest.
*/
- entryPtr = (Entry *) ckalloc(sizeof(Entry));
+ entryPtr = (Entry *) ckalloc(sizeof(Entry));
memset(entryPtr, 0, sizeof(Entry));
entryPtr->tkwin = tkwin;
@@ -563,7 +562,7 @@ Tk_EntryObjCmd(
Tcl_SetResult(interp, Tk_PathName(entryPtr->tkwin), TCL_STATIC);
return TCL_OK;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -926,11 +925,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]),
@@ -987,7 +988,7 @@ EntryWidgetObjCmd(
Tcl_Release(entryPtr);
return TCL_ERROR;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1053,7 +1054,7 @@ DestroyEntry(
ckfree((char *) entryPtr);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1114,12 +1115,12 @@ ConfigureEntry(
* value.
*/
- oldExport = entryPtr->exportSelection;
+ oldExport = entryPtr->exportSelection;
if (entryPtr->type == TK_SPINBOX) {
- oldValues = sbPtr->valueStr;
- oldFormat = sbPtr->reqFormat;
- oldFrom = sbPtr->fromValue;
- oldTo = sbPtr->toValue;
+ oldValues = sbPtr->valueStr;
+ oldFormat = sbPtr->reqFormat;
+ oldFrom = sbPtr->fromValue;
+ oldTo = sbPtr->toValue;
}
for (error = 0; error <= 1; error++) {
@@ -1368,7 +1369,7 @@ ConfigureEntry(
return TCL_OK;
}
}
-
+
/*
*---------------------------------------------------------------------------
*
@@ -1420,8 +1421,8 @@ EntryWorldChanged(
* the background may be overridden.
*/
- border = entryPtr->normalBorder;
- colorPtr = entryPtr->fgColorPtr;
+ border = entryPtr->normalBorder;
+ colorPtr = entryPtr->fgColorPtr;
switch (entryPtr->state) {
case STATE_DISABLED:
if (entryPtr->disabledBorder != NULL) {
@@ -1468,7 +1469,7 @@ EntryWorldChanged(
entryPtr->flags |= UPDATE_SCROLLBAR;
EventuallyRedraw(entryPtr);
}
-
+
#ifndef MAC_OSX_TK
/*
*--------------------------------------------------------------
@@ -1498,7 +1499,7 @@ TkpDrawEntryBorderAndFocus(
{
return 0;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -1527,7 +1528,7 @@ TkpDrawSpinboxButtons(
return 0;
}
#endif /* Not MAC_OSX_TK */
-
+
/*
*--------------------------------------------------------------
*
@@ -1846,7 +1847,7 @@ DisplayEntry(
#endif /* TK_NO_DOUBLE_BUFFERING */
entryPtr->flags &= ~BORDER_NEEDED;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1982,7 +1983,7 @@ EntryComputeGeometry(
Tk_GeometryRequest(entryPtr->tkwin, width, height);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2022,7 +2023,7 @@ InsertChars(
}
newByteCount = entryPtr->numBytes + byteCount + 1;
- newStr = (char *) ckalloc((unsigned) newByteCount);
+ newStr = ckalloc((unsigned) newByteCount);
memcpy(newStr, string, byteIndex);
strcpy(newStr + byteIndex, value);
strcpy(newStr + byteIndex + byteCount, string + byteIndex);
@@ -2082,7 +2083,7 @@ InsertChars(
}
EntryValueChanged(entryPtr, NULL);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2122,11 +2123,11 @@ DeleteChars(
byteCount = Tcl_UtfAtIndex(string + byteIndex, count) - (string+byteIndex);
newByteCount = entryPtr->numBytes + 1 - byteCount;
- newStr = (char *) ckalloc((unsigned) newByteCount);
+ newStr = ckalloc((unsigned) newByteCount);
memcpy(newStr, string, (size_t) byteIndex);
strcpy(newStr + byteIndex, string + byteIndex + byteCount);
- toDelete = (char *) ckalloc((unsigned) (byteCount + 1));
+ toDelete = ckalloc((unsigned) (byteCount + 1));
memcpy(toDelete, string + byteIndex, (size_t) byteCount);
toDelete[byteCount] = '\0';
@@ -2197,7 +2198,7 @@ DeleteChars(
}
EntryValueChanged(entryPtr, NULL);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2253,7 +2254,7 @@ EntryValueChanged(
EventuallyRedraw(entryPtr);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2327,7 +2328,7 @@ EntrySetValue(
if (malloced) {
entryPtr->string = value;
} else {
- char *tmp = (char *) ckalloc((unsigned) (valueLen + 1));
+ char *tmp = ckalloc((unsigned) (valueLen + 1));
strcpy(tmp, value);
entryPtr->string = tmp;
@@ -2363,7 +2364,7 @@ EntrySetValue(
EntryComputeGeometry(entryPtr);
EventuallyRedraw(entryPtr);
}
-
+
/*
*--------------------------------------------------------------
*
@@ -2445,7 +2446,7 @@ EntryEventProc(
break;
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2481,7 +2482,7 @@ EntryCmdDeletedProc(
Tk_DestroyWindow(entryPtr->tkwin);
}
}
-
+
/*
*---------------------------------------------------------------------------
*
@@ -2601,7 +2602,7 @@ GetEntryIndex(
}
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2659,7 +2660,7 @@ EntryScanTo(
EventuallyRedraw(entryPtr);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2720,7 +2721,7 @@ EntrySelectTo(
entryPtr->selectLast = newLast;
EventuallyRedraw(entryPtr);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2815,7 +2816,7 @@ EntryLostSelection(
EventuallyRedraw(entryPtr);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2854,7 +2855,7 @@ EventuallyRedraw(
Tcl_DoWhenIdle(DisplayEntry, entryPtr);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2903,7 +2904,7 @@ EntryVisibleRange(
/ entryPtr->numChars;
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2928,7 +2929,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 +2941,10 @@ EntryUpdateScrollbar(
interp = entryPtr->interp;
Tcl_Preserve(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 ");
@@ -2952,7 +2955,7 @@ EntryUpdateScrollbar(
Tcl_SetResult(interp, NULL, TCL_STATIC);
Tcl_Release(interp);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -2993,7 +2996,7 @@ EntryBlinkProc(
}
EventuallyRedraw(entryPtr);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -3043,7 +3046,7 @@ EntryFocusProc(
}
EventuallyRedraw(entryPtr);
}
-
+
/*
*--------------------------------------------------------------
*
@@ -3110,7 +3113,7 @@ EntryTextVarProc(
EntrySetValue(entryPtr, value);
return NULL;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -3171,7 +3174,7 @@ EntryValidate(
Tcl_SetResult(interp, NULL, 0);
return (bool ? TCL_OK : TCL_BREAK);
}
-
+
/*
*--------------------------------------------------------------
*
@@ -3308,7 +3311,7 @@ EntryValidateChange(
return code;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -3474,7 +3477,7 @@ ExpandPercents(
Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
}
}
-
+
/*
*--------------------------------------------------------------
*
@@ -3530,7 +3533,7 @@ Tk_SpinboxObjCmd(
* initialized as memset covers the rest.
*/
- sbPtr = (Spinbox *) ckalloc(sizeof(Spinbox));
+ sbPtr = (Spinbox *) ckalloc(sizeof(Spinbox));
entryPtr = (Entry *) sbPtr;
memset(sbPtr, 0, sizeof(Spinbox));
@@ -3604,7 +3607,7 @@ Tk_SpinboxObjCmd(
Tk_DestroyWindow(entryPtr->tkwin);
return TCL_ERROR;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -4043,11 +4046,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]),
@@ -4105,7 +4110,7 @@ SpinboxWidgetObjCmd(
Tcl_Release(entryPtr);
return TCL_ERROR;
}
-
+
/*
*---------------------------------------------------------------------------
*
@@ -4144,7 +4149,7 @@ GetSpinboxElement(
}
return SEL_ENTRY;
}
-
+
/*
*--------------------------------------------------------------
*
@@ -4310,7 +4315,7 @@ SpinboxInvoke(
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -4399,7 +4404,7 @@ ComputeFormat(
sbPtr->valueFormat = sbPtr->digitFormat;
return TCL_OK;
}
-
+
/*
* Local Variables:
* mode: c
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);
}
/*
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
index d736539..611da88 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.14 2008/07/23 23:24:21 nijtmans Exp $
+ * RCS: @(#) $Id: tkScrollbar.c,v 1.15 2008/10/03 13:13:31 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) {
@@ -370,8 +370,8 @@ ScrollbarWidgetCmd(
if (scrollPtr->flags & NEW_STYLE_COMMANDS) {
char first[TCL_DOUBLE_SPACE], last[TCL_DOUBLE_SPACE];
- Tcl_PrintDouble(interp, scrollPtr->firstFraction, first);
- Tcl_PrintDouble(interp, scrollPtr->lastFraction, last);
+ Tcl_PrintDouble(NULL, scrollPtr->firstFraction, first);
+ Tcl_PrintDouble(NULL, scrollPtr->lastFraction, last);
Tcl_AppendResult(interp, first, " ", last, NULL);
} else {
char buf[TCL_INTEGER_SPACE * 4];