From 78f9475396f1271f8c9a699c4461c0bdcbf942bb Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Mon, 5 Dec 2016 02:10:22 +0100 Subject: [PATCH] Prevent values like -0 in xdot output Two graphs in the shapes regression test reference files (invhouse and invtrapezium) contained a -0 coordinate. The Linux build produced the same results, but the Windows build didn't, causing the regression tests to fail. To prevent values like -0 in the xdot output, a comparison is added just before formatting the number. --- plugin/core/gvrender_core_dot.c | 5 +++++ tests/regression_tests/shapes/reference/invhouse.xdot | 2 +- tests/regression_tests/shapes/reference/invtrapezium.xdot | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/core/gvrender_core_dot.c b/plugin/core/gvrender_core_dot.c index 59407acf2..5f4ffd694 100644 --- a/plugin/core/gvrender_core_dot.c +++ b/plugin/core/gvrender_core_dot.c @@ -140,6 +140,11 @@ static void xdot_trim_zeros (char* buf, int addSpace) */ static void xdot_fmt_num (char* buf, double v) { + // Prevents values like -0 + if (v > -0.00000001 && v < 0.00000001) + { + v = 0; + } sprintf(buf, "%.02f", v); xdot_trim_zeros (buf, 1); } diff --git a/tests/regression_tests/shapes/reference/invhouse.xdot b/tests/regression_tests/shapes/reference/invhouse.xdot index de4ee07e8..72e37cc8a 100644 --- a/tests/regression_tests/shapes/reference/invhouse.xdot +++ b/tests/regression_tests/shapes/reference/invhouse.xdot @@ -4,7 +4,7 @@ graph G { xdotversion=1.7 ]; node [label="\N"]; - a [_draw_="c 7 -#000000 p 5 0 12.44 27 -0 54 12.44 53.97 32.56 0.03 32.56 ", + a [_draw_="c 7 -#000000 p 5 0 12.44 27 0 54 12.44 53.97 32.56 0.03 32.56 ", height=0.5, label="", pos="27,18", diff --git a/tests/regression_tests/shapes/reference/invtrapezium.xdot b/tests/regression_tests/shapes/reference/invtrapezium.xdot index 519eb8dd6..cc1fa4d75 100644 --- a/tests/regression_tests/shapes/reference/invtrapezium.xdot +++ b/tests/regression_tests/shapes/reference/invtrapezium.xdot @@ -4,7 +4,7 @@ graph G { xdotversion=1.7 ]; node [label="\N"]; - a [_draw_="c 7 -#000000 p 4 11.23 0 42.77 0 54 36 -0 36 ", + a [_draw_="c 7 -#000000 p 4 11.23 0 42.77 0 54 36 0 36 ", height=0.5, label="", pos="27,18", -- 2.40.0