From: Paul Eggert Date: Thu, 24 Aug 2017 23:15:59 +0000 (-0700) Subject: Prefer ‘double’ for FP temps in xterm.c X-Git-Tag: emacs-26.0.90~363 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=daf434b40d61e8cc99485988017a4a95ff475922;p=emacs.git Prefer ‘double’ for FP temps in xterm.c * src/xterm.c (xm_scroll_callback, xaw_jump_callback) (x_set_toolkit_scroll_bar_thumb) (x_set_toolkit_horizontal_scroll_bar_thumb): Prefer ‘double’ to ‘float’ for individual local floating-point temporaries. --- diff --git a/src/xterm.c b/src/xterm.c index 77daa22ae0d..fb220b335a4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -5575,8 +5575,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data) if (horizontal) { - portion = bar->whole * ((float)cs->value / XM_SB_MAX); - whole = bar->whole * ((float)(XM_SB_MAX - slider_size) / XM_SB_MAX); + double dXM_SB_MAX = XM_SB_MAX; + portion = bar->whole * (cs->value / dXM_SB_MAX); + whole = bar->whole * ((XM_SB_MAX - slider_size) / dXM_SB_MAX); portion = min (portion, whole); part = scroll_bar_horizontal_handle; } @@ -5713,7 +5714,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) { struct scroll_bar *bar = client_data; float *top_addr = call_data; - float top = *top_addr; + double top = *top_addr; float shown; int whole, portion, height, width; enum scroll_bar_part part; @@ -5729,7 +5730,8 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) if (shown < 1) { - whole = bar->whole - (shown * bar->whole); + double dshown = shown; + whole = bar->whole - (dshown * bar->whole); portion = min (top * bar->whole, whole); } else @@ -5750,7 +5752,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) whole = 10000000; portion = shown < 1 ? top * whole : 0; - if (shown < 1 && (eabs (top + shown - 1) < 1.0f / height)) + if (shown < 1 && (eabs (top + shown - 1) < 1.0 / height)) /* Some derivatives of Xaw refuse to shrink the thumb when you reach the bottom, so we force the scrolling whenever we see that we're too close to the bottom (in x_set_toolkit_scroll_bar_thumb @@ -6293,7 +6295,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); - float top, shown; + double dwhole = whole; + double top, shown; block_input (); @@ -6322,8 +6325,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio top = 0, shown = 1; else { - top = (float) position / whole; - shown = (float) portion / whole; + top = position / dwhole; + shown = portion / dwhole; } if (bar->dragging == -1) @@ -6347,8 +6350,8 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio top = 0, shown = 1; else { - top = (float) position / whole; - shown = (float) portion / whole; + top = position / dwhole; + shown = portion / dwhole; } { @@ -6368,19 +6371,20 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio #if ! defined (HAVE_XAW3D) /* With Xaw, 'top' values too closer to 1.0 may cause the thumb to disappear. Fix that. */ - top = min (top, 0.99f); + top = min (top, 0.99); #endif /* Keep two pixels available for moving the thumb down. */ - shown = max (0, min (1 - top - (2.0f / height), shown)); + shown = max (0, min (1 - top - (2.0 / height), shown)); #if ! defined (HAVE_XAW3D) /* Likewise with too small 'shown'. */ - shown = max (shown, 0.01f); + shown = max (shown, 0.01); #endif /* If the call to XawScrollbarSetThumb below doesn't seem to work, check that 'NARROWPROTO' is defined in src/config.h. If this is not so, most likely you need to fix configure. */ - if (top != old_top || shown != old_shown) + float ftop = top, fshown = shown; + if (ftop != old_top || fshown != old_shown) { if (bar->dragging == -1) XawScrollbarSetThumb (widget, top, shown); @@ -6405,14 +6409,15 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); - float top, shown; + double dwhole = whole; + double top, shown; block_input (); #ifdef USE_MOTIF bar->whole = whole; - shown = (float) portion / whole; - top = (float) position / (whole - portion); + shown = portion / dwhole; + top = position / (dwhole - portion); { int size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX); int value = clip_to_bounds (0, top * (XM_SB_MAX - size), XM_SB_MAX - size); @@ -6425,8 +6430,8 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, top = 0, shown = 1; else { - top = (float) position / whole; - shown = (float) portion / whole; + top = position / dwhole; + shown = portion / dwhole; } { @@ -6447,13 +6452,13 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, #if ! defined (HAVE_XAW3D) /* With Xaw, 'top' values too closer to 1.0 may cause the thumb to disappear. Fix that. */ - top = min (top, 0.99f); + top = min (top, 0.99); #endif /* Keep two pixels available for moving the thumb down. */ - shown = max (0, min (1 - top - (2.0f / height), shown)); + shown = max (0, min (1 - top - (2.0 / height), shown)); #if ! defined (HAVE_XAW3D) /* Likewise with too small 'shown'. */ - shown = max (shown, 0.01f); + shown = max (shown, 0.01); #endif #endif @@ -6462,7 +6467,8 @@ x_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, If this is not so, most likely you need to fix configure. */ XawScrollbarSetThumb (widget, top, shown); #if false - if (top != old_top || shown != old_shown) + float ftop = top, fshown = shown; + if (ftop != old_top || fshown != old_shown) { if (bar->dragging == -1) XawScrollbarSetThumb (widget, top, shown);