* Contributors: Details at https://graphviz.org
*************************************************************************/
+#include <cgraph/agxbuf.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
return strcmp(p0->name, p1->name);
}
-void colorxlate(char *str, char *buf) {
+void colorxlate(char *str, agxbuf *buf) {
static hsbcolor_t *last;
char canon[128];
- char *p;
hsbcolor_t fake;
if (last == NULL || strcmp(last->name, str)) {
if (last == NULL) {
if (!isdigit((int)canon[0])) {
fprintf(stderr, "warning: %s is not a known color\n", str);
- strcpy(buf, str);
+ agxbput(buf, str);
} else
- for (p = buf; (*p = *str++); p++)
- if (*p == ',')
- *p = ' ';
+ for (const char *p = str; *p != '\0'; ++p)
+ agxbputc(buf, *p == ',' ? ' ' : *p);
} else
- sprintf(buf, "%.3f %.3f %.3f", ((double) last->h) / 255,
+ agxbprint(buf, "%.3f %.3f %.3f", ((double) last->h) / 255,
((double) last->s) / 255, ((double) last->b) / 255);
}
#define NC 3 /* size of HSB color vector */
#include <assert.h>
+#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/cgraph.h>
#include <cgraph/exit.h>
static void setcolor(char *p, double *v)
{
- char buf[64];
+ agxbuf buf = {0};
if (sscanf(p, "%lf %lf %lf", v, v + 1, v + 2) != 3 && p[0]) {
- colorxlate(p, buf);
- sscanf(buf, "%lf %lf %lf", v, v + 1, v + 2);
+ colorxlate(p, &buf);
+ sscanf(agxbuse(&buf), "%lf %lf %lf", v, v + 1, v + 2);
}
+ agxbfree(&buf);
}
static char **Files;