]> granicus.if.org Git - graphviz/commitdiff
simplify attach_attrs_and_arrows with agxbprint
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Sep 2020 17:01:57 +0000 (10:01 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 17 Sep 2020 04:08:23 +0000 (21:08 -0700)
lib/common/output.c

index 9d9e6769b2894cedd73ed6f0594fa46f293e2ee0..d03f00967802736b10a52326ef1d9d3bfaf79a13 100644 (file)
@@ -275,11 +275,9 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep)
        if (dim3) {
            int k;
 
-           sprintf(buf, "%.5g,%.5g,%.5g", ND_coord(n).x, YDIR(ND_coord(n).y), POINTS_PER_INCH*(ND_pos(n)[2]));
-           agxbput (&xb, buf);
+           agxbprint(&xb, "%.5g,%.5g,%.5g", ND_coord(n).x, YDIR(ND_coord(n).y), POINTS_PER_INCH*(ND_pos(n)[2]));
            for (k = 3; k < GD_odim(g); k++) {
-               sprintf(buf, ",%.5g", POINTS_PER_INCH*(ND_pos(n)[k]));
-               agxbput (&xb, buf);
+               agxbprint(&xb, ",%.5g", POINTS_PER_INCH*(ND_pos(n)[k]));
            }
            agset(n, "pos", agxbuse(&xb));
        } else {
@@ -318,14 +316,13 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep)
                    if (i > 0)
                        agxbputc(&xb, ' ');
                    if (poly->sides >= 3)
-                       sprintf(buf, "%.5g %.5g",
+                       agxbprint(&xb, "%.5g %.5g",
                                PS2INCH(poly->vertices[i].x),
                                YFDIR(PS2INCH(poly->vertices[i].y)));
                    else
-                       sprintf(buf, "%.5g %.5g",
+                       agxbprint(&xb, "%.5g %.5g",
                                ND_width(n) / 2.0 * cos(i / (double) sides * M_PI * 2.0),
                                YFDIR(ND_height(n) / 2.0 * sin(i / (double) sides * M_PI * 2.0)));
-                   agxbput(&xb, buf);
                }
                agxset(n, N_vertices, agxbuse(&xb));
            }
@@ -357,8 +354,7 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep)
                        if (j > 0)
                            agxbputc(&xb, ' ');
                        ptf = ED_spl(e)->list[i].list[j];
-                       sprintf(buf, "%.5g,%.5g", ptf.x, YDIR(ptf.y));
-                       agxbput(&xb, buf);
+                       agxbprint(&xb, "%.5g,%.5g", ptf.x, YDIR(ptf.y));
                    }
                }
                agset(e, "pos", agxbuse(&xb));