]> granicus.if.org Git - graphviz/commitdiff
dotgen adjustregularpath: perform computation in double range
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Sep 2022 00:27:49 +0000 (17:27 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 29 Jan 2023 16:24:43 +0000 (08:24 -0800)
The truncation/rounding to `int` within this function appears unintentional.

lib/dotgen/dotsplines.c

index 160d521cc9e3a3029fb7faced5b5d56a463f7d2d..de3b4765276dfb48fe9917c7ed06a261cc136d57 100644 (file)
@@ -2221,18 +2221,18 @@ void refineregularends(edge_t *left, edge_t *right, pathend_t *endp, int dir,
 static void adjustregularpath(path * P, int fb, int lb)
 {
     boxf *bp1, *bp2;
-    int i, x;
+    int i;
 
     for (i = fb-1; i < lb+1; i++) {
        bp1 = &P->boxes[i];
        if ((i - fb) % 2 == 0) {
            if (bp1->LL.x >= bp1->UR.x) {
-               x = (bp1->LL.x + bp1->UR.x) / 2;
+               double x = (bp1->LL.x + bp1->UR.x) / 2;
                bp1->LL.x = x - HALFMINW, bp1->UR.x = x + HALFMINW;
            }
        } else {
            if (bp1->LL.x + MINW > bp1->UR.x) {
-               x = (bp1->LL.x + bp1->UR.x) / 2;
+               double x = (bp1->LL.x + bp1->UR.x) / 2;
                bp1->LL.x = x - HALFMINW, bp1->UR.x = x + HALFMINW;
            }
        }