From: Matthew Fernandez Date: Sun, 20 Mar 2022 01:36:40 +0000 (-0700) Subject: gvpr: rewrite debug graph processing to use stdio instead of sfio X-Git-Tag: 4.0.0~164^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa0d7c1ad3d495cdbd0f376c06df58a99a0a9e10;p=graphviz gvpr: rewrite debug graph processing to use stdio instead of sfio This cuts a dependency on sfio, as well as a dependency on non-portable unistd.h functions. Gitlab: #1998, #2204 --- diff --git a/cmd/gvpr/gvprmain.c b/cmd/gvpr/gvprmain.c index 819b692a6..d6d414e5d 100644 --- a/cmd/gvpr/gvprmain.c +++ b/cmd/gvpr/gvprmain.c @@ -21,20 +21,11 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#else -#include -#endif - - - #include #include #include #ifdef DEBUG -#include static ssize_t outfn (void* sp, const char *buf, size_t nbyte, void* dp) { if (nbyte > (size_t)INT_MAX) { @@ -53,17 +44,17 @@ static ssize_t errfn (void* sp, const char *buf, size_t nbyte, void* dp) static int iofread(void *chan, char *buf, int bufsize) { - return read(sffileno(chan), buf, bufsize); + return (int)fread(buf, 1, (size_t)bufsize, chan); } static int ioputstr(void *chan, const char *str) { - return sfputr(chan, str, -1); + return fputs(str, chan); } static int ioflush(void *chan) { - return sfsync(chan); + return fflush(chan); } static Agiodisc_t gprIoDisc = { iofread, ioputstr, ioflush }; @@ -74,7 +65,7 @@ int main (int argc, char* argv[]) { Agraph_t* gs[2]; - Agraph_t* g = agread (sfstdin, &gprDisc); + Agraph_t* g = agread(stdin, &gprDisc); int rv; gvpropts opts; @@ -88,9 +79,7 @@ main (int argc, char* argv[]) rv = gvpr (argc, argv, &opts); - sfprintf (sfstderr, "rv %d\n", rv); - /* for (i = 0; i < opts.n_outgraphs; i++) */ - /* agwrite (opts.outgraphs[i], sfstdout); */ + fprintf(stderr, "rv %d\n", rv); rv = gvpr (argc, argv, &opts);