* Contributors: Details at https://graphviz.org
*************************************************************************/
+#include <cgraph/agxbuf.h>
#include <cgraph/unreachable.h>
#include <common/render.h>
#include <label/xlabels.h>
place_root_label(g, dimen);
if (Show_boxes) {
- char buf[BUFSIZ];
+ agxbuf buf = {0};
if (Flip)
- snprintf(buf, sizeof(buf), M2, Offset.x, Offset.y, Offset.x, Offset.y);
+ agxbprint(&buf, M2, Offset.x, Offset.y, Offset.x, Offset.y);
else
- snprintf(buf, sizeof(buf), M1, Offset.y, Offset.x, Offset.y, Offset.x,
+ agxbprint(&buf, M1, Offset.y, Offset.x, Offset.y, Offset.x,
-Offset.x, -Offset.y);
- Show_boxes[0] = strdup(buf);
+ Show_boxes[0] = agxbdisown(&buf);
}
}
*************************************************************************/
#include "config.h"
-
+#include <cgraph/agxbuf.h>
#include <common/render.h>
#include <math.h>
#include <pathplan/pathplan.h>
{
pointf ll, ur;
int bi;
- char buf[BUFSIZ];
int newcnt = Show_cnt + boxn;
Show_boxes = ALLOC(newcnt+2,Show_boxes,char*);
for (bi = 0; bi < boxn; bi++) {
ll = boxes[bi].LL, ur = boxes[bi].UR;
- snprintf(buf, sizeof(buf), "%d %d %d %d pathbox", (int)ll.x, (int)ll.y,
+ agxbuf buf = {0};
+ agxbprint(&buf, "%d %d %d %d pathbox", (int)ll.x, (int)ll.y,
(int)ur.x, (int)ur.y);
- Show_boxes[bi+1+Show_cnt] = strdup (buf);
+ Show_boxes[bi + 1 + Show_cnt] = agxbdisown(&buf);
}
Show_cnt = newcnt;
Show_boxes[Show_cnt+1] = NULL;
static void psprintspline(Ppolyline_t spl)
{
- char buf[BUFSIZ];
int newcnt = Show_cnt + spl.pn + 4;
int li, i;
Show_boxes[li++] = strdup ("%% spline");
Show_boxes[li++] = strdup ("gsave 1 0 0 setrgbcolor newpath");
for (i = 0; i < spl.pn; i++) {
- snprintf(buf, sizeof(buf), "%f %f %s", spl.ps[i].x, spl.ps[i].y,
+ agxbuf buf = {0};
+ agxbprint(&buf, "%f %f %s", spl.ps[i].x, spl.ps[i].y,
i == 0 ? "moveto" : (i % 3 == 0 ? "curveto" : ""));
- Show_boxes[li++] = strdup (buf);
+ Show_boxes[li++] = agxbdisown(&buf);
}
Show_boxes[li++] = strdup ("stroke grestore");
Show_cnt = newcnt;
static void psprintline(Ppolyline_t pl)
{
- char buf[BUFSIZ];
int newcnt = Show_cnt + pl.pn + 4;
int i, li;
Show_boxes[li++] = strdup ("%% line");
Show_boxes[li++] = strdup ("gsave 0 0 1 setrgbcolor newpath");
for (i = 0; i < pl.pn; i++) {
- snprintf(buf, sizeof(buf), "%f %f %s", pl.ps[i].x, pl.ps[i].y,
+ agxbuf buf = {0};
+ agxbprint(&buf, "%f %f %s", pl.ps[i].x, pl.ps[i].y,
i == 0 ? "moveto" : "lineto");
- Show_boxes[li++] = strdup (buf);
+ Show_boxes[li++] = agxbdisown(&buf);
}
Show_boxes[li++] = strdup ("stroke grestore");
Show_cnt = newcnt;
static void psprintpoly(Ppoly_t p)
{
- char buf[BUFSIZ];
int newcnt = Show_cnt + p.pn + 3;
point tl, hd;
int bi, li;
hd.y = (int)p.ps[(bi+1) % p.pn].y;
if (tl.x == hd.x && tl.y == hd.y) pfx = "%%";
else pfx ="";
- snprintf(buf, sizeof(buf), "%s%d %d %d %d makevec", pfx, tl.x, tl.y, hd.x,
- hd.y);
- Show_boxes[li++] = strdup (buf);
+ agxbuf buf = {0};
+ agxbprint(&buf, "%s%d %d %d %d makevec", pfx, tl.x, tl.y, hd.x, hd.y);
+ Show_boxes[li++] = agxbdisown(&buf);
}
Show_boxes[li++] = strdup ("grestore");
static void psprintboxes(int boxn, boxf* boxes)
{
- char buf[BUFSIZ];
int newcnt = Show_cnt + 5*boxn + 3;
pointf ll, ur;
int bi, li;
Show_boxes[li++] = strdup ("gsave 0 1 0 setrgbcolor");
for (bi = 0; bi < boxn; bi++) {
ll = boxes[bi].LL, ur = boxes[bi].UR;
- snprintf(buf, sizeof(buf), "newpath\n%d %d moveto", (int)ll.x, (int)ll.y);
- Show_boxes[li++] = strdup (buf);
- snprintf(buf, sizeof(buf), "%d %d lineto", (int)ll.x, (int)ur.y);
- Show_boxes[li++] = strdup (buf);
- snprintf(buf, sizeof(buf), "%d %d lineto", (int)ur.x, (int)ur.y);
- Show_boxes[li++] = strdup (buf);
- snprintf(buf, sizeof(buf), "%d %d lineto", (int)ur.x, (int)ll.y);
- Show_boxes[li++] = strdup (buf);
+ agxbuf buf = {0};
+ agxbprint(&buf, "newpath\n%d %d moveto", (int)ll.x, (int)ll.y);
+ Show_boxes[li++] = agxbdisown(&buf);
+ agxbprint(&buf, "%d %d lineto", (int)ll.x, (int)ur.y);
+ Show_boxes[li++] = agxbdisown(&buf);
+ agxbprint(&buf, "%d %d lineto", (int)ur.x, (int)ur.y);
+ Show_boxes[li++] = agxbdisown(&buf);
+ agxbprint(&buf, "%d %d lineto", (int)ur.x, (int)ll.y);
+ Show_boxes[li++] = agxbdisown(&buf);
Show_boxes[li++] = strdup ("closepath stroke");
}
Show_boxes[li++] = strdup ("grestore");