]> granicus.if.org Git - graphviz/commitdiff
selfRightSpace: consistently use a double for calculating self width
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 14 Mar 2022 15:09:29 +0000 (08:09 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 20 Mar 2022 01:20:32 +0000 (18:20 -0700)
This avoids going backwards and forwards between double and int, which was
causing some compiler warnings and unnecessary loss of precision.

lib/common/render.h
lib/common/splines.c
lib/dotgen/position.c

index 83703e7f0aeb7b2783729fca55e09020ce949113..4e622a4111e8bc11640b8a2158ab147823b02bed 100644 (file)
@@ -137,7 +137,7 @@ extern "C" {
     RENDER_API void routesplinesterm(void);
     RENDER_API pointf* simpleSplineRoute (pointf, pointf, Ppoly_t, int*, int);
     RENDER_API pointf *routepolylines(path* pp, int* npoints);
-    RENDER_API int selfRightSpace (edge_t* e);
+    RENDER_API double selfRightSpace(edge_t *e);
     RENDER_API shape_kind shapeOf(node_t *);
     RENDER_API void shape_clip(node_t * n, pointf curve[4]);
     RENDER_API void make_simple_label (GVC_t * gvc, textlabel_t* rv);
index bc07b2fa6167c97a6f02bd8600cda6c672dda7fe..15fa081e7b4666d0af1b4ab3b37a4fe1b0b32381 100644 (file)
@@ -1158,10 +1158,8 @@ selfLeft (edge_t* edges[], int ind, int cnt, double stepx, double sizey,
  * so using the constant SELF_EDGE_SIZE is going to be wrong.
  * Fortunately, the default nodesep is the same as SELF_EDGE_SIZE.
  */
-int
-selfRightSpace (edge_t* e)
-{
-    int sw;
+double selfRightSpace(edge_t *e) {
+    double sw;
     double label_width;
     textlabel_t* l = ED_label(e);
 
index 287407ad97f93790148d6673b60869ec26750ab4..1a3578d981d6e64077044ee2d0432a425ca83d11 100644 (file)
@@ -211,7 +211,6 @@ static void
 make_LR_constraints(graph_t * g)
 {
     int i, j, k;
-    int sw;                    /* self width */
     int m0, m1;
     double width;
     int sep[2];
@@ -245,7 +244,7 @@ make_LR_constraints(graph_t * g)
                  * Note that this would not only affect left and right
                  * positioning but may also affect interrank spacing.
                  */
-               sw = 0;
+               double sw = 0; // self width
                for (k = 0; (e = ND_other(u).list[k]); k++) {
                    if (agtail(e) == aghead(e)) {
                        sw += selfRightSpace (e);