]> granicus.if.org Git - graphviz/commitdiff
gvpr: rewrite debug graph processing to use stdio instead of sfio
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 20 Mar 2022 01:36:40 +0000 (18:36 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 25 Mar 2022 14:40:02 +0000 (07:40 -0700)
This cuts a dependency on sfio, as well as a dependency on non-portable unistd.h
functions.

Gitlab: #1998, #2204

cmd/gvpr/gvprmain.c

index 819b692a6edc30b1707a3dd2e91f9ee34a701d8f..d6d414e5d301bbe76d6bb418c30f20bf6f3006a7 100644 (file)
 #include <stddef.h>
 #include <stdio.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#else
-#include <ast/compat_unistd.h>
-#endif
-
-
-
 #include <cgraph/cgraph.h>
 #include <cgraph/exit.h>
 #include <gvpr/gvpr.h>
 
 #ifdef DEBUG
-#include <sfio/sfio.h>
 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);