]> granicus.if.org Git - graphviz/commitdiff
dotgen pf2s: replace 'sprintf' into a raw buffer with 'agxbprint'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 28 Jan 2023 16:51:55 +0000 (08:51 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 30 Jan 2023 15:43:10 +0000 (07:43 -0800)
Gitlab: #1950

lib/dotgen/compound.c

index 47f25e6af5bd7a4604423f322bc944ebd24b43cf..6b4441482b9f3f104daaaca3093f98b52206fff8 100644 (file)
 /* Module for clipping splines to cluster boxes.
  */
 
+#include       <cgraph/agxbuf.h>
 #include       <dotgen/dot.h>
 
 /* pf2s:
  * Convert a pointf to its string representation.
  */
-static char *pf2s(pointf p, char *buf)
-{
-    sprintf(buf, "(%.5g,%.5g)", p.x, p.y);
-    return buf;
+static char *pf2s(pointf p, agxbuf *xb) {
+  agxbprint(xb, "(%.5g,%.5g)", p.x, p.y);
+  return agxbuse(xb);
 }
 
 /* Return point where line segment [pp,cp] intersects
@@ -66,12 +66,16 @@ static pointf boxIntersectf(pointf pp, pointf cp, boxf * bp)
 
     /* failure */
     {
-       char ppbuf[100], cpbuf[100], llbuf[100], urbuf[100];
+       agxbuf ppbuf = {0}, cpbuf = {0}, llbuf = {0}, urbuf = {0};
 
        agerr(AGERR,
                "segment [%s,%s] does not intersect box ll=%s,ur=%s\n",
-               pf2s(pp, ppbuf), pf2s(cp, cpbuf),
-               pf2s(ll, llbuf), pf2s(ur, urbuf));
+               pf2s(pp, &ppbuf), pf2s(cp, &cpbuf),
+               pf2s(ll, &llbuf), pf2s(ur, &urbuf));
+       agxbfree(&ppbuf);
+       agxbfree(&cpbuf);
+       agxbfree(&llbuf);
+       agxbfree(&urbuf);
        assert(0);
     }
     return ipp;