diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkTextDisp.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e0d1d57..2a3cf44 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.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: tkTextDisp.c,v 1.9 2000/01/06 02:18:59 hobbs Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.10 2002/04/22 12:45:49 dkf Exp $ */ #include "tkPort.h" @@ -96,6 +96,16 @@ typedef struct TextStyle { && ((s1)->sValuePtr->bgStipple == (s2)->sValuePtr->bgStipple)) /* + * The following macro is used to compare two floating-point numbers + * to within a certain degree of scale. Direct comparison fails on + * processors where the processor and memory representations of FP + * numbers of a particular precision is different (e.g. Intel) + */ + +#define FP_EQUAL_SCALE(double1, double2, scaleFactor) \ + (fabs((double1)-(double2))*((scaleFactor)+1.0) < 0.3) + +/* * The following structure describes one line of the display, which may * be either part or all of one line of the text. */ @@ -3865,7 +3875,7 @@ GetXView(interp, textPtr, report) * scrollbar if it has changed. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - char buffer[TCL_DOUBLE_SPACE * 2]; + char buffer[TCL_DOUBLE_SPACE * 2 + 1]; double first, last; int code; @@ -3886,7 +3896,8 @@ GetXView(interp, textPtr, report) Tcl_SetResult(interp, buffer, TCL_VOLATILE); return; } - if ((first == dInfoPtr->xScrollFirst) && (last == dInfoPtr->xScrollLast)) { + if (FP_EQUAL_SCALE(first, dInfoPtr->xScrollFirst, dInfoPtr->maxLength) && + FP_EQUAL_SCALE(last, dInfoPtr->xScrollLast, dInfoPtr->maxLength)) { return; } dInfoPtr->xScrollFirst = first; @@ -3936,7 +3947,7 @@ GetYView(interp, textPtr, report) * scrollbar if it has changed. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - char buffer[TCL_DOUBLE_SPACE * 2]; + char buffer[TCL_DOUBLE_SPACE * 2 + 1]; double first, last; DLine *dlPtr; int totalLines, code, count; @@ -3971,7 +3982,8 @@ GetYView(interp, textPtr, report) Tcl_SetResult(interp, buffer, TCL_VOLATILE); return; } - if ((first == dInfoPtr->yScrollFirst) && (last == dInfoPtr->yScrollLast)) { + if (FP_EQUAL_SCALE(first, dInfoPtr->yScrollFirst, totalLines) && + FP_EQUAL_SCALE(last, dInfoPtr->yScrollLast, totalLines)) { return; } dInfoPtr->yScrollFirst = first; |