From: Matthew Fernandez Date: Sun, 20 Mar 2022 01:29:07 +0000 (-0700) Subject: gvpr: rewrite debug I/O output to use stdio instead of unistd X-Git-Tag: 4.0.0~164^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9492642c7d6f3f5191a313d179833318c7a7210;p=graphviz gvpr: rewrite debug I/O output to use stdio instead of unistd There is no need to use the lower level `write` API for this I/O. By using `fprintf` instead, we avoid a dependency on non-portable unistd.h. Gitlab: #2204 --- diff --git a/cmd/gvpr/gvprmain.c b/cmd/gvpr/gvprmain.c index 228e8365b..819b692a6 100644 --- a/cmd/gvpr/gvprmain.c +++ b/cmd/gvpr/gvprmain.c @@ -17,6 +17,9 @@ #include "config.h" +#include +#include +#include #ifdef HAVE_UNISTD_H #include @@ -34,14 +37,18 @@ #include static ssize_t outfn (void* sp, const char *buf, size_t nbyte, void* dp) { - write (1, " ", 8); - return write (1, buf, nbyte); + if (nbyte > (size_t)INT_MAX) { + return -1; + } + return printf("%.*s", (int)nbyte, buf); } static ssize_t errfn (void* sp, const char *buf, size_t nbyte, void* dp) { - write (2, " ", 8); - return write (2, buf, nbyte); + if (nbyte > (size_t)INT_MAX) { + return -1; + } + return fprintf(stderr, "%.*s", (int)nbyte, buf); } static int iofread(void *chan, char *buf, int bufsize)