From 778c10e60d67016b0c995e940b0a9aeaed8aeba8 Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Thu, 30 Oct 2014 15:07:28 +0000 Subject: Pushing the fix out to more files. --- generic/tkScale.c | 10 ++++------ generic/tkScale.h | 6 ------ macosx/tkMacOSXScale.c | 2 +- tests/scale.test | 1 - unix/tkUnixScale.c | 8 ++++---- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index 258a1fa..69a7d91 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -632,12 +632,7 @@ ConfigureScale( scalePtr->tickInterval = -scalePtr->tickInterval; } - if (scalePtr->digits > TCL_MAX_PREC) { - Tcl_AppendResult(interp, "too large -digits value", NULL); - continue; - } else { - ComputeFormat(scalePtr); - } + ComputeFormat(scalePtr); scalePtr->labelLength = scalePtr->label ? (int)strlen(scalePtr->label) : 0; @@ -813,6 +808,9 @@ ComputeFormat( */ numDigits = scalePtr->digits; + if (numDigits > TCL_MAX_PREC) { + numDigits = 0; + } if (numDigits <= 0) { if (scalePtr->resolution > 0) { /* diff --git a/generic/tkScale.h b/generic/tkScale.h index f406bf6..a2c5f2b 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -220,12 +220,6 @@ typedef struct TkScale { #define SPACING 2 /* - * How many characters of space to provide when formatting the scale's value: - */ - -#define PRINT_CHARS 150 - -/* * Declaration of procedures used in the implementation of the scale widget. */ diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index e94763d..a37029c 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -145,7 +145,7 @@ TkpDisplayScale( Tk_Window tkwin = scalePtr->tkwin; Tcl_Interp *interp = scalePtr->interp; int result; - char string[PRINT_CHARS]; + char string[TCL_DOUBLE_SPACE]; MacScale *macScalePtr = (MacScale *) clientData; Rect r; WindowRef windowRef; diff --git a/tests/scale.test b/tests/scale.test index 527b319..657f668 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -35,7 +35,6 @@ foreach test { {-command "set x" {set x} {} {}} {-cursor arrow arrow badValue {bad cursor spec "badValue"}} {-digits 5 5 badValue {expected integer but got "badValue"}} - {-digits 17 17 18 {too large -digits value}} {-fg #00ff00 #00ff00 badValue {unknown color name "badValue"}} {-font fixed fixed {} {font "" doesn't exist}} {-foreground green green badValue {unknown color name "badValue"}} diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index e158549..71f9ea8 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -262,7 +262,7 @@ DisplayVerticalValue( { register Tk_Window tkwin = scalePtr->tkwin; int y, width, length; - char valueString[PRINT_CHARS]; + char valueString[TCL_DOUBLE_SPACE]; Tk_FontMetrics fm; Tk_GetFontMetrics(scalePtr->tkfont, &fm); @@ -341,7 +341,7 @@ DisplayHorizontalScale( */ if (tickInterval != 0) { - char valueString[PRINT_CHARS]; + char valueString[TCL_DOUBLE_SPACE]; double ticks, maxTicks; /* @@ -478,7 +478,7 @@ DisplayHorizontalValue( { register Tk_Window tkwin = scalePtr->tkwin; int x, y, length, width; - char valueString[PRINT_CHARS]; + char valueString[TCL_DOUBLE_SPACE]; Tk_FontMetrics fm; x = TkScaleValueToPixel(scalePtr, value); @@ -535,7 +535,7 @@ TkpDisplayScale( Tcl_Interp *interp = scalePtr->interp; Pixmap pixmap; int result; - char string[PRINT_CHARS]; + char string[TCL_DOUBLE_SPACE]; XRectangle drawnArea; scalePtr->flags &= ~REDRAW_PENDING; -- cgit v0.12