## [Unreleased (6.0.0)]
+### Changed
+
+- **Breaking**: libxdot fields for the size and number of operations are now
+ `size_t` values instead of `int` values
+
### Removed
- The `$GV_FILE_PATH` sandboxing mechanism has been removed #2257
#include <ctype.h>
#include <float.h>
#include <math.h>
+#include <stddef.h>
static xdot *parseXdotwithattrs(void *e)
{
-
- int cnt=0;
xdot* xDot=NULL;
xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot);
if (agobjkind(e) == AGRAPH)
xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot);
if(xDot)
{
- for (cnt=0;cnt < xDot->cnt ; cnt++)
+ for (size_t cnt = 0; cnt < xDot->cnt; cnt++)
{
((sdot_op*)(xDot->ops))[cnt].obj=e;
}
static void draw_xdot(xdot* x,float base_z)
{
- int i;
sdot_op *op;
if (!x)
return;
view->Topview->global_z=base_z;
op=(sdot_op*)x->ops;
- for (i=0; i < x->cnt; i++,op++)
+ for (size_t i = 0; i < x->cnt; i++, op++)
{
if(op->op.drawfunc)
op->op.drawfunc(&op->op,0);
{
xdot_point s, e;
int v, have_s, have_e, cnt;
- int sz = sizeof(sdot_op);
+ static const size_t sz = sizeof(sdot_op);
xdot* xd;
xdot_op* op;
xdot_point* pts;
#include "config.h"
#include <assert.h>
#include <stdbool.h>
+#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <locale.h>
int ptsize = INITPTS;
pointf* pts = N_GNEW(INITPTS, pointf);
exdot_op* op;
- int i, angle;
+ int angle;
char** styles = NULL;
int filled = FILL;
op = (exdot_op*)(xd->ops);
- for (i = 0; i < xd->cnt; i++) {
+ for (size_t i = 0; i < xd->cnt; i++) {
switch (op->op.kind) {
case xd_filled_ellipse :
case xd_unfilled_ellipse :
{
GVC_t *gvc = GD_gvc(g);
exdot_op* op;
- int i;
double fontsize = 0.0;
char* fontname = NULL;
pointf pts[2];
}
op = (exdot_op*)xd->ops;
- for (i = 0; i < xd->cnt; i++) {
+ for (size_t i = 0; i < xd->cnt; i++) {
tf = null_tf;
switch (op->op.kind) {
case xd_filled_ellipse :
* Parse and append additional xops onto a given xdot object.
* Return x.
*/
-xdot *parseXDotFOn (char *s, drawfunc_t fns[], int sz, xdot* x)
-{
+xdot *parseXDotFOn(char *s, drawfunc_t fns[], size_t sz, xdot *x) {
xdot_op op;
char *ops;
- int oldsz, bufsz;
+ size_t oldsz, bufsz;
int error;
- int initcnt;
if (!s)
return x;
if (!x) {
x = gv_alloc(sizeof(*x));
- if (sz < 0 || (size_t)sz <= sizeof(xdot_op))
+ if (sz <= sizeof(xdot_op))
sz = sizeof(xdot_op);
/* cnt, freefunc, ops, flags zeroed by gv_alloc */
x->sz = sz;
}
- initcnt = x->cnt;
+ size_t initcnt = x->cnt;
sz = x->sz;
if (initcnt == 0) {
}
-xdot *parseXDotF(char *s, drawfunc_t fns[], int sz)
-{
+xdot *parseXDotF(char *s, drawfunc_t fns[], size_t sz) {
return parseXDotFOn (s, fns, sz, NULL);
}
static void _printXDot(xdot * x, pf print, void *info, print_op ofn)
{
- int i;
xdot_op *op;
char *base = (char *) (x->ops);
- for (i = 0; i < x->cnt; i++) {
+ for (size_t i = 0; i < x->cnt; i++) {
op = (xdot_op *) (base + i * x->sz);
ofn(op, print, info, i < x->cnt - 1);
}
void freeXDot (xdot * x)
{
- int i;
xdot_op *op;
char *base;
freefunc_t ff = x->freefunc;
if (!x) return;
base = (char *) (x->ops);
- for (i = 0; i < x->cnt; i++) {
+ for (size_t i = 0; i < x->cnt; i++) {
op = (xdot_op *) (base + i * x->sz);
if (ff) ff (op);
freeXOpData(op);
int statXDot (xdot* x, xdot_stats* sp)
{
- int i;
xdot_op *op;
char *base;
memset(sp, 0, sizeof(xdot_stats));
sp->cnt = x->cnt;
base = (char *) (x->ops);
- for (i = 0; i < x->cnt; i++) {
+ for (size_t i = 0; i < x->cnt; i++) {
op = (xdot_op *) (base + i * x->sz);
switch (op->kind) {
case xd_filled_ellipse:
#pragma once
+#include <stddef.h>
#include <stdio.h>
#ifdef __cplusplus
#define XDOT_PARSE_ERROR 1
typedef struct {
- int cnt; /* no. of xdot ops */
- int sz; /* sizeof structure containing xdot_op as first field */
+ size_t cnt; /* no. of xdot ops */
+ size_t sz; /* sizeof structure containing xdot_op as first field */
xdot_op* ops;
freefunc_t freefunc;
int flags;
} xdot;
typedef struct {
- int cnt; /* no. of xdot ops */
+ size_t cnt; /* no. of xdot ops */
int n_ellipse;
int n_polygon;
int n_polygon_pts;
} xdot_stats;
/* ops are indexed by xop_kind */
-XDOT_API xdot* parseXDotF (char*, drawfunc_t opfns[], int sz);
-XDOT_API xdot* parseXDotFOn (char*, drawfunc_t opfns[], int sz, xdot*);
+XDOT_API xdot *parseXDotF(char*, drawfunc_t opfns[], size_t sz);
+XDOT_API xdot *parseXDotFOn(char*, drawfunc_t opfns[], size_t sz, xdot*);
XDOT_API xdot* parseXDot (char*);
XDOT_API char* sprintXDot (xdot*);
XDOT_API void fprintXDot (FILE*, xdot*);
static void write_xdots (char * val, GVJ_t * job, state_t* sp)
{
xdot* cmds;
- int i;
if (!val || *val == '\0') return;
gvputs(job, "\n");
indent(job, sp->Level++);
gvputs(job, "[\n");
- for (i = 0; i < cmds->cnt; i++) {
+ for (size_t i = 0; i < cmds->cnt; i++) {
if (i > 0)
gvputs(job, ",\n");
write_xdot (cmds->ops+i, job, sp);