From: Matthew Fernandez Date: Mon, 25 Apr 2022 00:16:12 +0000 (-0700) Subject: replace various SFIO to stderr with C stdio X-Git-Tag: 4.0.0~59^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c24d86977b1c580b4daafd0eeb3eb81dbffb230b;p=graphviz replace various SFIO to stderr with C stdio While it is technically possible to replace the `sfstderr` stream with something other than stderr or use an SFIO-specific format specifier (e.g. `%!`), nothing in Graphviz permits this. Thus we know all these instances are actually just doing basic output to stderr. By replacing them with C stdio, they are more transparent to the compiler and can be implemented more efficiently. Gitlab: #1998 --- diff --git a/lib/ast/error.c b/lib/ast/error.c index 13d28a0fb..32f854b4c 100644 --- a/lib/ast/error.c +++ b/lib/ast/error.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -53,36 +54,36 @@ void errorv(const char *id, int level, const char *s, va_list ap) const char *prefix; if (level && ((prefix = error_info.id) || (prefix = id))) { if (flags & ERROR_USAGE) - sfprintf(sfstderr, "Usage: %s ", prefix); + fprintf(stderr, "Usage: %s ", prefix); else - sfprintf(sfstderr, "%s: ", prefix); + fprintf(stderr, "%s: ", prefix); } if (flags & ERROR_USAGE) /*nop */ ; else if (level < 0) { int i; for (i = 0; i < error_info.indent; i++) - sfprintf(sfstderr, " "); - sfprintf(sfstderr, "debug%d: ", level); + fprintf(stderr, " "); + fprintf(stderr, "debug%d: ", level); } else if (level) { if (level == ERROR_WARNING) { - sfprintf(sfstderr, "warning: "); + fprintf(stderr, "warning: "); error_info.warnings++; } else { error_info.errors++; if (level == ERROR_PANIC) - sfprintf(sfstderr, "panic: "); + fprintf(stderr, "panic: "); } if (error_info.line) { if (error_info.file && *error_info.file) - sfprintf(sfstderr, "\"%s\", ", error_info.file); - sfprintf(sfstderr, "line %d: ", error_info.line); + fprintf(stderr, "\"%s\", ", error_info.file); + fprintf(stderr, "line %d: ", error_info.line); } } - sfvprintf(sfstderr, s, ap); + vfprintf(stderr, s, ap); if (flags & ERROR_SYSTEM) - sfprintf(sfstderr, "\n%s", strerror(errno)); - sfprintf(sfstderr, "\n"); + fprintf(stderr, "\n%s", strerror(errno)); + fprintf(stderr, "\n"); if (level >= ERROR_FATAL) graphviz_exit(level - ERROR_FATAL + 1); } diff --git a/lib/gvpr/gvpr.c b/lib/gvpr/gvpr.c index e43713196..b869456ac 100644 --- a/lib/gvpr/gvpr.c +++ b/lib/gvpr/gvpr.c @@ -339,8 +339,7 @@ doFlags(char* arg, int argi, int argc, char** argv, options* opts) opts->verbose = 1; break; case 'V': - sfprintf(sfstderr, "%s version %s (%s)\n", - Info[0], Info[1], Info[2]); + fprintf(stderr, "%s version %s (%s)\n", Info[0], Info[1], Info[2]); return 0; break; case '?': @@ -1001,7 +1000,7 @@ int gvpr (int argc, char *argv[], gvpropts * uopts) incoreGraphs = 0; if (opts->verbose) - sfprintf (sfstderr, "Parse/compile/init: %.2f secs.\n", gvelapsed_sec()); + fprintf(stderr, "Parse/compile/init: %.2f secs.\n", gvelapsed_sec()); /* do begin */ if (xprog->begin_stmt) exeval(xprog->prog, xprog->begin_stmt, state); @@ -1015,7 +1014,7 @@ int gvpr (int argc, char *argv[], gvpropts * uopts) if (opts->verbose) gvstart_timer (); for (state->curgraph = nextGraph(ing); state->curgraph; state->curgraph = nextg) { - if (opts->verbose) sfprintf (sfstderr, "Read graph: %.2f secs.\n", gvelapsed_sec()); + if (opts->verbose) fprintf(stderr, "Read graph: %.2f secs.\n", gvelapsed_sec()); state->infname = fileName(ing); if (opts->readAhead) nextg = state->nextgraph = nextGraph(ing); @@ -1042,7 +1041,7 @@ int gvpr (int argc, char *argv[], gvpropts * uopts) state->curobj = (Agobj_t *) state->curgraph; if (xprog->endg_stmt) exeval(xprog->prog, xprog->endg_stmt, state); - if (opts->verbose) sfprintf (sfstderr, "Finish graph: %.2f secs.\n", gvelapsed_sec()); + if (opts->verbose) fprintf(stderr, "Finish graph: %.2f secs.\n", gvelapsed_sec()); /* if $O == $G and $T is empty, delete $T */ if ((state->outgraph == state->curgraph) && @@ -1069,7 +1068,7 @@ int gvpr (int argc, char *argv[], gvpropts * uopts) if (opts->verbose) gvstart_timer (); if (!opts->readAhead) nextg = nextGraph(ing); - if (opts->verbose && nextg) sfprintf (sfstderr, "Read graph: %.2f secs.\n", gvelapsed_sec()); + if (opts->verbose && nextg) fprintf(stderr, "Read graph: %.2f secs.\n", gvelapsed_sec()); } }