From: Matthew Fernandez Date: Sat, 12 Nov 2022 23:53:05 +0000 (-0800) Subject: core plugin: suppress 'offset' double comparison warning X-Git-Tag: 7.0.2~11^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=449407245568ce8a96a142923c388d6bfdfe5d34;p=graphviz core plugin: suppress 'offset' double comparison warning This code is trying to abbreviate printing `0.000` or `1.000`. We can more accurately describe the situations under which this will happen, squashing: gvrender_core_svg.c: In function ‘svg_print_stop’: gvrender_core_svg.c:525:16: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 525 | if (offset == 0.0) | ^~ gvrender_core_svg.c:527:21: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal] 527 | else if (offset == 1.0) | ^~ --- diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index e26bc0d42..76ceb7f81 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -534,9 +534,9 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) static void svg_print_stop(GVJ_t * job, double offset, gvcolor_t color) { - if (offset == 0.0) + if (fabs(offset - 0.0) < 0.0005) gvputs(job, "