From: ellson Date: Wed, 19 Dec 2007 22:03:36 +0000 (+0000) Subject: use new gvprintnum routine in -Tps:core X-Git-Tag: LAST_LIBGRAPH~32^2~4968 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b406cbf5fdaab99801957bdcfa9be3e40af5eda2;p=graphviz use new gvprintnum routine in -Tps:core --- diff --git a/lib/gvc/gvcproc.h b/lib/gvc/gvcproc.h index a6ab07bf6..b8c93f6e4 100644 --- a/lib/gvc/gvcproc.h +++ b/lib/gvc/gvcproc.h @@ -77,9 +77,10 @@ extern "C" { extern void gvdevice_format(GVJ_t * job); extern void gvdevice_finalize(GVJ_t * job); - extern char * gvprintnum(int *len, double num); + extern unsigned char * gvprintnum(int *len, double num); extern void gvdevice_printnum(GVJ_t * job, double num); extern void gvdevice_printpointf(GVJ_t * job, pointf p); + extern void gvdevice_printpointflist(GVJ_t * job, pointf *p, int n); /* render */ diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index 4b141f698..1cf0d98cc 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -106,7 +106,7 @@ void gvdevice_printf(GVJ_t * job, const char *format, ...) void gvdevice_printnum(GVJ_t * job, double num) { - char *buf; + unsigned char *buf; int len; buf = gvprintnum(&len, num); @@ -115,16 +115,27 @@ void gvdevice_printnum(GVJ_t * job, double num) void gvdevice_printpointf(GVJ_t * job, pointf p) { - char *buf; + unsigned char *buf; int len; buf = gvprintnum(&len, p.x); gvdevice_write(job, buf, len); - gvdevice_write(job, " ", 1); + gvdevice_write(job, (unsigned char*)" ", 1); buf = gvprintnum(&len, p.y); gvdevice_write(job, buf, len); } +void gvdevice_printpointflist(GVJ_t * job, pointf *p, int n) +{ + int i = 0; + + while (TRUE) { + gvdevice_printpointf(job, p[i]); + if (++i >= n) break; + gvdevice_write(job, (unsigned char*)" ", 1); + } +} + static void auto_output_filename(GVJ_t *job) { static char *buf; diff --git a/lib/gvc/gvprintnum.c b/lib/gvc/gvprintnum.c index 7109e582b..4087fa0c9 100644 --- a/lib/gvc/gvprintnum.c +++ b/lib/gvc/gvprintnum.c @@ -26,14 +26,14 @@ #define DECPLACES_SCALE 100 /* use macro so maxnegnum is stated just once for both double and string versions */ -#define val_str(n, x) static double n = x; static char n##str[] = #x; +#define val_str(n, x) static double n = x; static unsigned char n##str[] = #x; val_str(maxnegnum, -999999999999999.99) /* Note. Returned string is only good until the next call to gvprintnum */ -char * gvprintnum (int *len, double number) +unsigned char * gvprintnum (int *len, double number) { - static char tmpbuf[sizeof(maxnegnumstr)]; /* buffer big enough for worst case */ - char *result = tmpbuf+sizeof(maxnegnumstr); /* init result to end of tmpbuf */ + static unsigned char tmpbuf[sizeof(maxnegnumstr)]; /* buffer big enough for worst case */ + unsigned char *result = tmpbuf+sizeof(maxnegnumstr); /* init result to end of tmpbuf */ long int N; bool showzeros, negative; int digit, i; @@ -61,7 +61,7 @@ char * gvprintnum (int *len, double number) N = number + 0.5; if (N == 0) { /* special case for exactly 0 */ *len = 1; - return "0"; + return (unsigned char *)"0"; } if ((negative = (N < 0))) /* avoid "-0" by testing rounded int */ N = -N; /* make number +ve */ @@ -92,7 +92,7 @@ char * gvprintnum (int *len, double number) #ifdef GVPRINTNUM_TEST int main (int argc, char *argv[]) { - char *buf; + unsigned char *buf; int len; double test[] = {